We use ZMQ notifications to monitor new blocks and new transactions in the mempool. It works very well on mainnet, but on testnet and regtest it works halfway: only new blocks are notified but not transactions in the mempool.
Here is the code used to connect:
def connect_to_zmq(self):
self.zmq_context = zmq.asyncio.Context()
self.zmq_sub_socket_sequence = self.zmq_context.socket(zmq.SUB)
self.zmq_sub_socket_sequence.setsockopt(zmq.RCVHWM, 0)
self.zmq_sub_socket_sequence.setsockopt(zmq.RCVTIMEO, ZMQ_TIMEOUT)
self.zmq_sub_socket_sequence.setsockopt_string(zmq.SUBSCRIBE, "rawtx")
self.zmq_sub_socket_sequence.setsockopt_string(zmq.SUBSCRIBE, "hashtx")
self.zmq_sub_socket_sequence.setsockopt_string(zmq.SUBSCRIBE, "sequence")
self.zmq_sub_socket_sequence.connect(self.zmq_sequence_address)
self.zmq_sub_socket_rawblock = self.zmq_context.socket(zmq.SUB)
self.zmq_sub_socket_rawblock.setsockopt(zmq.RCVHWM, 0)
self.zmq_sub_socket_sequence.setsockopt(zmq.RCVTIMEO, ZMQ_TIMEOUT)
self.zmq_sub_socket_rawblock.setsockopt_string(zmq.SUBSCRIBE, "rawblock")
self.zmq_sub_socket_rawblock.connect(self.zmq_rawblock_address)
and the full code is here: https://github.com/CounterpartyXCP/counterparty-core/blob/master/counterparty-core/counterpartycore/lib/follow.py
and here is the config file:
rpcuser=rpc
rpcpassword=rpc
rpcallowip=0.0.0.0
server=1
addresstype=legacy
txindex=1
prune=0
mempoolfullrbf=1
rpcworkqueue=100
datadir=/home/ouziel/medias/ssd/
daemon=1
[main]
zmqpubrawtx=tcp://0.0.0.0:9332
zmqpubhashtx=tcp://0.0.0.0:9332
zmqpubsequence=tcp://0.0.0.0:9332
zmqpubrawblock=tcp://0.0.0.0:9333
[test]
zmqpubrawtx=tcp://0.0.0.0:19332
zmqpubhashtx=tcp://0.0.0.0:19332
zmqpubsequence=tcp://0.0.0.0:19332
zmqpubrawblock=tcp://0.0.0.0:19333
[regtest]
zmqpubrawtx=tcp://0.0.0.0:29332
zmqpubhashtx=tcp://0.0.0.0:29332
zmqpubsequence=tcp://0.0.0.0:29332
zmqpubrawblock=tcp://0.0.0.0:29333
Is this a known limitation of Bitcoin Core? or a specific setting that is missing?
Thanks in advance.