Browse Source

Re-trigger sending commit in case we start up in `PendingCommit`

For now the behavior is: Once the user pressed the button commit will be published and also retried upon startup.
upload-correct-windows-binary
Daniel Karzel 3 years ago
parent
commit
592e81c897
No known key found for this signature in database GPG Key ID: 30C3FC2E438ADB6E
  1. 7
      daemon/src/maker_cfd.rs
  2. 4
      daemon/src/model/cfd.rs
  3. 7
      daemon/src/taker_cfd.rs

7
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,

4
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(),

7
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,

Loading…
Cancel
Save