How can I get Bitcoin receive notifications with Bitcoin Core. I have tried the walletnotify and blocknotify options. walletnotify is fired two times when I send or receive bitcoins. And with blocknotify I have to perform below task to detect which account of the wallet has received bitcoin.

  • Run getBlock command to get all transaction hash
  • Run a for loop for each transaction hash to run getTransaction command
  • If transaction hash belong to my wallet account, I save the receive transaction in my database.

Using blocknotify seems to be inefficient as it involves lots of RPC calls per transaction.

walletnofity executes twice for bitcoin send and receive.

I have also tried ZMQ but I got a response which is difficult to convert into desirable format.

So could anybody suggest some efficient way to get a bitcoin receive notification upon first confirmation?

  • Since your current problem is inefficiency, i suggest writing to a sub/pub queue only onetime per new block or maintaining a database with receive indexes and query the DB (don't forget to manage a reorganization case)
    – youssef
    Oct 5, 2018 at 14:47
  • 5
    fwiw, the reason walletnotify executes twice is because the first time is for when a tx enters your mempool, and the second time is for when the tx is confirmed. You should care about the second one if it's an incoming payment. Also you can run with blocksonly=1 which will disable mempool and cause walletnotify to execute once (when a tx is confirmed in a new block)
    – arubi
    Dec 16, 2018 at 22:07

3 Answers 3


walletnotify executes once per every unconfirmed transaction creation (incoming/outgoing) and once more once the transaction is mined into a block (gets it's first confirmation).

I am not sure what are you developing, but as far as I see it both notifications are essential: The first one to let the customer know that his transaction had been recorded, and the second to know that the value was indeed remitted, with enough fee, and will not be double spent.

For more info please review the official documentation. https://en.bitcoin.it/wiki/Running_Bitcoin


I see a solution using ZMQ.

An example of using it is also available on Python.

By enabling ZMQ you can process network updates (blocks, new transactions) and select most relevant events accordingly. Also, some libraries to deserialize bitcoin blocks and transactions could be useful. If you work with Python, you can use python-bitcoinlib.


Not sure if this will be efficient enough for you, but when walletnotify is called it can pass along the txid it was called with. Then whatever program is executed, from walletnotify can do something like a decoderawtransaction using that txid and see if the blockHash field is filled in, and confirmations>0.

You can also use some intermediary program to prevent the primary program from being called twice. For example in bitcoin.conf have walletnotify call to something like 'checkconfirmed.py' . checkonfirmed.py can do the decoderawtransaction opreration described above, and only if confirmed will it call out to "finalprogram.py".

Your Answer

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

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