Skip to content

Commit

Permalink
Merge pull request #411 from rishkwal/rk/save-swapcoin-to-disk-first
Browse files Browse the repository at this point in the history
fix(maker): store swapcoin to disk before broadcasting funding tx
  • Loading branch information
mojoX911 authored Feb 9, 2025
2 parents b5dc0cb + 2944616 commit 7628090
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/maker/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,6 @@ impl Maker {
outgoing_swapcoin.others_contract_sig = Some(*senders_sig);
}

let mut my_funding_txids = Vec::<Txid>::new();
for my_funding_tx in &connection_state.pending_funding_txes {
let txid = self.wallet.read()?.send_tx(my_funding_tx)?;

assert_eq!(txid, my_funding_tx.compute_txid());
my_funding_txids.push(txid);
}
log::info!(
"[{}] Broadcasted funding txs: {:?}",
self.config.network_port,
my_funding_txids
);

{
let mut wallet_writer = self.wallet.write()?;
for (incoming_sc, outgoing_sc) in connection_state
Expand All @@ -546,6 +533,19 @@ impl Maker {
wallet_writer.save_to_disk()?;
}

let mut my_funding_txids = Vec::<Txid>::new();
for my_funding_tx in &connection_state.pending_funding_txes {
let txid = self.wallet.read()?.send_tx(my_funding_tx)?;

assert_eq!(txid, my_funding_tx.compute_txid());
my_funding_txids.push(txid);
}
log::info!(
"[{}] Broadcasted funding txs: {:?}",
self.config.network_port,
my_funding_txids
);

// Update the connection state.
self.ongoing_swap_state.lock()?.insert(
message.id.clone(),
Expand Down

0 comments on commit 7628090

Please sign in to comment.