diff --git a/daemon/src/maker_cfd.rs b/daemon/src/maker_cfd.rs index 8133915..b3d9c89 100644 --- a/daemon/src/maker_cfd.rs +++ b/daemon/src/maker_cfd.rs @@ -97,6 +97,13 @@ impl Actor { tracing::info!("Refund transaction published on chain: {}", txid); } + for cfd in cfds.iter().filter(|cfd| Cfd::is_pending_commit(cfd)) { + let signed_commit_tx = cfd.commit_tx()?; + let txid = wallet.try_broadcast_transaction(signed_commit_tx).await?; + + tracing::info!("Commit transaction published on chain: {}", txid); + } + Ok(Self { db, wallet, diff --git a/daemon/src/model/cfd.rs b/daemon/src/model/cfd.rs index 3736343..8349040 100644 --- a/daemon/src/model/cfd.rs +++ b/daemon/src/model/cfd.rs @@ -654,6 +654,10 @@ impl Cfd { matches!(self.state.clone(), CfdState::MustRefund { .. }) } + pub fn is_pending_commit(&self) -> bool { + matches!(self.state.clone(), CfdState::PendingCommit { .. }) + } + pub fn is_cleanup(&self) -> bool { matches!( self.state.clone(), diff --git a/daemon/src/taker_cfd.rs b/daemon/src/taker_cfd.rs index 46a91c4..9730787 100644 --- a/daemon/src/taker_cfd.rs +++ b/daemon/src/taker_cfd.rs @@ -90,6 +90,13 @@ impl Actor { tracing::info!("Refund transaction published on chain: {}", txid); } + for cfd in cfds.iter().filter(|cfd| Cfd::is_pending_commit(cfd)) { + let signed_commit_tx = cfd.commit_tx()?; + let txid = wallet.try_broadcast_transaction(signed_commit_tx).await?; + + tracing::info!("Commit transaction published on chain: {}", txid); + } + Ok(Self { db, wallet,