mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Alice aborts if any timelock expired before locking XMR
Once we resume unfinished swaps upon startup we have to ensure that it is safe for Alice to act. If Bob has locked BTC it is only make sense for Alice to lock up the XMR as long as no timelock has expired. Hence we abort if the BTC is locked, but any timelock expired already.
This commit is contained in:
parent
607b3d2fdc
commit
dfd69c9c80
@ -88,7 +88,11 @@ async fn next_state(
|
||||
}
|
||||
}
|
||||
}
|
||||
AliceState::BtcLocked { state3 } => {
|
||||
AliceState::BtcLocked { state3 } => match state3
|
||||
.expired_timelocks(bitcoin_wallet)
|
||||
.await?
|
||||
{
|
||||
ExpiredTimelocks::None => {
|
||||
// Record the current monero wallet block height so we don't have to scan from
|
||||
// block 0 for scenarios where we create a refund wallet.
|
||||
let monero_wallet_restore_blockheight = monero_wallet.block_height().await?;
|
||||
@ -118,6 +122,8 @@ async fn next_state(
|
||||
monero_wallet_restore_blockheight,
|
||||
}
|
||||
}
|
||||
_ => AliceState::SafelyAborted,
|
||||
},
|
||||
AliceState::XmrLocked {
|
||||
state3,
|
||||
monero_wallet_restore_blockheight,
|
||||
|
@ -835,7 +835,7 @@ pub struct FastCancelConfig;
|
||||
impl GetConfig for FastCancelConfig {
|
||||
fn get_config() -> Config {
|
||||
Config {
|
||||
bitcoin_cancel_timelock: CancelTimelock::new(1),
|
||||
bitcoin_cancel_timelock: CancelTimelock::new(10),
|
||||
..env::Regtest::get_config()
|
||||
}
|
||||
}
|
||||
@ -846,7 +846,7 @@ pub struct FastPunishConfig;
|
||||
impl GetConfig for FastPunishConfig {
|
||||
fn get_config() -> Config {
|
||||
Config {
|
||||
bitcoin_cancel_timelock: CancelTimelock::new(1),
|
||||
bitcoin_cancel_timelock: CancelTimelock::new(10),
|
||||
bitcoin_punish_timelock: PunishTimelock::new(1),
|
||||
..env::Regtest::get_config()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user