4

I'm pretty sure bitcoinj is capable of downloading any Bitcoin transaction from P2P nodes by broadcasting GetDataMessage because that's what it does in the peer.downloadDependenciesInternal method.

I'm trying to find/implement a very simple method which would download a transaction with its inputs and outputs and the block in which it's included (if any) but, because of Guava asynchronous futures, I cannot figure it out.

Very simply, I would like to replace 3rd-party services like blockchain.info with something decentralized.

3 Answers 3

1

GetData can fetch only unconfirmed transactions, and that's what Peer.downloadDependenciesInternal is doing.

You might want to contact the developer of the now defunct biteasy.com block explorer, he was using (and extending on) bitcoinj.

0

If your goal is to replace a 3rd-party service like blockchain.info, then you have to run a full bitcoind node with -txindex=1 and write your service to interface with it (see here)

As far as I can tell, the only way to get bitcoinj to only download your own confirmed TXs (by ID) is by setting up your wallet with it and using the Bloom filter feature to download Merkle proofs w.r.t. to the block headers. However, this will not be helpful for your application, where you want to download any transaction. You will have to run a full node!

0

So far, what I found out is that bitcoinj can only fetch unconfirmed transactions using:

GetDataMessage message = new GetDataMessage();
message.addTransaction(hash);
peer.sendMessage(message);

Message should then be received by some listener, for example:

peer.addPreMessageReceivedEventListener(...);

But confirmed transactions will not be received by this nor any similar method. If I'm wrong here I would be very happy. Simply there's no such functionality without running full node (bitcoind) with hash index.

1
  • Given that a Bitcoin Core full node cannot locate individual transactions by txid (unless txindex is enabled) for local usage, how would those same nodes be able to provide it to you over the network? If you want to find confirmed transactions, you need to synchronize the blocks (potentially with BIP37 filtering, but that has severe privacy implications). Commented Feb 18, 2017 at 2:20

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.