text:
Bitcoin Core 0.17 fails after loading too many wallets
I can start bitcoin core loading with 200 wallets. But when I increase it to 300 wallets, it fails. Below is the debug.log when I tried to load 300 wallets.
2018-12-17T01:36:27Z init message: Loading wallet...
2018-12-17T01:36:27Z [wallet-201.dat] nFileVersion = 170001
2018-12-17T01:36:27Z [wallet-201.dat] Keys: 3 plaintext, 0 encrypted, 3 w/ metadata, 3 total. Unknown wallet records: 1
2018-12-17T01:36:27Z [wallet-201.dat] Wallet completed loading in               1ms
2018-12-17T01:36:27Z [wallet-201.dat] setKeyPool.size() = 2
2018-12-17T01:36:27Z [wallet-201.dat] mapWallet.size() = 0
2018-12-17T01:36:27Z [wallet-201.dat] mapAddressBook.size() = 0
2018-12-17T01:36:27Z init message: Loading wallet...
2018-12-17T01:36:27Z [wallet-202.dat] nFileVersion = 170001
2018-12-17T01:36:27Z [wallet-202.dat] Keys: 3 plaintext, 0 encrypted, 3 w/ metadata, 3 total. Unknown wallet records: 1
2018-12-17T01:36:39Z [wallet-202.dat] Wallet completed loading in           12012ms
2018-12-17T01:36:39Z init message: Rescanning...
2018-12-17T01:36:39Z [wallet-202.dat] Rescanning last 1447907 blocks (from block 0)...
2018-12-17T01:36:39Z [wallet-202.dat] Rescan started from block 1447885...
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=14930383)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=14955195)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15731604)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15152698)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=14994412)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15000180)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15237899)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15073409)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15076691)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15162221)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15175705)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15238839)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15734430)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15746232)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15755504)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15759768)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15780715)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15795130)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15814178)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15841983)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15844548)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15870120)
2018-12-17T01:36:39Z Unable to open file /root/.bitcoin/testnet3/blocks/blk00155.dat
2018-12-17T01:36:39Z ERROR: ReadBlockFromDisk: OpenBlockFile failed for CBlockDiskPos(nFile=155, nPos=15897975)
2018-12-17T01:36:39Z [wallet-202.dat] Rescan completed in               1ms
2018-12-17T01:36:39Z [wallet-202.dat] setKeyPool.size() = 2
2018-12-17T01:36:39Z [wallet-202.dat] mapWallet.size() = 0
2018-12-17T01:36:39Z [wallet-202.dat] mapAddressBook.size() = 0
2018-12-17T01:36:39Z init message: Loading wallet...
2018-12-17T01:36:51Z [wallet-203.dat] Releasing wallet
2018-12-17T01:36:51Z BerkeleyEnvironment::Flush: Flush(false)
2018-12-17T01:36:51Z BerkeleyEnvironment::Flush: Flush(false) took               0ms
2018-12-17T01:36:51Z

************************
EXCEPTION: St13runtime_error
BerkeleyBatch: Error 24, can't open database wallet.dat
bitcoin in AppInit()

You are going to run into issues when opening many wallets at the same time due to memory constraints. When a wallet is opened, some data from the wallet is stored in memory. If you have too many wallets opened, then you may run out of memory to store all of that extra data. This will impact other parts of the process too and could result in corrupt databases and corrupted wallets.
Furthermore, opening wallets means that a new file is being opened. Modern operating systems have limits on the number of open files a process can have. In your case, the error number 24 means that there are too many file opened. You will need to lookup how to increase the open file limit for your OS.
I do not recommend that you continue to try to have so many wallets open at once. Bitcoin Core now has dynamic loading and unloading of wallets, so you can load a wallet when you need it and unload it when you are done. This will let you have fewer wallets open simultaneously and you will not run into such issues.

Thanks for the suggestion. The reason I load so many wallets at the same time is because I wanted to use bitcoin walletNotify. I've tested that walletNotify won't work if I didn't load the wallet.
I guess I need to import all addresses from each wallets into 1 wallet as watch-only addresses. Is there a limit on running a wallet with too many watch-only addresses?

You will run into memory issues eventually, but you won't run into the too many open files problem.

I don't see what in the log indicates memory? What am I missing? --other things that could also contribute is that bdb has many default limits that might be hit, or just running into the file descriptors ulimit.

@G. Maxwell He hit the file descriptor limit, but I am mentioning in my answer out of memory because he's going to hit that too eventually if he raises the file descriptor limit.

It's not unreasonable for a host to have hundreds of gigabytes of ram these days, ... I'd understand you saying that he'd run out of memory if he said he wanted to load tens of millions of wallets...


text:
Bitcoin Core signing using signrawtransactionwithkey returns null
I am trying to sign a transaction to spend funds from a 3 of 7 multisig address.
signrawtransactionwithkey 0200000001df84bf87bee6e5ef37252bee0aefffff01570400000000000017a914ab7810c333815366e268a8e21cdd516a73e353348700000000 "[   \"L19iWVPKJLUm316JUSwuKanZ1aUNk\",
    \"L4QXPc2ErXQ5cpmSizgnqL3VdUNFr3\",
    \"L3u2KCt3oBYp1rTn8a7AK8cdZjp8wsF\"
]"
[{
    "txid": "a9d4599e15b53f3eb56bda871e8b34f2f430c",
    "vout": 0,
    "scriptPubKey": "a9142371a0f091d72061f52b3a87",
    "redeemScript": "53210386c5bb843616d7e504997778707701b5245904a48d0e2e7b64e0fe346bee975d321023bd5cef26304c25450933da1dd50d6d39625ae8154319e14884c76b0300336a22102ed48db7649ae65433f6c46bbdbf143927411c9c12878f85b64815183a458b5ea210379371734a424889ded7f8de018d7e4c6f1ce7196980c80e9d6f3bb748668415d2102051d068ac8dee4aa46af230ea46d96a860c4c65f000831e748b866ffdfb74f3d21029c7cc1f53494ae3ce3f44adbdf9bee34ce5f8e70cb099b9c72ba31f71cf1617c57ae",
    "amount": "0.00001234"
}]

Ive redacted a bit of the private keys, etc - though there are only a few sats so if someone guesses cracks it enjoy.
The response I am getting is "null" instead of the expected output from signrawtransaction (including the signed transaction).

What version of Bitcoin Core are you using?

Maybe it is because a ton of things are wrong with your input. I'm not sure when you were "redacted" private keys you changed other things or not, but if you didn't they are wrong. More noticeably is your redeemScript which is 3 of 7 but provides only 6 public keys and also it has 1 extra bytes right after the first one (..975d321023b..) which makes the hex and script invalid.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Bitcoind in test network doesn't display transactions
Hello i'm setting up the bitcoin-core daemon, i use version 160300 ( but it is same problem with newer version ).
I have made config like this:
testnet.conf
server=1
listen=50
listenonion=0
testnet=1
bind=127.0.0.1:18333
proxy=127.0.0.1:9050
rpcuser=bob
rpcpassword=12345
rpcport=18332
port=18333

datadir=/home/testnet/
pid=/home/testnet/.pid

then i run bitcoind:
bitcoind -daemon -conf="~/btc/testnet.conf"
Now i got me some address, using:
bitcoin-cli --rpcuser="bob" --rpcpassword="12345" --rpcport=18332 getnewaddress "test_user"
Result is 2NF9YinW7mqpUGy1GySD2xEV11uVPbQggbb
Then i go to this site https://coinfaucet.eu/en/btc-testnet/
I enter this address 2NF9YinW7mqpUGy1GySD2xEV11uVPbQggbb and press send, it gives me back transaction id, this is it here https://live.blockcypher.com/btc-testnet/tx/d2aa744b33e60f959217cf2ae3852f8826bb2d977839b4a2be0a958aec6a9984/
But i do now:
bitcoin-cli --rpcuser="bob" --rpcpassword="12345" --rpcport=18332 listtransactions

and in result get this:
[
]

No incoming transactions. getbalance returns 0
Can someone help. what is going on, do i need to mine blocks or something to get that transaction ? Or should i wait more for bitcoind to work ?
UPDATE:
The output of getblockcount is 1381543 and it seems to increase when i send getblockcount again
The output of getblockchaininfo is:
{
  "chain": "test",
  "blocks": 1381659,
  "headers": 1580289,
  "bestblockhash": "0000000000000095a7c30336ab1c9f12260b5a8fb2deb6dde59ab8c372376a64",
  "difficulty": 17349304.92883517,
  "mediantime": 1533662288,
  "verificationprogress": 0.8876421741980308,
  "initialblockdownload": true,
  "chainwork": "00000000000000000000000000000000000000000000008b05062dc0c9f9c122",
  "size_on_disk": 15923153327,
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "reject": {
        "status": true
      }
    },
    {
      "id": "bip66",
      "version": 3,
      "reject": {
        "status": true
      }
    },
    {
      "id": "bip65",
      "version": 4,
      "reject": {
        "status": true
      }
    }
  ],
  "bip9_softforks": {
    "csv": {
      "status": "active",
      "startTime": 1456790400,
      "timeout": 1493596800,
      "since": 770112
    },
    "segwit": {
      "status": "active",
      "startTime": 1462060800,
      "timeout": 1493596800,
      "since": 834624
    }
  },
  "warnings": ""
}

Is Bitcoin Core synced yet? What do you get for getblockcount? Can you update your question with the output of getblockchaininfo?

@AndrewChow i have updated my post

Bitcoin Core has not yet fully synced the testnet blockchain. You can see this in the getblockchaininfo output, it has "initialblockdownload": true and the number of blocks is less than the number of headers (headers are synced first so the number of headers indicates the number of blocks that need to be synced).
You should see your balance once your node has fully synced.

Sounds like you did not give bitcoind time to "sync", no other explanation comes to mind. Starting bitcoin-qt may be more obvious.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
api.pro.coinbase.com retrieve historic candles data
I am using PHP to retrieve historic candles data from api.pro.coinbase.com
https://api.pro.coinbase.com/products/BTC-USD/candles?granularity=86400

Above URL gets 300 candles. I would like to know how I can get more or less candles.
In bitfinex I can set the number of candles (up to 1000) using limit parameter like this https://api.bitfinex.com/v2/candles/trade:1D:tBTCUSD/hist?limit=1000

Im working on the same thing. You have to repeat the request.
For 1000 candles you need to loop the request 3-4 times with different start and end parameters.
I had it working for hole hours but now that I switched to minute granularity the request comes out weird.


text:
Consistency when multiple blocks are added
Let's say that 2 miners were able to add a block around the same time. However, when they broadcast their respective blocks to the network, other nodes receive these blocks in arbitrary order. The block that arrives later will be considered invalid because the hash of the previous block will not match up.
How does blockchain ensure that the newly block added is the same one for all the nodes?
EDIT:
Even if everyone is connected to the network this can happen:
Blocks A and B are added at the same time. Then next round C happens on top of A, and D happens on top of B. All nodes will delete the shortest block-tip before they even hear about the other broadcast.
node 1:
chain +A  +C
chain +B  +D

node 2:
chain +B  +D
chain +A  +C

And if this keeps happening, all the nodes will maintain different versions of the blockchain which, in their view is the correct version
node 1:
chain+A+C+...

node 2:
chain+B+D+...

i think i've answered a similiar question: https://bitcoin.stackexchange.com/questions/61106/does-full-node-store-all-valid-forks-and-alternative-blocks-from-blockchain-hi. I hope this is helpful.

:) yes, this is the question I refer to in my comment below

because I cannot add a comment on the other question...
It could might as well be that different nodes end up adding a block to a different block-tip and if that's the case how can consensus ever be reached

It can be, but highly unlikely if they are connected to the network. One of the branches will get ahead and broadcast its length and branch. Then everybody will switch to this longer branch.

I edited the question otherwise it would be too big for a comment.

As per how I understand, as soon as C comes, node 2 will switch to chain+A+C, and they will be consistent again. Or if D comes first, both will switch to chain+B+D. It is extremely unlikely this can continue for more than 1 block.

but I'm saying that node 2 never hears about C, but hears about D which happens on top of B

Let us continue this discussion in chat.

All nodes will delete the shortest block-tip before they even hear about the other broadcast.

This assumption is incorrect.
For Bitcoin Core (and since all full nodes are either Bitcoin Core, modeled off of Bitcoin Core, or forked from it, this applies to basically all nodes), all blocks which have a valid Proof of Work and a few other things are written to disk and added to the block index and chainstate. At the very least the headers are recorded as headers are received before the blocks are. So if I am using Chain+A and I receive block B, I will store block B and mark it as not in my main chain but still fully valid. When block C, I will update my main chain with block C (advance the current tip to block C). When I receive block D, I store block D to disk and mark it as not in my main chain but still fully valid.
If I had received block D (or its header) without having received block B (or its block header), then I will discard it as invalid. However this is unlikely to happen because I will almost always know the best headers chain of all of my peers because I asked for it when they connected and I will receive headers from each of them for every valid block they receive.
Such a fork will resolve when one chain has more work than the other chain. This will typically happen when one becomes longer than the other. When that happens, because all nodes know of the other chain having either its block headers or the blocks themselves, all nodes following the shorter chain will automatically switch over to using the longer chain.
If the split should persist indefinitely, then this will not happen, but that is extremely unlikely given that it becomes more and more improbable for every single block on each chain to be found, broadcast, and received by all nodes simultaneously.

So the issue you describe is that half of nodes consider chain+A valid and half consider chain+B valid.
The situation gets resolved when the first subsequent block is mined, let's say it happens to be the one from the miners on the chain+A. Now we have the situation: chain+A+1 vs chain+B. At this point all the nodes switch to longer chain: chain+A+1.
EDIT: Regarding the circumstances of how switch occurs I'm not sure but an idea is the following:

When new block is mined and broadcasted, if it does not fit on recipients tip of chain, communication is held between the broadcaster and recipient to find where the branches diverged.
If recipient finds the broadcaster's branch is longer it switches to it.

In real life Internet the contention situation is highly unlikely to exist for longer than 1 block duration. Eventually it gets resolved even if divergence continues for longer.
Someone more experienced can correct me.

The chain+B nodes already invalidated A, then how would they know about A in the first place.
Also, what if the process keeps happening, chain+A+C+... and chain+B+D+...

Good question. I have the similar one posted :). Wanted to edit my answer that if this is your question I don't know the answer :D.

I updated with  my idea of how this switch could technically happen.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Bittrex websockets: How to get the order history?
Using the Bittrex websockets API I am able to get the summary updates for all markets and also the exchange updates for specific markets.
However, I am not able to receive the order history (as opposed to updates).
The market exchange updates are regularly received after invoking the hub method: "SubscribeToExchangeDeltas".
I am trying to get the order history via invoking the hub method: "QueryExchangeState".
But this does not seem to work and I don't get an error either ... ?
Does anyone have experience with this or has the same problem or knows a nifty trick, please let me know!
The code I am using is like so:
import pprint
from requests import Session  # pip install requests
from signalr import Connection  # pip install signalr-client

def handle_received(*args, **kwargs):

    print('\nreceived')
    print('\nargs:')
    pprint.pprint(args)
    print('\nkwargs:')
    pprint.pprint(kwargs)

def print_error(error):
    print('error: ', error)

def main():
    with Session() as session:
        connection = Connection("https://www.bittrex.com/signalR/", session)
        chat = connection.register_hub('corehub')
        connection.start()

        connection.received += handle_received
        connection.error += print_error

        for market in ["BTC-MEME"]:
            chat.server.invoke('SubscribeToExchangeDeltas', market)
            chat.server.invoke('QueryExchangeState', market)
            pass

        while True:
            connection.wait(1)

if __name__ == "__main__":
    main()

So ...it turns out from correspondence with a Bittrex developer that it is currently not possible to get the order history via websockets.
One has to revert to the "normal" public API for this: https://bittrex.com/home/api

How far back can you retrieve it via API?

Using /account/getorderhistory you get the latest 200. For /public/getmarkethistory I don't know, I don't use it.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
What does the nBits value represent?
When a miner hashes a blocksheader and it produces a hash that is lower than the value represented by nBits then the PoW is considered solved.
What exactly does this mean? For example a SHA256 hash has the following structure: c45bc3de9bff9ee27fc7303a3aa4fa8022ab6608d42bbea4d72bbee9b719703b how do you determine whether this is below an nBits value?

nBits refers to the target. The target is inversely proportional to the difficulty, and is encoded as a compact representation of a 256-bit number. The first byte of the 32-bit field represents an exponent and the remaining 3 bytes encode a mantissa.

Image via btcinformation.org
E.g. the first (and maximum) target was 0x1d00ffff, which is the compact representation of 0x00000000ffff0000000000000000000000000000000000000000000000000000, a 256-bit number with the leading 32 bits set to zero, followed by sixteen bits set to one, followed by the remaining bits not defined by the mantissa also being set to zero.
The block hash is usually represented as a hexadecimal number (which include the letters from A–F for the numbers 10-15), but block hashes result from SHA256d hashing and the output of SHA256 is a 256-bit number (hence the name). When miners are searching for a valid block, they create a multitude of block candidates. When one of these candidates' hash digests (interpreted as a 256-bit number) is smaller than or equal than the target, the miner has found a valid block.

You can calculate the difficulty from the target with the following formula:
difficulty = max_target / current_target

where max_target stands for the above mention initial target and corresponds to the minimum difficulty. Alternatively, the formula works out to:
difficulty = 2^208 * 65535 / current_target.


text:
Why does some transaction returned in the result of Blocktrail api call contain a field called "raw"?
Such as the result of https://api.blocktrail.com/v1/btc/transaction/57ecab25858a91448cbca713ea369c23a06f6080fca85dea367c33fad93fa056?api_key=MY_APIKEY
Also what exactly does "raw" mean here? Could it be translated to some information?

It looks like a hex encoding of the binary encoding that Bitcoin uses. You could also get this through the getrawtransaction Bitcoin RPC call, if you have txindex=1 enabled.


text:
API request of blockchain.info over Java stops spontaneously
In my java class, I extract the hash of transactions from the files of blk...dat, then obtain the data of the corresponding transactions via reading from the URL: https://blockchain.info/rawtx/+ hash. At one time, my program stopped after calling the urls for 1370 times, at the other time, my program stopped after calling the urls for 2243 times. The program is not terminated and will not proceed no matter how long I wait.
What is going on in this case?
Since the number of call exceeds the the hard limits described here: https://blockchain.info/api, I suspect that it is not a problem of I lacking an API-Key. But in the case it is the reason, how could I get an API-Key? I don't have a website (the java-application is for my bachelor thesis), and it seems that quite a few people online have issue with obtaining the API-Key from blockchain.info.
Could it because of something about the network quality I am using, if yes, is there any way to work around it with my java program?
If it is a inherent problem from the side of blockchain.info, could someone recommend me an alternative way to attain similar data of transactions?
My code:
import org.bitcoinj.core.*;
import org.bitcoinj.core.Transaction;
import org.bitcoinj.utils.*;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.*;
import org.bitcoinj.params.MainNetParams;

import org.json.*;

public class ParseFromDat {
    private static String readAll(Reader rd) throws IOException {
        StringBuilder sb = new StringBuilder();
        int cp;
        while ((cp = rd.read()) != -1) {
            sb.append((char) cp);
        }
        return sb.toString();
    }

    public static JSONObject readJsonFromUrl(String url) throws IOException, JSONException {
        InputStream is = new URL(url).openStream();
        try {
            BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));
            String jsonText = readAll(rd);
            JSONObject json = new JSONObject(jsonText);
            return json;
        } finally {
            is.close();
        }
    }

    public static void main(String[] args) throws IOException, JSONException {
        Context.getOrCreate(MainNetParams.get());

        // Arm the blockchain file loader.
        NetworkParameters np = new MainNetParams();
        List<File> blockChainFiles = new ArrayList<File>();
        blockChainFiles.add(new File("C:\\Users\\...\\AppData\\Roaming\\Bitcoin\\blocks\\blk00514.dat"));
        BlockFileLoader bfl = new BlockFileLoader(np, blockChainFiles);

        // define files to be written into
        PrintWriter transactions = new PrintWriter(new File("./csvs/transactions.csv"));
        StringBuilder traStr = new StringBuilder();
        traStr.append("tranHashString:ID(Trans)\n");
        PrintWriter sendAdd = new PrintWriter(new File("./csvs/sendAdd.csv"));
        StringBuilder sendStr = new StringBuilder();
        sendStr.append("addr:ID(SendAdd),value,tranHashString,addr_tag_link,addr_tag\n");
        PrintWriter receiveAdd = new PrintWriter(new File("./csvs/receiveAdd.csv"));
        StringBuilder receiStr = new StringBuilder();
        receiStr.append("addr:ID(ReceAdd),value,tranHashString,addr_tag_link,addr_tag\n");

        PrintWriter inTran = new PrintWriter(new File("./csvs/intran.csv"));
        StringBuilder inStr = new StringBuilder();
        inStr.append(":START_ID(SendAdd),:END_ID(Trans)\n");
        PrintWriter outTran = new PrintWriter(new File("./csvs/outtran.csv"));
        StringBuilder outStr = new StringBuilder();
        outStr.append(":START_ID(Trans),:END_ID(ReceAdd)\n");

        // Iterate over the blocks in the dataset.
        int counter = 0;
        for (Block block : bfl) {
            System.out.println("aaaa");
            List<Transaction> trans = block.getTransactions();
            for (Transaction ta : trans) {
                System.out.println("bbbb");
                traStr.append(ta.getHashAsString());
                traStr.append("\n");
                System.out.println("bbbb1 " + (counter++));
                System.out.println(ta.getHashAsString());
                JSONObject json = readJsonFromUrl("https://blockchain.info/rawtx/" + ta.getHashAsString());
                JSONArray inputs = json.getJSONArray("inputs");
                for (int i = 0; i < inputs.length(); i++) {
                    if (inputs.getJSONObject(i).has("prev_out")) { // it is possible that the value is null even when prev_out is not null
                        System.out.println("ccc");
                        JSONObject prevOut = (JSONObject) (inputs.getJSONObject(i).get("prev_out"));
                        inStr.append(prevOut.get("addr").toString());
                        inStr.append(',');
                        inStr.append(ta.getHashAsString());
                        inStr.append("\n");

                        sendStr.append(prevOut.get("addr").toString());
                        sendStr.append(',');
                        sendStr.append(prevOut.get("value").toString());
                        sendStr.append(',');
                        sendStr.append(ta.getHashAsString());

                        if (prevOut.has("addr_tag_link") || prevOut.has("addr_tag")) {
                            if (prevOut.has("addr_tag_link") && prevOut.has("addr_tag")) {
                                sendStr.append(prevOut.get("addr_tag_link").toString());
                                sendStr.append(',');
                                sendStr.append(prevOut.get("addr_tag").toString());
                            } else if (prevOut.has("addr_tag_link")) {
                                sendStr.append(prevOut.get("addr_tag_link").toString());
                                sendStr.append(',');
                                sendStr.append("null");
                            } else {
                                sendStr.append("null");
                                sendStr.append(',');
                                sendStr.append(prevOut.get("addr_tag").toString());
                            }
                        }
                        sendStr.append("\n");
                    }else{
                        continue;
                    }
                }
                JSONArray out = json.getJSONArray("out");
                for (int i = 0; i < out.length(); i++) {
                    JSONObject outItem = out.getJSONObject(i);
                    if (outItem.has("addr")) { // it is possible that the add and value is null?
                        outStr.append(ta.getHashAsString());
                        outStr.append(',');
                        outStr.append(outItem.get("addr").toString());
                        outStr.append("\n");

                        receiStr.append(outItem.get("addr").toString());
                        receiStr.append(',');
                        receiStr.append(outItem.get("value").toString());
                        receiStr.append(',');
                        receiStr.append(ta.getHashAsString());

                        if (outItem.has("addr_tag_link") || outItem.has("addr_tag")) {
                            if (outItem.has("addr_tag_link") && outItem.has("addr_tag")) {
                                receiStr.append(outItem.get("addr_tag_link").toString());
                                receiStr.append(',');
                                receiStr.append(outItem.get("addr_tag").toString());
                            } else if (outItem.has("addr_tag_link")) {
                                receiStr.append(outItem.get("addr_tag_link").toString());
                                receiStr.append(',');
                                receiStr.append("null");
                            } else {
                                receiStr.append("null");
                                receiStr.append(',');
                                receiStr.append(outItem.get("addr_tag").toString());
                            }
                        }
                        receiStr.append("\n");
                    }else{
                        continue;
                    }

                }

            }

        }
        transactions.write(traStr.toString());
        transactions.close();
        sendAdd.write(sendStr.toString());
        sendAdd.close();
        receiveAdd.write(receiStr.toString());
        receiveAdd.close();
        inTran.write(inStr.toString());
        inTran.close();
        outTran.write(outStr.toString());
        outTran.close();
    }
}


text:
Is there an API with which I could obtain the exchange rate of bitcoin to dollar some time in the past by giving the desired time as parameter?
I would also like the the result to be precise to hour (or minute).
It is for a java program.
I have looked around, but the service I have found could not satisfy my need:
http://www.coindesk.com/api/: only precise to date
https://api.coinbase.com/v1/prices/historical?page=1 (from https://community.coinbase.com/t/past-bitcoin-exchange-rates/1725): need to adjust page number to find the desired time (at which one wants the value of exchange rate)
http://api.bitcoincharts.com/v1/csv/: I am not exactly sure what it does, but it seems that one needs to download different files from this site containing "USD" in the file names, check in all the files before finding the desired time

You can use winkdex.com api, it accepts a unix timestamp as a parameter.
http://docs.winkdex.com/#price

It says that price is "The value of the WinkDex at the requested time in 0.01 USD". What is the value of WinkDex and what does it have anything to do with Bitcoin?

WinkDex is a bitcoin price index. It takes the information from several of the largest bitcoin exchanges and consolidates it into an average price.

The timestamp has an entry like: 2017-03-15T08:05:00Z. Am I correct that Z represent that the time is in UTC? What does the "T" in the middle mean?

@Aqqqq it's the ISO 8601 format. The T seems to act as a delimiter to separate the date and time. There's a whole wikipedia page dedicated to this time format: https://en.wikipedia.org/wiki/ISO_8601 . Z does indicated UTC time.

In addition to the answers already given, the CoinMarketCap API endpoint allows you to fetch a whole set of data points at once for a given time range.


text:
Why does some transactions have an excessive number of receiving addresses?
Such as this transaction: 92088fe6b9d9c9db84d26481b80104f8ca566649a656b7aa3e67432b346cbf1c, which has over 5000 receiving addresses.
It is unlikely that someone would send money to that many business partners at once, let along each individual output is quite small. If that is done for privacy protection purpose, over 5000 receiving addresses is too excessive.

It is unlikely that someone would send money to that many business
  partners at once

Why? It's a mass payment for "shareholders". In this instance, the transaction you mentioned is a known payment from a pool to their miners.

With many of the payments under than one dollar?

Why not? The transaction you mentioned is known as a payment to miners from a pool https://bitcointalk.org/index.php?topic=1338693.msg13656238#msg13656238

Thank you. Are you aware of any way to find out which transaction is a payment to miners from a pool?

I've edited your post to add the comment's content to the answer, as the comment addressed the question more directly than the actual answer.

When I asked for specifically the transaction I mentioned, the field enough_fee is false. Is the fact that it is a mass payment from pool which allows the transaction to be confirmed despite the fact that there is no enough fees?

there is no "enough_fee" field in bitcoin transactions.

Miners select arbitrarily which transactions to confirm. If it was their own payout transaction, there is absolutely nothing stopping them from selecting their own transaction without paying a fee to themselves.

@amaclin Sorry for the late reply. The field is in the json returned by blocktrail.


text:
Is the current Bitcoin implementation easy for different users to participate in a single transaction?
I read a paper from 2013 (Androulaki E., Karame G.O., Roeschlin M., Scherer T., Capkun S. (2013) Evaluating User Privacy in Bitcoin. In: Sadeghi AR. (eds) Financial Cryptography and Data Security. FC 2013. Lecture Notes in Computer Science, vol 7859. Springer, Berlin, Heidelberg) that, regarding transaction input, "currently, Bitcoin clients do not provide support for different users to participate in a single transaction; to achieve this, users would have to modify the Bitcoin client implementation themselves".
What about now?
Also am I correct that most of the transaction nowadays have still only one user as input?
Sources (to ex. papers) would be nice.

The referenced paper is from 2013. It may have been true that at this time it was difficult, to share a spending activity amongst users. This link here https://gist.github.com/gavinandresen/3966071 explains the details around multisig, and comes in early 2013. As of today, you got it correctly, we have multisig in two variants, and the statement doesn't hold true anymore.
On the aksed sources: there was a paper from 2014 (http://www.quantabytes.com/articles/a-survey-of-bitcoin-transaction-types), that evaluated the distribution of transactions type, but that is the last I know of... and I haven't seen any updates since then.


text:
Accidentally sent Bitcoin Cash to Bitcoin address held by a third party
I made an exchange on Changelly to exchange my Bitcoins to Bitcoin Cash. These Bitcoin Cash would later be sent to my address. Unfortunately, I did not check twice and had the Bitcoin Cash sent to my Bitcoin address and not Bitcoin Cash address.
Is there a way for me to reclaim these Bitcoin Cash? They are on a Bitcoin Cash address, just not mine. I checked the address and it only holds my Bitcoin Cash, which means it probably does not exist as an address. Is there a way for me to custom create the address and claim them or how do I get them back?
This is the process of how it went

As BTC in Blockchain.info
Transferred to Bitcoin Cash via Changelly
Transferring done, Bitcoin Cash supposed to be sent to my Bitcoin Cash address, to my Bitcoin.com Wallet but after accidentally having written my Bitcoin address and NOT my Bitcoin Cash address, the Bitcoin Cash is now with that address. I can see the cash at the other address but don't know how to get it back.

Help would be much appreciated. Thanks!

If BCH was sent to an address belonging to your bitcoin.com wallet, then I believe you have the private keys on your device and should be safe.  Even better, the latest version of the bitcoin.com wallet supports BCH, so your BCH should be visible and available there.

I just had a similar problem with the difference that both wallets belong to me. I got help from http://BitcoinMedic.com and got my funds back. I have read you also got it back, good!

It feels bad to lose them in the first place but it feels very nice to retrieve them back.

You'll have to negotiate with your service provider whether they can help you.
Whoever holds the private keys for your Bitcoin wallet should be theoretically able to generate a transaction that sends the BCH from the Bitcoin address to wherever you wanted them to go.
In practice this may be difficult or infeasible: To keep large quantities of Bitcoin secure, the private keys are often stored in hardware devices or otherwise hard to access. The service provider will likely at least need to manually intervene to help you.
If the Bitcoin address was SegWit (which I wouldn't expect in this case), it might be even more difficult to recover, as you'd need the help of a miner, additionally.
It is unfortunate, that the Bitcoin Cash developers used the same address format as Bitcoin, even after this problem was well-known and in the media recently with Litecoin switching to a new unique P2SH address format for this very reason. However, I've read that they are working on a new unique address format, so at least this should stop happening in the future.

Who is my service provider in this case? Changelly, Bitcoin.com Wallet or some other third party?

@AhmadOthman: If I understand correctly, the Bitcoin address that you accidentally sent the BCH to was from your Bitcoin.com wallet. That means that Bitcoin.com has the corresponding private key.

I sent Bitcoin Cash to my Bitcoin address on Bitcoin.com wallet. Hope that was your question. Thanks, really appreciate your help.

@AhmadOthman: Then Bitcoin.com would be who can help you recover it.

Alright, I will write to them about it shortly, thanks!

@AhmadOthman Is it one of these wallets? What platform? Seems to be a fork of Copay which should allow exporting a private key.

If BCH was sent to a bitcoin.com-wallet, then one is in control of the private keys, and rescuing the funds should be as easy as upgrading the wallet (since it supports BCH by now).

I was able to get them back, fortunately. Thanks for all the help!

Nope,impossible to get back,  effectively you sent them to another bitcoin cash address that less likely might be for  anyone or used..your coins are lost into the void on that address and you cannot have the keys to it, nor anybody can get them back
You can though see them on the BCH blockchain stuck there
Sorry to deliver the bad news

That's not true, the keys to the address are the same for both chains if it's a 'normal' bitcoin address so it should be recoverable

Ahh,apologies, correct the keys are same, misread question

I was able to get them back, fortunately. Thanks for all the help!

@Ahmed, could you please let me know how you got the coins back? Did bitcoin.com give you the private keys or did they reverse the transaction themselves? I'm in a similar situation having sent LTC to a BTC wallet held at CEX.io. Their support is terrible though, so I'm having no luck so far getting the coins back.

@AhmadOthman for Runny Yolk and others that read this it would be helpful if you could explain what you did to resolve your problem.

I apologize for the late answer
Bitcoin.com responded to me by sending a long email explaining some details concerning BTC and BCC. The email is too long to copy-paste and it is more directed towards users that use bitcoin.com I would say, but you might be able to find something helpful.
You can do the following to retrieve your BCC from your BTC wallet:
Go to Home > New wallet (press the '+' icon) > New personal wallet. Select the Bitcoin Cash option, as you want to recover your BCC. Enter a name for the wallet (I would suggest BCC recovery) > Show advanced options > Wallet key

Copy from wallet... > Select Wallet To > [Your Bitcoin [BTC] Wallet]
Create new wallet
This will create a Bitcoin Cash (BCC) wallet from your Bitcoin (BTC) wallet seed.
Once it has been created, go to Settings > [BCC recovery wallet] > More Options > Wallet Addresses > Tap 'Unused Addresses' at least 20 times / until you get an "Empty addresses limit reached" message
Tap 'Scan addresses for funds'
Your BCC will now appear in your BCC recovery wallet.
(If this did not help, which is likely) If you have an email I can resend the full response. Just write to me at Ahmadmso1995@gmail.com


text:
How to find what is suitable transaction fee to send 10 mBTC?
Using MultiBit Desktop Wallet, I can see that the default transaction fee is set to 0.5 mBTC per KB.
Usually that default rate worked fine. But yesterday, when I tried that and my transaction has not been confirmed for over 12 hours now.
So today I increased the fee to 1mBTC per KB and tried to send another 10mBTC to the same destination wallet. It is half an hour now and it has not confirmed either.
It is really frustrating. I'm wondering what is wrong here, and how can I choose a fee that make near instant transaction possible.

Bitcoin Fees is a useful site to see the current network status and pending transaction fees. According to that site as of now, a transaction fee of 4.11 - 4.20 mBTC/KB is required to clear within 1-12 blocks (i.e. within around 2 hours), 4.61+ to clear as soon as possible.

Another site that provides good information about bitcoin fees is mempool.space. I believe it's an open source project too.


text:
send bitcoin to mobile number or email address
How I can send bitcoins to someone's phone number or email address. I explored this api but they have documentation only for sending bitcoins to an address directly. But here they have explained how to send directly to a mobile number or email address. I want to implement this idea in php, please let me know how I can do it or where I can find some relevant information.

First of all: You do not really send the bitcoins to an email-adress or a phone number. You can only transfer them from one bitcoin adress to another one.
My understanding: The internetsite / (software behind it) creates a keypair (private and public key) and generates a bitcoin adress. Then, the site tells the user to send x Btc to that adress and provides you a textfield to enter an email-adress of your fried for example. And after that, the site sends an email to the email adress like "Hey, someone sent you bitcoins. Visit our site http://...
And finally, you need to provide the 2nd person the opportunity to import the keypair into his wallet or you ask him for a passwort that the first person gave the second person and let him/her enter a new bitcoin adress where he/she than send the bitcoins to. And you should use https for such a project.


text:
How to exchange bitcoins held in electrum to ethereum?
How to exchange Bitcoins to Ethereum through shapeshift.io or changelly.com, from Electrum bitcoin wallet to Jaxx ETH wallet?
In electrum wallet do I need to subtract the Bitcoin mining fee manually, or I can send all my bitcoins in the wallet to shapeshift/exchangelly?

In electrum wallet do I need to subtract the Bitcoin mining fee manually, or I can send all my bitcoins in the wallet to shapeshift/exchangelly?

You just send Bitcoin with sufficient fee in a same way that you send Bitcoin to a standard address.
Here is the quick way to exchange BTC for ETH at Shapeshift.io
1. Paste your Bitcoin and Ethereum addresses in the filed below

Send some Bitcoins that you want to exchange to the address where shapeshift gives. It depends on how fast you want to get the transaction done. If you want to get it done in 10 mins, you probably have to pay approximately 500 satoshis/byte for the mining fee.


text:
Restore Wallet From Jaxx to Coinomi: ETH missing (but BTC and LTC are fine)
I have some BTC, ETH and LTC in a wallet created with Jaxx, but I want to use Coinomi instead. I downloaded Coinomi and chose Restore Wallet and entered my 12 words. My BTC and my LTC popped right up, but the ETH is nowhere to be seen (even after several hours).
I've tried adding some additional ETH wallets as suggested in this thread: https://www.reddit.com/r/COINOMI/comments/7b8wxb/help_lost_ltc_when_restoring_my_old_wallet/
I can still access all currencies in my Jaxx wallet, so I could just transfer the ETH to my wallet in Coinomi, but I'd quite like to keep my transaction history.
Should my ETH be showing in Coinomi? Or am I wrong in my assumption that I can use my 12 words to restore in another wallet?

Jaxx uses a different derivation path than Coinomi when handling ETH. Coinomi opted for the path as described in the ETH specification. Ledger has the same scheme as Coinomi.
Jaxx: M/44H/60H/0H/0
Coinomi: M/44H/60H/0H
You will have to do the following:

Delete any existing ETH wallets you have added by long pressing them (2 sec) in the Overview tab and clicking on the trash icon that appears.
Add another ETH wallet, but before clicking ADD, click on the gears icon next to the coin name in the coin list and then click on "ADVANCED SETTINGS" link on that popup, and enter this entire text in: M/44H/60H/0H/0 Then click add.

You should now see your ETH balance in Coinomi.

The derivation path that worked for me when importing an ETH Jaxx wallet to Coinomi was M/44H/60H/0H/0 instead of M/44/60H/0H/0.


text:
Chain Code from Ledger Nano S
The question is basically in the title. Can I (or it is possible to) extract the chain code from a ledger nano s device? It doesn't have to be the Master Chain Code. Any of them will do.

Yes. You can get the public key, chaincode, and address for any derivation path.
If you use the btchip-python library, you can use the getWalletPublicKey() method to retrieve a dictionary containing all three of those things.

Hey, thanks for the response. How to I get python to interact with the ledger device?

You need to use getDongle from https://github.com/LedgerHQ/btchip-python/blob/master/btchip/btchipComm.py to get the device object to do the calls with. Alternatively you can use the HWI project (https://github.com/bitcoin-core/HWI) to get an xpub from your Ledger and extract the chaincode from that. HWI is a python library and command line tool to do stuff with hardware wallets.

Extracting BIP 32/39/44 chain code is agnostic as to whether a Ledger device or Trezor device is used. Remember the chain code is based upon open standards, specifally see https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format.
Here is how chain code can be found for the Bitcoin path m/44'/0'/0'/0 for the example at https://github.com/libbitcoin/libbitcoin-system/wiki/Altcoin-Version-Mappings#7-bitcoin-btc-bip-3944-technology-examples:
This is the level the chain code was determined for below:
% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 9-10
04
This is the index the chain code was determined for below:
% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 19-26
00000000
This is the chain code for the particular level and index:
% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 27-90
6fbe96de86322b27a540572e2777562f55fb9810327917f9dd1163592952272a
This is the associated secp256k1 private key:
% echo "radar blur cabbage chef fix engine embark joy scheme fiction master release" | bx mnemonic-to-seed | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 0 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx base58-decode | cut -c 93-156
c227b3ba34eecfee2830b06bef3b35d5a88d4f6a9c5f34bd3d4e465e6c3ead1f


text:
What is the difference between Trading Volume and Transaction Volume?
Looking at the Bitcoin Statistics summery from Blockchain.info
there are Trading Volume and Transaction Volume listed.
I understand that transaction volume represents the amount of bitcoin used for transactions, eg. user sends bitcoins over to another user.
What about trade though? How is the value for trading value determined?

Trading, in this context, refers to the exchange of Bitcoins for fiat currency (dollars, euros, etc).
Major exchanges report on the number and total value of trades made on their platform.  Presumably the numbers on blockchain.info come from aggregating that data.


text:
Security implications of bitcoin.conf location
I'm setting up and hardening a dedicated headless bitcoind and lightning daemon and wanted to have a discussion about location of the bitcoin.conf.
Item #1:
Bitcoind defaults to using ~/.bitcoin/bitcoin.conf, presumably because keeping all relevant files in one location makes it easier to copy and/or share the blockchain between different machines. Are there security implications to this? Is it substantively safer to store bitcoin.conf in /etc instead (such as /etc/bitcoind/bitcoin.conf)?
One argument against using ~/home/.bitcoin/bitcoin.conf I thought of is the RPC Password is be stored in the .conf file and could be viewed by anyone with read access. So it is less readable in ~/home or in /etc?
I'd get +1 POSIX-style-points for using /etc...
One argument against using /etc/bitcoind/bitcoin.conf is portability. It is less convenient to have the .conf file in a separate location. Less convenient means greater chance of mistake or error sometime down the road.
Item #2
Similar to #1, besides +1 style points, is there any advantage to moving logs to /var/log? My understanding is bitcoind already rotates logs, but is there an advantage to how systemd does log rotation in /var/log?

Thanks, these are good points. You're right about bitcoin.conf being in /etc and it causing difficulty accessing the daemon on a day-to-day basis. In my case this server is meant to serve a small local workgroup on the same machine and on the LAN and has bitcoind running without a wallet to serve a local lnd and electrumx instance. Both of these access bitcoind through RPC via localhost, so the location of bitcoin.conf is irrelevant to them.
Even if bitcoind was run as a system-level service to be used as a wallet, users wouldn't necessarily need to access bitcoin.conf if they used RPC. Local users could each have their own bitcoin.conf in their home folders with RPC credentials. This would eliminate their need to specify bitcoin.conf at the command line.

You may then secure the file with "chmod 600", so only the owner can read/write >the bitcoind.conf file (and root and/or the admins after tweaking the >permissions).

^^This would do more for security than just moving to /etc.
So there is no one right answer, but that if running bitcoind as a system-level service it might make more sense (if not actually increase security) and get +1 POSIX style points to put bitcoin.conf in /etc, but if running bitcoind in the user space for a single local user it makes more sense just to keep everything in ~/home to save RPC credentialing hassles.

You "wanted to have a discussion" -- remember this is not a discussion forum. According the the [help/dont-ask] we should avoid open-ended chatty questions for the reasons given there. Your Item #2 is mostly off-topic here and would best be answered by reading existing answers in (for example) our sister-site https://serverfault.com

OK, so I changed my mind. I don't want to 'have a discussion' I simply want an answer to the following question:
Is it "best" to keep bitcoin.conf in /etc/ or in ~/home/.bitcoin?

I do not see the "necessary" relevance to bitcoin here. File access security is better discussed in unix relevant stackexchange. Still I'd like to share my view with the little bit of bitcoind relevance.

One argument against using ~/home/.bitcoin/bitcoin.conf I thought of
  is the RPC Password is be stored in the .conf file and could be viewed
  by anyone with read access.

depends how you setup your bitcoin system. If bitcoind is setup as a user related process, it makes absolutely sense to have bitcoind.conf in home directory. You may then secure the file with "chmod 600", so only the owner can read/write the bitcoind.conf file (and root and/or the admins after tweaking the permissions).
When storing in /etc, the "chmod 660" makes more sense, then owner and group can read/write the file. In this case I'd be having bitcoind running as a systemwide daemon. But to be honest, I haven't seen such a setup discussed anywhere. This would be ok for a static setup (using shell scripts to startup), but imagine you use it every day for tx generation or status checks. Every call to the bitcoind executable would require the correct path to the config file, and if not, bitcoind creates one (in your home dir), and then it might give RPC access problems...

Item #2 Similar to #1, besides +1 style points, is there any advantage
  to moving logs to /var/log?

This again depends on the distribution used. My OpenBSD uses syslog (to /var/log), whereas the OpenSuSE systems have introduced last recently the journal system, where all logging is in a database. I must admit, I am more comfortable with /var/log, but when my beloved OpenBSD would also go away from /var/log, then what to do with bitcoin system logs?
So generally I'd say, /var/log should remain for the unix system related logging, and each application (I consider bitcoind as an application) should have it's own log (and related directory). This makes separation of duties on a larger unixoide system more easy, and the sysadmins wouldn't find irrelevant data in their well known /var/log directory.


text:
bfgminer on bitcoin-qt
I am getting this error and looking for guidance.
Error : Most likely you have input the wrong URL, forgotten to add a port, or have not set up workers
config
 server=1
 rpcallowip=192.168.1.0/24
 rpcallowip=192.168.2.0/24
 rpcallowip=127.0.0.1
 rpcport=9050
 rpcuser=someuser
 rpcpassword=somepass

command
bfgminer.exe -o 192.168.2.242:9050 -u someuser -p somepass
bfgminer.exe -o 127.0.0.1:9050 -u someuser -p somepass

In this example, the username in bitcoin.conf is somepass but on the bfgminer command line it is someuser.  Perhaps you should double check whether they match in your actual setup.

don't mind it I misedit them while posting here.

I have a stupid question. Is bitcoind actually running?

I am not sure what is bitcoind but bitcoin-qt running and synced. (like 25 GB)


text:
What is "Key Splitting"? When would I use it?
Here is some github code to create split keys.

Is Key Splitting the same as Multi Sig?
What are the benefits of Key Splitting, what's it used for?
How does it relate to P2SH or any other relevant BIP?
How are split keys used in a transaction?

No. Multisignature transactions involve multiple keys/signatures, whereas this involves splitting up one key.
As far as I know, it's not used at all in production. There are a whole host of issues.
P2SH was created to make multisignature transactions easier to implement for e-wallet providers and merchants, and to move the burden of multisignature transactions from the sender to the reciever.
Like so:

Generate a key
Split the key up, store the pieces in different places
Put the key back together
Sign transactions

The major problem with split-key transactions is that you need a trusted third party. When they generate the key, they could secretly store it. When they put the key back together, they could secretly sign a transaction that stole all of your bitcoins.


text:
Does it make sense to "collect" smaller transactions balances into a single account during low activity?
My understanding is that it's possible for extra bitcoins to be left in several accounts within my wallet.  The scattering of these coins into different accounts may cause future transactions to become larger in size (Kb), and therefore more costly in fees.
Does it make sense to prematurely consolidate these small accounts into a single "spend account" at some point? (perhaps while I sleep?)

The fact that they're in different accounts doesn't matter. What matters is that they are distinct transaction outputs. What you would do is consolidate these small outputs into a single larger output.

@DavidSchwartz What I'm getting at is what if I have 1000 customers who paid me to 1000 addresses.  I have 0.002 BTC in each account.  If I spend 2.0 BTC on something won't my transaction be huge? .. and I'll have to pay a large fee?

You'd have the same problem if they all paid you to the same address. You'd still have 1,000 transaction outputs to "gather" if you tried to spend 2 BTC, so your transaction would still be huge.

@DavidSchwartz Could I divide that into smaller "free" batches so that when the time comes I won't have to pay a fee?

Theoretically yes, but practically, there's probably no point. For one thing, it would mean your final transaction would be using newer coins, which counts against it.

@DavidSchwartz You hit the nail on the head (of my recent questions).  If these small transactions were collected, during low expected utilization (low spend hours), then I avoid the fee after I wait N hours.  It's like a logical defragmentation of my wallet balance. no?

possible duplicate of In order to reduce fees, can I 'consolidate' my wallet by sending the entire balance to a new address in the same wallet?

This question doesn't ask how, so I've asked that question here: http://bitcoin.stackexchange.com/questions/5583/how-can-i-combine-all-the-tiny-amounts-ive-received-while-minimising-transactio

@HighlyIrregular I'll give you rep for that one (Though that is the question I was going to ask next in sequence and link to them all) ;)

It's something that's been needing attention for a long time... thanks for raising it again! I suspect it won't be a simple answer though.

In satoshi client, the "accounts" therein are only a convenience for labeling of receiving addresses. They don't matter for sending at all.
If you receive bitcoins, the balance is not added as in bank, but the amount is saved as "unspent output". Client only shows all these outputs together as one available balance. It doesn't matter whether one address has n unspent outputs, or these are on more addresses. When you send bitcoin, the fee is based on number of these outputs used and it is higher if they are very recent. So trying to consolidate them won't help much, only that you pay the fee sooner. And it isn't done "while you sleep", it's done by simply sending your whole balance minus fees to yourself.
In other clients, the fee algorithm can be completely different.


text:
What was the intended benefit of truncating the Target?
I'm thinking about how the Target value is truncated to and later compared to the SHA-256hash of the Block Header.
Given that
The maximum target (lowest possible difficulty) is
0x00000000FFFF0000000000000000000000000000000000000000000000000000
and the current target is
0x00000000000004985C0000000000000000000000000000000000000000000000
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (4bits * 32 = 128)
                                  This part is always zero due to truncation

Question:

Is it simply there to make coding and evaluation easier?
Does this make the mining operation faster (more efficient comparisons)?
Are the efficiencies of the previous bullet endian-specific?
Are there statistical benefits or drawbacks to making it non-zero? (fractionally easier to find a block?)

I haven't seen a thoughtful explanation of why the decision was made, and I don't want to infer anything on my own.

I suspect that the target is truncated so it will not consume too much space in the blockchain.
The blockchain stores a compact form of the target in a "bits" field that is 4 bytes wide.  This is (significantly) less than 32 bytes (256 bits) representing a SHA256 hash.
For context:

The space savings is exactly 28 bytes per block.
As of 2/28/13, a block count of 223693, that's 6,263,404 bytes or roughly 6MB that was saved with this optimization.  This data optimization applies to data-on-disk, and what is sent to miners from pool operators


text:
What are "discouraged blocks" in the blockchain? (examples and explanation please)
As of the time I write this, only one block type is marked as "discouraged", and I'd like to understand why this exists.

Is a correct reading that is that "it should be in the blockchain?
Is this simply the block number embedded in the transaction?
Are there any sample blocks that do or don't have this information?

The link states this: At the moment, the only "new rule" for which disobedience is being discouraged is the "put the block height in the coinbase" rule.
The way I read it, there is a rule "put the block height in the coinbase" and disobedience is discouraged. That would mean the opposite of what you state in the question title, which would mean that the block height is encouraged to be in the coin base. Disclaimer: I know little about this topic, but that's how I read it...

@HighlyIrregular I edited the question, I see that your interpretation may be spot on.  Now that my thinking isn't inverted, it makes sense, though I wonder how / why unnumbered blocks would ever work.  Was it a v0.01 bug?

See also http://bitcoin.stackexchange.com/questions/2952/who-obeys-discouraged-blocks

The wiki article you describe has been updated since by a skilled developer who is part of the Bitcoin team and the key change now reads:

Bitcoin does not currently implement block discouraging in any form.

So this appears to be a concept that has not been implemented by any clients.


text:
Verifying transation inputs
I have a question about practical implementation of one part of Bitcoin protocol.
I'm reading the Protocol Rules for Bitcoin - "tx" messages and point 14 states that "For each input, if the referenced output has already been spent by a transaction in the main branch, reject this transaction".
How does the client validate that output has not been spent? It seems that it should remember all transations and amount of Bitcoins for all known addresses. This would take a lot of memory to store them all. Is there an optimization I'm not aware of?

Actually, that is exactly what happens, and it is the reason why synchronizing the block chain is so slow: we download all blocks, with all transaction history in it, and build and maintain an index that states which transaction output was spent or not, and even where it was spent.
As of 0.8, the reference client will switch to a new model where no such index is maintained anymore. Instead, it will maintain a copy of the set of transactions, but only with their not-yet-spent outputs, which is much smaller than the full data (around 150 MiB as of writing, december 10, 2012).

Thank you for detailed answer. Is there a commit or a file in https://github.com/bitcoin/bitcoin that shows current and/or new transation behavior?


text:
Stuck in "verifying database integrity"
I restarted my computer and now bitcoin doesnt go further than "verifying database integrity" and staying in until now (about an hour now) also windows tells me that the program isnt responding.
Anyone knows what to do ?

StackExchange Q&A isn't a very good place for providing tech support.  The BitcoinTalk forum has a Technical Support board that works well in getting this types of problems resolved.

Your debug.log will likely give more info about what the problem is.


text:
Check block reward
So this is an exercise for fun as we know the block reward already.
But how would you get the bitcoind to show the block reward for the next block?
There is no bitcoind getblockreward but is there a way to discover the block reward from the commands available in bitcoind.

With getblockcount you can get the height of the latest block. Then the reward of the next block is 50 / 2 ^ Floor ((blockcount+1)/210000). In some programming environments 5000000000>>((blockcount+1)/210000) will give the desired result in satoshis.

This works as we know the total coins. But going outside the scope of Bitcoin, what if we didn't know the total coins like Freicoin and the reward decreases over time.

@Bushstar: I don't know how to answer the general question. (I'm not sure if this information is explicitly available in the coinbase tx data, and even if so, the gettransaction call seems to work only for txs in the wallet). I'm not even sure if it's meaningful - an alt might have a completely different notion of block reward or a different API, so you can't devise a coin-agnostic procedure. And if it's just Bitcoin, the above applies.


text:
First altcoin with integrated Tor
I'm trying to rebuild the commit history of a coin and it starts with a single dump with a port from another alt. It comes from NovaCoin but has Tor added.
Does anyone know what the first coin with integrated Tor was?
I'm hoping to be able to fork Novacoin and apply the changes made before adding the altcoin I'm on as the difference between it and Novacoin are massive, there's a big chunk of missing history. I've actually traced six coin iterations the code has gone through but there is a missing link!

What does 'integrated Tor' mean? Bitcoin Core has supported proxying through Tor and running as a hidden service since 2012...

A lot of cryptos use anonymous networks. Look up monero, dash, torcoin and more. They're a ton of anonymous coins out there.

I think Torcoin was the first Altcoin with Tor support. But I can't find an evidence right now.


text:
Scalable implementation of Bitcoin
What reference implementations of Bitcoin are most suitable for backing a front end service on to with a high user load?
Something that can be put onto our own AWS or Google Cloud hardware and support being scaled up to support high demand. The front end site will allow people to have their own wallet to pay others for work or product discounts or receive funds for those same things.
One options seems to be Bitcore which has come along way since I last used it. It is Node.JS which can be put on AWS Elastic Beanstalk and it uses MongoDB which can also be scaled on AWS. Are there others and please let me know if I'm wrong about Bitcore before I get too entrenched.

Here is an interesting article that discusses the issues involved:  https://www.washingtonpost.com/news/the-switch/wp/2013/11/12/bitcoin-needs-to-scale-by-a-factor-of-1000-to-compete-with-visa-heres-how-to-do-it/


text:
How to tell how many hashes/sec the bitcoin core app on osx is running?
I'm curious how many hashes per sec my cpu is able to perform, is there some way to check this?
This is a follow-up to this question.

Most CPUs will do a few megahash per second, which is completely worthless for anything other than testing and has been for several years now. It may be possible to improve performance in the future as Skylake Intel x86 processors include specific instructions for SHA256, but only by a few percent. Even with improvements it is a waste of time and power attempting to use anything but the most efficient dedicated hardware. A large portion of ASIC miners are effectively obsolete due to their power requirements outstripping their output, and they are orders of magnitude more efficient than mining on a CPU.

This is not technically true. You can still enable the internal miners using the -gen option, and using the setgenerate RPC. It is non-optimized and slow though, even for a CPU miner.

@PieterWuille My mistake, I conflated the removal of getWork with removal of the miner entirely. Running bitcoin-cli setgenerate true does seem crash bitcoind though, wish I hadn't learned that in production.

Please report that as a bug. As long as the feature exists, it should work.

Yes Erik, the mining feature is still built-in and you can check how many hashes your CPU can perform. Although it's pointless and you cannot earn anything, it is still a fun experiment that people like to try. If you have a bitcoin core installed and synced with the network, you can just simply open the command console and type in and enter:
setgenerate true
This will initiate your CPU and will start mining.
You can then get your hashrate by typing in
getmininginfo
Your hashrate will be shown in integer format and you should see a number like 1-3 million hashes per second.
To turn off the mining, because you will just be wasting energy type in
setgenerate false

so I'm using osx and those commands are not available by default.

I guess this should be the accepted answer then!

This answer is really old and outdated. setgenerate was removed in version 0.13 because mining with bitcoin core on mainnet is useless and has been for a number of years. https://bitcoin.stackexchange.com/a/70696/26873


text:
Import testnet address in bcoin
I´m trying to import a watch-only address to my bcoin node using cli (testnet). My config looks as follows:
[....]
#
# Options
#

network: testnet

#
# Node
#

prefix: ~/.bcoin-testnet
db: leveldb
max-files: 64
cache-size: 100
[...]

entering the following command (just a random valid testnet address):
 bcoin wallet watch my7q4nhpuJ6TsevXdDnPRq1rvHcPKeGEaD

results with the following error in the debug.log:
[E:2017-08-03T08:43:02Z] (node) Network mismatch for address.
AssertionError [ERR_ASSERTION]: Network mismatch for address.
at Wallet.importAddress [as _importAddress] ([...]/.nvm/versions/node/v8.2.1/lib/node_modules/bcoin/lib/wallet/wallet.js:1310:3)
at Wallet.importAddress ([...]/.nvm/versions/node/v8.2.1/lib/node_modules/bcoin/lib/wallet/wallet.js:1284:23)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[E:2017-08-03T08:43:02Z] (node) This socket is closed
Error: This socket is closed
at Socket._writeGeneric (net.js:721:18)
at Socket._write (net.js:781:8)
at doWrite (_stream_writable.js:371:12)
at clearBuffer (_stream_writable.js:497:7)
at Socket.Writable.uncork (_stream_writable.js:297:7)
at connectionCorkNT (_http_outgoing.js:695:8)
at _combinedTickCallback (internal/process/next_tick.js:135:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

The error occurs, no matter what address I try to import. Does anyone have an idea on how to solve this?

You can use the http api to perform an import. Notably, you import a wallet with the create wallet command as the import command imports addresses into a wallet.

curl -X PUT \
  http://127.0.0.1:18332/wallet/$ID \
  -H 'authorization: Basic eDppYW1zYXRvc2hp' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
    "masterKey":$MASTERKEY
}'

Link to docs


text:
How much data does it take to prove a given transaction exists on the blockchain?
As I understand the SVP protocol, a client can be reasonably certain that a transaction has been accepted on the blockchain if they know it is a member of a certain block, via the Merkle path, and a reasonable number of blocks have been mined on top of that block.
How much total data would that be, roughly?  I guess if you were beginning with 0 knowledge, you would need all of the block headers, beginning from the genesis block?  But once you are convinced you are looking at the head of the right chain, you could discard all of the ancient block headers, and just save a recent one as a trusted starting point to evaluate subsequent transactions?

I guess the premise of my question is faulty, as a fake transaction could always be embedded in a fake chain, if enough computing resources were available.  So, there is no amount of data that insures a transaction is valid, without access to other information, e.g., what is the longest chain currently in existence.
A better question for my purposes would be how much would the electricity cost to create one fake block header at today's difficulty level?  Figuring that blockchain currently pays around $60K to mine one block, I would guess it must be in that order of magnitude, though smaller since we are removing the race condition.

Assuming the SPV client has the block header and the transaction hash; proof for only one transaction
ceil(log_2 (number_of_tx_in_that_block)) * 32 bytes

You can see the structure of the merkle tree here (the 2nd one)
For example, for TX 4, you need to give the hash of TX 3, hash D, hash C.

Thanks, but how to be certain the block header is not phony?  I guess can prove Merkle Root is valid with full chain of block headers, but that is still a lot of data.  Do I have to go back to genesis block?  Or, would I just need to see enough block headers chained after my block to be certain header is not fake?

SPV wallets should (must with little exceptions) store the block headers. That's what most of the SPV wallets do, and that's useful @user1055568

Seems like I only need a few block header preceding the block that contains my transaction, and then 6 or so that follow.  I can make up fake Merkle root, and all the Hash that follow, but to fake a preceding header, I need to solve reverse hash, and repeatedly for each preceding header.

In theory, you would only need the data from the block of the transaction, and the ability to prove it the transaction still exists after at least 6 confirmations.
The more confirmations (blocks mined beyond a transaction) the lower probability it becomes possible to reverse. Generally speaking, 6 confirmations is enough to identify a transaction is irreversible.
Here's a quote from Mastering Bitcoin by Andreas Antonopoulos:

By convention, any block with more than six confirmations is considered irrevocable, because it would require an immense amount of computation to invalidate and recalculate six blocks.

Block vary in size, but in SegWit transactions, the entire block can be a maximum  ~2 MB.
These days there are many online tools that can verify this without needing the entire blockchain.
The bitcoind JSON RPC API also works fairly well in providing transaction data. (Cannot be manipulated like with an online API)

I thought I could be certain a transaction belongs to a block, just by looking at the Merkle root and Merkle path.  But, if the Merkle root is made up, then it would be easy to make up phony path.   So, must have header chain, or at least a subset of it, to know Merkle root is not made up.


text:
What is the schema of the data stores used by the reference client?
I'm interested in seeing the schema (layout and indexes) that is used in the reference client.  Namely wallet.dat, the bk** files and also the in-memory uncommitted tx.
Does this exist anywhere for the 7.x client or the newer BerkleyDB format?
I'd like to see what, if any changes are being made to accommodate BIP 0034.

There are the bitcoin-tools by Gavin Andresen but they will only work up to version 0.7 of Bitcoin-QT. If your goal is to simply check whether the blocks are version 1 or 2 I suggest you do something like this:
MAX_HEIGHT=`bitcoind getinfo | grep blocks | grep -oE '[0-9]+'`
MIN_HEIGHT=210000
for HEIGHT in `seq $MAX_HEIGHT -1 $MIN_HEIGHT`; do
  HASH=`bitcoind getblockhash $HEIGHT`
  VERSION=`bitcoind getblock $HASH | grep version | grep -oE '[0-9]+'`
  echo $HEIGHT,$HASH,$VERSION
done >> block-versions.csv

This will get you a Comma-Separated file with the block's height,its hash and version.


text:
Where can I learn more about BIP30; namely the exploit and the background discussion?
I'm having trouble understanding the bug that was fixed in BIP030, and how it would be exploited.
Is the premise of this attack that there would have to be a netsplit and the chain was forked, then subsequently rolled back the old transactions?
What would the validation psuedo-logic of the following look like?

There are several potential solutions to this problem:

Guarantee that all coinbases are unique, making duplicate transactions very hard to create.
Remember previous remaining outputs of a given transaction identifier, in case a new transaction with the same identifier is
  added.
Only allow duplicate transactions in case the previous instance of the transaction had no spendable outputs left. Removing a block from
  the chain can then safely reset the removed transaction's outputs to
  nothing.

The reason I'm asking is so I can develop additional validation rules that work in parallel with the existing client.

The problem was that in case a duplicate transaction was created in a side branch that is afterwards reverted, and is only seen by a certain portion of the network, a fork risk exists. The nodes A that have seen the duplicate transactions and its reversal, will consider the original transaction unspendable (as it was overwritten and subsequently removed from their transaction database in the reorganisation), while nodes B that did not see the duplicate would consider the original spendable. When the original transaction is spent afterwards, and a majority of the network is in B, the network will split, as the A nodes will consider the chain created by B as invalid.
The third solution presented is implemented by BIP30 - this was a stopgap solution to prevent the worst from happening. A more complete solution (the first one) being deployed as BIP 34


text:
How can i use litecoinj(carete wallet return public address &send money to another address)?

why in this line(peerGroup.downloadBlockChain();) I can't connection peer?? I'm confuse.

Do you have a local litecoind instance?

No,But I Download litecoinj in github,how can i get the litecoin instance client ? I gratitude that, buy the way, I run bitcoinj use the main.class in java, and i can see the bitcoin wallet , how can litecoind use it ? i'm confuse.

It looks like the code that you're running expects to be able to connect to localhost and download the blockchain. Since there is no litecoin instance listening locally, this will not work.
Install litecoin, and run it.

I Download the litecoin client and run it,this is litecoin wallet client , I want to use run litecoin java code , should I use litecoin wallet client and change this wallet network to test ?

authors: Владислав Доценко


text:
If the PHP script and the Bitcoin wallet are on the same computer, does encrypting the link is necessary?
Dears,
If the PHP script and the Bitcoin wallet are on the same computer, does encrypting the link is necessary? like turn ssl on:rpcssl=1

It probably doesn't help much.
If the wallet (server) and the script (client) are running on the same computer, and you're connecting to it directly (e.g. on 127.0.0.1), then the data being sent should never reach any external network, and could only be intercepted by the user(s) running those programs, or a system administrator with higher privileges.  In most cases, those people would also be able to recover the SSL key, so encryption would not help very much.  For that matter, they would also probably be able to recover private keys and other sensitive data directly from the files or memory being used by the programs.
On the other hand, in most cases, RPC has so little traffic that the overhead of encryption is negligible, so it costs you almost nothing to turn it on, and it might make an attacker's job somewhat more difficult.
If your system uses more advanced separation of privileges (e.g. Linux admin capabilities and securelevels) then there might be more situations where someone might have access to local network traffic but not the keys or other sensitive data.  In such cases, encryption could make more of a difference.


text:
Where to find the blockchain on Bitcoin ABC?
So if I'm running a full node on Bitcoin ABC, where can I find the file or files which contain the blockchain when it is being downloaded?
The folder in Program Files is too small, I think, to contain the blockchain.

For future readers: the Bitcoin-ABC client is (confusingly) not a Bitcoin client.

As per the documentation https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/doc/files.md
blocks/blk000??.dat: block data (custom, 128 MiB per file); since 0.8.0

These files should be in C:/Users/(username)/AppData/Roaming/Bitcoin which is the standard app data directory.


text:
Generating addresses starting with certain characters such as "JoeAnonymousUserB7pMqyVa8JRcpZdCQLQ"
Similar to how the SHA256 hash competition exists to validate a transaction, I wonder if this concept can be ported to addresses, so that the first few characters is significant to a human reader.

Is there value in making a public key address start with human readable text?
What approaches exist to accomplish this?  Must the key pair be re-generated continuously or there there space to place a nonce?
Could this cause legal issues?  ...such as a key that contains text matching censored information which is replicated to countries that ban that information

Yes, the concept is known, and called "vanity address". The problem with it is that it takes a lot of computing power. However, there is also a "split-key" method of generating vanity addresses, which lets you commission other people for the computing work. And finally, I created a website called Vanity Pool that handles a sort of free market of vanity miners and buyers.
As for the legal issues, I have already included a so called "illegal number" in the block chain as a part of my master thesis. So far Bitcoin hasn't been banned;).

Yes, that part of the question was inspired from your master thesis.  Great work, highly recommended reading!


text:
How to fix Bitcoin QT loading issue
A few years ago my Bitcoin QT wallet stopped working and error messages started popping up
The error reads:

Assertion Failed!
Program:... File: src/main.cpp Line: 1127 Expression: pindexFirst
For information on how your program can cause an assertion failure,
  see the Visual C++ documentation on asserts (Press Retry to debug the
  application - JIT must be enabled)

How can I fix this? Is this wallet now obsolete?

This issue may be related.
The suggested fix is to start bitcoin-qt with the reindex option. To do that you'll need to start it from a command prompt and use:
bitcoin-qt.exe -reindex

Of course make sure you take a copy of your wallet.dat file and put it somewhere safe.
You could also try updating to the latest version of Bitcoin Core and then copy your wallet.dat file into the data directory BUT the wallet format may have changed in the interim which could prevent it from opening.

Actually, if the wallet format is changed bitcoin-qt should upgrade it automatically.