Class TransactionBroadcast

java.lang.Object
org.bitcoinj.core.TransactionBroadcast

public class TransactionBroadcast extends Object
Represents a single transaction broadcast that we are performing. A broadcast occurs after a new transaction is created (typically by a Wallet) and needs to be sent to the network. A broadcast can succeed or fail. A success is defined as seeing the transaction be announced by peers via inv messages, thus indicating their acceptance. A failure is defined as not reaching acceptance within a timeout period, or getting an explicit reject message from a peer indicating that the transaction was not acceptable.
  • Field Details

    • random

      public static Random random
      Used for shuffling the peers before broadcast: unit tests can replace this to make themselves deterministic.
  • Method Details

    • createMockBroadcast

      public static TransactionBroadcast createMockBroadcast(Transaction tx, com.google.common.util.concurrent.SettableFuture<Transaction> future)
    • future

      public com.google.common.util.concurrent.ListenableFuture<Transaction> future()
    • setMinConnections

      public void setMinConnections(int minConnections)
    • setDropPeersAfterBroadcast

      public void setDropPeersAfterBroadcast(boolean dropPeersAfterBroadcast)
    • broadcast

      public com.google.common.util.concurrent.ListenableFuture<Transaction> broadcast()
    • setProgressCallback

      public void setProgressCallback(TransactionBroadcast.ProgressCallback callback)
      Sets the given callback for receiving progress values, which will run on the user thread. See Threading for details. If the broadcast has already started then the callback will be invoked immediately with the current progress.
    • setProgressCallback

      public void setProgressCallback(TransactionBroadcast.ProgressCallback callback, @Nullable Executor executor)
      Sets the given callback for receiving progress values, which will run on the given executor. If the executor is null then the callback will run on a network thread and may be invoked multiple times in parallel. You probably want to provide your UI thread or Threading.USER_THREAD for the second parameter. If the broadcast has already started then the callback will be invoked immediately with the current progress.