Skip to content

Commit

Permalink
Merge pull request #412 from rishkwal/rk/hotfix/continue-after-swapco…
Browse files Browse the repository at this point in the history
…in-recovery-error

patch(maker): allow maker to continue after failed swapcoin recovery
  • Loading branch information
mojoX911 authored Feb 15, 2025
2 parents 7628090 + 07910fe commit 77358e6
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
34 changes: 32 additions & 2 deletions src/maker/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,15 +615,45 @@ pub(crate) fn restore_broadcasted_contracts_on_reboot(maker: Arc<Maker>) -> Resu
let next_internal_address = &maker.wallet.read()?.get_next_internal_addresses(1)?[0];
let time_lock_spend = og_sc.create_timelock_spend(next_internal_address)?;

let tx = og_sc.get_fully_signed_contract_tx()?;
let tx = match og_sc.get_fully_signed_contract_tx() {
Ok(tx) => tx,
Err(e) => {
log::error!(
"Error: {:?} \
This was not supposed to happen. \
Kindly open an issue at https://github.com/citadel-tech/coinswap/issues.",
e
);
maker
.wallet
.write()?
.remove_outgoing_swapcoin(&og_sc.get_multisig_redeemscript())?;
continue;
}
};
outgoings.push((
(og_sc.get_multisig_redeemscript(), tx),
(contract_timelock, time_lock_spend),
));
}

for ic_sc in inc.iter() {
let tx = ic_sc.get_fully_signed_contract_tx()?;
let tx = match ic_sc.get_fully_signed_contract_tx() {
Ok(tx) => tx,
Err(e) => {
log::error!(
"Error: {:?} \
This was not supposed to happen. \
Kindly open an issue at https://github.com/citadel-tech/coinswap/issues.",
e
);
maker
.wallet
.write()?
.remove_incoming_swapcoin(&ic_sc.get_multisig_redeemscript())?;
continue;
}
};
incomings.push((ic_sc.get_multisig_redeemscript(), tx));
}

Expand Down
17 changes: 16 additions & 1 deletion src/maker/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,22 @@ fn unexpected_recovery(maker: Arc<Maker>) -> Result<(), MakerError> {
.zip(state.incoming_swapcoins.iter())
{
let contract_timelock = og_sc.get_timelock()?;
let contract = og_sc.get_fully_signed_contract_tx()?;
let contract = match og_sc.get_fully_signed_contract_tx() {
Ok(tx) => tx,
Err(e) => {
log::error!(
"Error: {:?} \
This was not supposed to happen. \
Kindly open an issue at https://github.com/citadel-tech/coinswap/issues.",
e
);
maker
.wallet
.write()?
.remove_outgoing_swapcoin(&og_sc.get_multisig_redeemscript())?;
continue;
}
};
let next_internal_address = &maker.wallet.read()?.get_next_internal_addresses(1)?[0];
let time_lock_spend = og_sc.create_timelock_spend(next_internal_address)?;
outgoings.push((
Expand Down

0 comments on commit 77358e6

Please sign in to comment.