parse bitcoin addresses from transactions acquired by means of the P2P protocol utilizing python

on

|

views

and

comments


I’m assuming that you’re truly simply involved in getting data on each transaction your node sees, reasonably than the precise p2p site visitors.

In that case, right here is how I’d strategy your drawback:

  1. Run a Bitcoin Core full node. If you happen to solely care about unconfirmed transactions, take into account making it a pruned node. If you wish to accumulate information on all transactions, make it a non-pruning node and allow the transaction index with txindex=1.
  2. Set up PyZMQ
  3. Allow ZeroMQ.
  4. Hearken to the hashtx ZMQ notifications
    hashtx notifies about all transactions, both when they’re added to mempool or when a brand new block arrives, so chances are you’ll get a number of notifications for a similar txid.
  5. For every hashtx notification you obtain, test if the transaction is seen for the primary time, then name bitcoin-cli getrawtransaction <txid>. Within the response, learn the worth and handle fields for every component of the vout vector. Optionally learn n to get the output’s index. Observe that some outputs don’t have addresses, e.g. P2PK and nulldata (OP_RETURN) outputs.
  6. Optionally: Retailer the ensuing outputs in a database utilizing their “outpoint” (txid:n) as the important thing.

Observe that some txs you see in your mempool could get changed by a later transaction. If you wish to be sure to solely maintain transactions that find yourself being a part of the most effective chain, chances are you’ll wish to monitor transactions in blocks reasonably than transactions within the mempool, and you should definitely deal with blockchain reorganizations.

If that’s too gradual to your functions, you may get a complete block explorer of your personal by operating an occasion of mempool.area or Esplora. Alternatively, you may most likely pay for an API key to get this (public!) information from plenty of completely different block explorers.

Observe that you just may must easy out some corners on this strategy if you would like use it, I’ve not examined this. There may additionally be simpler extra environment friendly methods, I by no means tried to unravel this drawback myself.

Share this
Tags

Must-read

Constructing the Torc Driverless Security Case

At Torc, we’ve structured our security case on three foundational pillars: Engineer It to Be Secure, Function It to Be Secure, and the...

What’s DL+S? Unlocking the Huge Information Required to Develop Autonomous Vans

Breakthroughs in AI for autonomous driving don't occur in isolation. They occur when information, simulation, machine studying, infrastructure, and car testing work as...

Why I can’t wait to get right into a driverless automotive | Self-driving automobiles

Adrian Chiles (Driverless automobiles are taking us on a street to nowhere, 10 September) needs to know who requested for driverless automobiles. I...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here