Skip to content

Commit

Permalink
Rebroadcast commitment tx when handle Event BumpTransactionEvent::Cha…
Browse files Browse the repository at this point in the history
…nnelClose.
  • Loading branch information
EthanYuan committed Jan 14, 2025
1 parent a2e3c86 commit c0cffd8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mutiny-core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,23 @@ impl<S: MutinyStorage> EventHandler<S> {
timestamp,
hex_tx
);

// Leverages the `BumpTransactionEvent::ChannelClose` mechanism to automatically retry
// rebroadcasting the commitment transaction if the initial broadcast fails.
// This operation has almost no side effects, as broadcasting the same transaction multiple times
// does not alter its state or the blockchain, and nodes will simply ignore duplicate broadcasts.
log_debug!(
self.logger,
"Trying rebroadcast for commitment tx transaction: {event:?}"
);
if let Err(e) = self
.wallet
.broadcast_transaction(commitment_tx.clone())
.await
{
log_error!(self.logger, "Failed to rebroadcast commitment tx: {e}");
}

if self.do_not_bump_channel_closed_tx {
log_debug!(self.logger, "Skip channel close transaction");
} else {
Expand Down

0 comments on commit c0cffd8

Please sign in to comment.