3

How would I go about getting a stream of transactions broadcast on the Bitcoin network? Is this supported by the vanilla client?

I know that the client can notify me on new blocks and on all transactions that effect an address in my wallet, but I want to stream ALL transactions on the network.

2
  • What do you mean by "stream"? What do you want to do with those transactions? What do you want to be done for you? Apr 2, 2014 at 15:04
  • @NateEldredge I want to do something similar to how blockchain.info displays transactions in real time. I just didn't know if the client exposed this anywhere, or not. I can see them in bitcoind's console - do I monitor console output? <shudder/>
    – Avram
    Apr 3, 2014 at 0:36

5 Answers 5

1

Reading your question again, and looking at the comments, I think your question is slightly misinformed.

The standard bitcoin QT client is a node, which means that it receives the inventory of all transactions and relays all valid transactions it requests to receive (from the inventories). That's a bit of a mouthfull but read it carefully.

This has nothing to do with your wallet. It is a standard function of the full node on the peer to peer network.

What you appear to be mixing is the functionality of the wallet and the functionality of the node. These are two different things.

Bitcoin QT is unlike other (lightweight or SPV) clients which only request information specific to the addresses they hold, when trying to syncronise themselves with the network.

If you are looking to essentially print all transactions that are being relayed through your node, I think this would be pretty straitforward using something like Node.js or just running a continuous regular process which queries Bitcoind using RPC.

1

You don't need a full bitcoind node running. There's plenty of code to do that, I suggest you bitcoinj for Java and picocoin for C. It's a trivial task: connect to any peer (e.g. through DNS discovery) and parse the 'tx' messages it will send you.

I also published my own client library but it's for iOS and I guess you're looking for server-side stuff.

EDIT: if you don't want to get your feet wet at all a quick-and-dirty solution is the blockchain.info WebSocket API.

1

For https://getaddr.bitnodes.io/dashboard/#transactions-and-blocks-propagation, I keep open connections with all reachable nodes in the network and then capture all incoming inv messages with tcpdump and parse the pcap files for inv packets; inv type 1 for transaction and inv type 2 for block. In order to receive all inv messages, you need to ensure your relay bit is set to 1 in your outgoing version message. Be ready to handle 3 to 10 Mbps for the incoming invs and you should be able to get all transactions this way but they may not necessarily come from the origin node.

0

Signing the transaction itself gets them to propagate on the network. The miner fee is recognized by peers running btc nodes and by miners who are willing to accept the fee if their proof of work is accepted.

It sounds like you're trying to effectively replicate the real-time relaying of transactions? Bitlisten.com has effectively done this and provides the audio output when this occurs in real-time. They use Blockchain.info's api to recieve realtime transactions.

3
  • Yes, I know Blockchain.info can do it - I guess my question could be restated 'how do THEY do it?'
    – Avram
    Apr 3, 2014 at 0:35
  • @Avram: The short answer is, they wrote a lot of custom code. Apr 3, 2014 at 0:44
  • That's what I feared :) I will start by parsing bitcoind's output and see how far that gets me.
    – Avram
    Apr 3, 2014 at 0:46
0

Theres a python script that connects to bitcoind and generates new tx and new block events here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.