How to receive newly broadcasted transactions immediately with bitcoin-core RPC?

2

1

With getrawmempool it gets me txids, however it just dumps the whole mempool on me. This isn't convenient if I want to quickly detect new transactions. Is it possible to only get newly broadcasted transactions?

Is there another way to sort of stream them from bitcoin-core into my program?

snitko

Posted 2017-08-16T06:03:16.110

Reputation: 163

Answers

3

You can use the ZMQ interface to receive a ZMQ notification when a new transaction is received. You can have it give you the txid, the raw transaction, or both.

Andrew Chow

Posted 2017-08-16T06:03:16.110

Reputation: 40 910

0

I think what you are looking for is walletnotify. You can set on bitcoin.conf file.

For example

walletnotify=/home/process_tx.sh

That will call /home/process_tx.sh passing as parameter the transaction hash Or you can also run bitcoind with using -walletnotify

bitcoind -walletnotify=/home/process_tx.sh

carvmarc

Posted 2017-08-16T06:03:16.110

Reputation: 126

1As far as I understand, walletnotify only notifies of transactions made to the address that belong to that wallet. I'm interested in collecting all transactions that are broadcasted.snitko 2017-08-17T04:20:23.560

In that case, you should use ZMQ as sugest by @Andrew Chowcarvmarc 2017-08-17T15:08:33.197