I use bitcoinj to create the following method to broadcast a raw transacion in testnet, and I did see on bitcoin explorer that it has been broadcast. But even the transaction has been already broadcast, it always return false message, please help me to solve this issue, I don't know if there is a problem when sync with the peer or if my broadcast method is wrong.

//sync with the peer
static WalletAppKit kit = new WalletAppKit(params, new File("."), "sendrequest-example");

//transaction broadcast method
public static boolean broadcastTransaction (Transaction tx) {
        System.out.println("Broadcast transaction: ");
        try {
            TransactionBroadcast broadcast = kit.peerGroup().broadcastTransaction(tx);
            System.out.println(tx.getHash() + "broadcasted successfully!");
            return true;
        } catch (Exception e) {
            System.out.println("e.getMessage() = " + e.getMessage());
        return false;

The false message is always as following, although the transaction has been indeed broadcast.

e.getMessage() = Waited 20 seconds (plus 1985971 nanoseconds delay) for com.google.common.util.concurrent.SettableFuture@20d525[status=PENDING]
e.getMessage() = Waited 20 seconds (plus 4214583 nanoseconds delay) for com.google.common.util.concurrent.SettableFuture@38afe297[status=PENDING]

1 Answer 1


This looks like an implementation choice of the PeerGroup.broadcastTransaction method of bitcoinj.

If you send a transaction out to one or more peers, there is no guarantee that any of those peers will forward them on to others, and no way to verify it without having another node somewhere else on the bitcoin network listening for it (or listening to it from the same node but from different peers). You can only attempt to have some level of confidence that the transaction has been broadcast by sending it to multiple peers.

The broadcastTransaction method appears to have some confidence calculation in it, and probably does not complete the promise unless the confidence is met. I've not explored the details of it, but I'd suspect you're perhaps not connected to enough peers for it to have the confidence. Are you only connected to one peer perhaps? Maybe you need a longer timeout? Check the details of how the broadcast is implemented and you might figure it out.

  • If you're only connected to one peer, there's not much it can do. That peer won't send the transaction back to you. So until it's mined (which obviously will typically take much more than 20 seconds) it can't get any confidence at all. Aug 19, 2020 at 0:37

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.