Skip to content

Commit

Permalink
don't hard error on send failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mojoX911 committed Jan 17, 2025
1 parent 6a0aca5 commit 3874f53
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions src/maker/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,19 @@ pub(crate) fn recover_from_swap(
"[{}] Incoming Contract Already Broadcasted",
maker.config.network_port
);
} else {
maker.wallet.read()?.send_tx(&tx)?;

log::info!(
"[{}] Broadcasted Incoming Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}
} else if let Err(e) = maker.wallet.read()?.send_tx(&tx) {
log::info!(
"Can't send incoming contract: {} | {:?}",
tx.compute_txid(),
e
);
} else {
log::info!(
"[{}] Broadcasted Incoming Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}

let removed_incoming = maker
.wallet
Expand All @@ -774,7 +778,7 @@ pub(crate) fn recover_from_swap(
}

//broadcast all the outgoing contracts
for ((_, tx), _) in outgoings.iter() {
for ((og_rs, tx), _) in outgoings.iter() {
if maker
.wallet
.read()?
Expand All @@ -786,14 +790,27 @@ pub(crate) fn recover_from_swap(
"[{}] Outgoing Contract already broadcasted",
maker.config.network_port
);
} else {
let txid = maker.wallet.read()?.send_tx(tx)?;
log::info!(
"[{}] Broadcasted Outgoing Contract : {}",
maker.config.network_port,
txid
);
}
} else if let Err(e) = maker.wallet.read()?.send_tx(tx) {
log::info!(
"Can't send ougoing contract: {} | {:?}",
tx.compute_txid(),
e
);
if format!("{:?}", e).contains("bad-txns-inputs-missingorspent") {
// This means the funding utxo doesn't exist anymore. Just remove this coin.
log::info!("Removing outgoing swapcoin: {}", tx.compute_txid());
maker
.get_wallet()
.write()?
.remove_outgoing_swapcoin(og_rs)?;
}
} else {
log::info!(
"[{}] Broadcasted Outgoing Contract : {}",
maker.config.network_port,
tx.compute_txid()
);
}
}

// Save the wallet here before going into the expensive loop.
Expand Down

0 comments on commit 3874f53

Please sign in to comment.