-pub trait BroadcasterInterface: Sync + Send {
- /// Sends a transaction out to (hopefully) be mined.
- fn broadcast_transaction(&self, tx: &Transaction);
-}
-
-/// A trait indicating a desire to listen for events from the chain
-pub trait ChainListener: Sync + Send {
- /// Notifies a listener that a block was connected. Transactions may be filtered and are given
- /// paired with their position within the block.
- fn block_connected(&self, header: &BlockHeader, txdata: &[(usize, &Transaction)], height: u32);
-
- /// Notifies a listener that a block was disconnected.
- /// Unlike block_connected, this *must* never be called twice for the same disconnect event.
- /// Height must be the one of the block which was disconnected (not new height of the best chain)
- fn block_disconnected(&self, header: &BlockHeader, disconnected_height: u32);
+pub trait BroadcasterInterface {
+ /// Sends a list of transactions out to (hopefully) be mined.
+ /// This only needs to handle the actual broadcasting of transactions, LDK will automatically
+ /// rebroadcast transactions that haven't made it into a block.
+ ///
+ /// In some cases LDK may attempt to broadcast a transaction which double-spends another
+ /// and this isn't a bug and can be safely ignored.
+ ///
+ /// If more than one transaction is given, these transactions should be considered to be a
+ /// package and broadcast together. Some of the transactions may or may not depend on each other,
+ /// be sure to manage both cases correctly.
+ ///
+ /// Bitcoin transaction packages are defined in BIP 331 and here:
+ /// https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md
+ fn broadcast_transactions(&self, txs: &[&Transaction]);