6

I'm using the traditional bitcoind -gen on the testnet to mine some test bitcoins. I did this on one machine for a few hours, and stopped when I found a faucet. Later though, I magically obtained 50 coins in my wallet. I think because blocks have a long confirmation?

Anyway, so how can I tell when bitcoind has successfully mined a block (and now just waiting for confirmations)

2 Answers 2

3

If you look in debug.log, you should see a message that says "proof-of-work found".

Here is an excerpt from debug.log for a testnet block that I found. (It was immediately orphaned; in fact an earlier block had been found several minutes earlier but had not yet reached me. So you won't find it in the blockchain.)

BitcoinMiner:
proof-of-work found  
  hash: 00000000609b21ea1d67f7220d12f7e6f06542907fa24511fa416b286e11cb54  
target: 00000000ffff0000000000000000000000000000000000000000000000000000
CBlock(hash=00000000609b21ea1d67f7220d12f7e6f06542907fa24511fa416b286e11cb54, ver=2, hashPrevBlock=00000000b96e8a2e2f27bf209a1059fd10b117cdf5a6373559eb93268853bc04, hashMerkleRoot=f25394d1360a276fa5e3c51b245969d193710d06b5bda12468e11074c8740d50, nTime=1383697696, nBits=1d00ffff, nNonce=2576125723, vtx=1)
  CTransaction(hash=f25394d1360a276fa5e3c51b245969d193710d06b5bda12468e11074c8740d50, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 0330f6010101062f503253482f)
    CTxOut(nValue=50.00000000, scriptPubKey=0226fe62f7b1812c421efd7638907f)
  vMerkleTree: f25394d1360a276fa5e3c51b245969d193710d06b5bda12468e11074c8740d50 
generated 50.00
keypool keep 6
AddToWallet f25394d1360a276fa5e3c51b245969d193710d06b5bda12468e11074c8740d50  new
Committing 1 changed transactions to coin database...
SetBestChain: new best=00000000609b21ea1d67f7220d12f7e6f06542907fa24511fa416b286e11cb54  height=128560  log2_work=57.064666  tx=708022  date=2013-11-06 00:28:16 progress=1.000000
ProcessBlock: ACCEPTED

I believe debug.log is overwritten periodically, so if your block was created some time ago, you may no longer have this entry in yours.

Newly generated coins require 100 confirmations before they can be spent, and bitcoind apparently won't show them as spendable until 120. See also this question. As far as I know these rules are the same on testnet.

Congratulations on your newfound fake wealth!

2
  • 2
    The debug log is way too huge to manually sift through. Searching through it though for "proof", "work", or "found" revealed nothing obvious though
    – Earlz
    Dec 4, 2013 at 22:43
  • @Earlz: I added an excerpt. If you didn't find it, it may have been overwritten. Another idea would be to use Block Explorer on the address that received the generated coins, find the block that created them, and grep debug.log for its hash. Dec 4, 2013 at 23:28
0

As described in Running Bitcoin, you need to either use the -blocknotify command line switch or enable the setting in your Bitcoin.conf file.

As the page says, you use a command line script/program and the %s in the command line gets replaced by the new block's hash. If you need info about the block, you can then look it up using a JSON-RPC command like get-block, for example.

My bitcoind installation has a command-line script that uses CURL, which I then use to post an HTTP notification to my web site. Just an example of how this can be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.