5

I need to capture and store the raw transactions coming through my local full-node bitcoin instance. I read here that it is possible, but there is no mention of the particular RPC calls. I also see the raw transaction JSON-RPC API, but it is still not clear how to use this to periodically query the raw transactions.

It seems like bitcoin-sniffer (written in python) is what I am trying to do and need, and since I am using Java, it seems bitcoinj can actually listen for incoming transactions, but I don't see example codes on how to do this.

My question is, how do I use the HTTP POST JSON RPC API back to my local bitcoin instance to query for transactions? Is there a tutorial?

I'd imagine I would be running in a continuous thread and periodically query bitcoind (the daemon) for the latest batch of transactions. Is this possible?

3
  • 3
    bitcoin transactions comes in streams, its better to use ZMQ for this. Read doc/zmq.md in the bitcoin repository.
    – rny
    Commented Feb 10, 2017 at 22:38
  • Thanks. That seems like a viable alternative. Just to clarify, do you know if what's published from bitcoind to 0MQ is the raw transactions (the data and all its fields) in deserialized (JSON not hex) form?
    – Jane Wayne
    Commented Feb 10, 2017 at 22:45
  • its serialized hex, you'll have to de-serialize it. There are convenient functions with bitcoin-cli to do this.
    – rny
    Commented Feb 10, 2017 at 23:24

2 Answers 2

1

My question is, how do I use the HTTP POST JSON RPC API back to my local bitcoin >instance to query for transactions? Is there a tutorial?

You can find information about bitcoin RPC in https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

Also you can actually execute bitcoin RPC calls in https://chainquery.com/bitcoin-cli. If you only want to see what they are returning

I'd imagine I would be running in a continuous thread and periodically query >bitcoind (the daemon) for the latest batch of transactions. Is this possible?

That's the approach I'm using in my project, you can see the code in https://github.com/JRamosGarcia/bitcoindAdapter It uses many java technologies as spring (for many uses, but make RPC a breeze to implement) , or quartz for periodic jobs. It's a work in progress, but maybe you can find some code or technology that helps you.

0

Renlord commented

bitcoin transactions comes in streams, its better to use ZMQ for this. Read doc/zmq.md in the bitcoin repository

and

[the data is not json but] serialized hex, you'll have to de-serialize it. There are convenient functions with bitcoin-cli to do this.

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.