Skip to content

Commit 2024749

Browse files
committed
Use a vec of length 1 to broadcast unrelated txs
`BroadcasterInterface::broadcast_transactions` requires that any passed vector containing multiple transactions must be a single child together with its parents. We will lean on this contract in upcoming commits, so here we fix a case where we broke this contract.
1 parent 150f370 commit 2024749

1 file changed

Lines changed: 14 additions & 17 deletions

File tree

src/wallet/mod.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -326,23 +326,20 @@ impl Wallet {
326326
}
327327
}
328328

329-
if !unconfirmed_outbound_txids.is_empty() {
330-
let txs_to_broadcast: Vec<Transaction> = unconfirmed_outbound_txids
331-
.iter()
332-
.filter_map(|txid| {
333-
locked_wallet.tx_details(*txid).map(|d| (*d.tx).clone())
334-
})
335-
.collect();
336-
337-
if !txs_to_broadcast.is_empty() {
338-
let tx_count = txs_to_broadcast.len();
339-
self.broadcaster.broadcast_unclassified_transactions(txs_to_broadcast);
340-
log_info!(
341-
self.logger,
342-
"Rebroadcast {} unconfirmed transactions on chain tip change",
343-
tx_count
344-
);
345-
}
329+
let count: usize = unconfirmed_outbound_txids
330+
.into_iter()
331+
.filter_map(|txid| {
332+
let tx = locked_wallet.tx_details(txid).map(|d| (*d.tx).clone())?;
333+
self.broadcaster.broadcast_unclassified_transactions(vec![tx]);
334+
Some(())
335+
})
336+
.count();
337+
if count != 0 {
338+
log_info!(
339+
self.logger,
340+
"Rebroadcast {} unconfirmed transactions on chain tip change",
341+
count,
342+
);
346343
}
347344
},
348345
WalletEvent::TxUnconfirmed { txid, tx, .. } => {

0 commit comments

Comments
 (0)