From 530b9b2ea86a3c05e65c198d29023eaf8966f945 Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Mon, 8 Feb 2021 14:39:27 +1100 Subject: [PATCH] Remove possible mix up of timelocks when using `State0::new` --- swap/src/protocol/alice.rs | 3 +-- swap/src/protocol/alice/state.rs | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/swap/src/protocol/alice.rs b/swap/src/protocol/alice.rs index b35f167e..cf9b883b 100644 --- a/swap/src/protocol/alice.rs +++ b/swap/src/protocol/alice.rs @@ -178,8 +178,7 @@ impl Builder { let state0 = State0::new( amounts.btc, amounts.xmr, - self.execution_params.bitcoin_cancel_timelock, - self.execution_params.bitcoin_punish_timelock, + self.execution_params, self.bitcoin_wallet.as_ref(), &mut OsRng, ) diff --git a/swap/src/protocol/alice/state.rs b/swap/src/protocol/alice/state.rs index 0ec03f05..7127ba36 100644 --- a/swap/src/protocol/alice/state.rs +++ b/swap/src/protocol/alice/state.rs @@ -6,6 +6,7 @@ use crate::{ wait_for_cancel_timelock_to_expire, GetBlockHeight, TransactionBlockHeight, TxCancel, TxRefund, WatchForRawTransaction, }, + execution_params::ExecutionParams, monero, protocol::{ alice::{Message1, Message3, TransferProof}, @@ -104,8 +105,7 @@ impl State0 { pub async fn new( btc: bitcoin::Amount, xmr: monero::Amount, - cancel_timelock: Timelock, - punish_timelock: Timelock, + execution_params: ExecutionParams, bitcoin_wallet: &bitcoin::Wallet, rng: &mut R, ) -> Result @@ -128,8 +128,8 @@ impl State0 { punish_address, btc, xmr, - cancel_timelock, - punish_timelock, + cancel_timelock: execution_params.bitcoin_cancel_timelock, + punish_timelock: execution_params.bitcoin_punish_timelock, }) }