public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
* [bitcoin-dev] Trying to patch Core ZMQ "rawtx" topic to only publish unconfirmed transactions: How?
@ 2021-11-26 16:56 Ali Sherief
  2021-11-29  9:32 ` 0xB10C
  0 siblings, 1 reply; 5+ messages in thread
From: Ali Sherief @ 2021-11-26 16:56 UTC (permalink / raw)
  To: bitcoin-dev

[-- Attachment #1: Type: text/plain, Size: 2079 bytes --]

This has also been posted on Bitcointalk forum: https://bitcointalk.org/index.php?topic=5373341.msg58539261#msg58539261 I have republished it here hoping someone more knowledgeable can post some insight about this.
----
It appears that the ZeroMQ topic I'm listening to, "rawtx", not only emits a raw transaction when it appears on the mempool, but once it's already confirmed too.

This messes with my software, causing it to add txids, addresses, etc. a second time inside arrays (this means that the same transaction is received twice in total).

Array de-duping is not a viable solution long-term (because the array will quickly grow to be big eventually and then this has to happen every time a new element is added), so I'm trying to nip the problem from the source by instructing Core to only publish unconfirmed bitcoin transactions.

According to https://bitcoin.stackexchange.com/questions/52848/is-it-possible-to-configure-the-bitcoin-daemon-to-only-broadcast-unconfirmed-tra , it is not possible to configure this from a configuration or command-line option. The source code must directly be edited. But since the codebase has changed greatly, the proposed solution no longer works.

----

So basically, I know that something inside src/zmq/zmqnotificationinterface.cpp needs to be patched, but I'm not sure which function, or how to do it. Because I only need unconfirmed transactions to be published on ZeroMQ rawtx and not confirmed ones, it's one of the following functions that I need to patch for my own build:

CZMQNotificationInterface::TransactionRemovedFromMempool
void CZMQNotificationInterface::BlockDisconnected

Both of these call NotifyTransaction() method which I assume fires a message on "rawtx" channel.

In the Stack Exchange question I linked above, Jonas Schnelli suggested adding an `if (!pblock)` check, but that was several years ago and the function he was referencing no longer exists.

But I still wonder if the pblock check is still applicable in the present day (i.e. if it's indicating a block the transaction is inside).

- Ali Sherief

[-- Attachment #2: Type: text/html, Size: 3020 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [bitcoin-dev] Trying to patch Core ZMQ "rawtx" topic to only publish unconfirmed transactions: How?
@ 2021-11-27 13:42 Prayank
  0 siblings, 0 replies; 5+ messages in thread
From: Prayank @ 2021-11-27 13:42 UTC (permalink / raw)
  To: ali; +Cc: Bitcoin Dev

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

Hi Ali,

Not sure if this is exactly what you are looking for but maybe trying to solve this I might also learn few things:

Save zmqpubsequence=tcp://127.0.0.1:28332 in bitcoin.conf

Run bitcoind

Run this python script: https://pastebin.com/raw/tNp2x5y3

You will see results like this: 
https://i.imgur.com/xKzFJbl.png
https://i.imgur.com/gpsTTHZ.png

A - Accepted, C- Connect (block) and R- Removal in the above screenshots

If you are looking for unconfirmed transactions printed in sequence I think this should help. Since transactions can be printed twice (accept,remove) in this case as well, python script can be modified to manage this IMO.

Other alternatives can be debug=mempool and reading debug.log for changes without polling.

-- 
Prayank

A3B1 E430 2298 178F

[-- Attachment #2: Type: text/html, Size: 1465 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-29 14:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 16:56 [bitcoin-dev] Trying to patch Core ZMQ "rawtx" topic to only publish unconfirmed transactions: How? Ali Sherief
2021-11-29  9:32 ` 0xB10C
2021-11-29 14:10   ` LORD HIS EXCELLENCY JAMES HRMH
2021-11-29 14:13     ` Ali Sherief
2021-11-27 13:42 Prayank

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox