Avoid possible mix up between timelocks

Introduce new type to ensure no mix up happens when ordering the fields
in function calls.
This commit is contained in:
Franck Royer 2021-02-15 12:19:43 +11:00
parent 9a321a4f09
commit b8a84aa34b
No known key found for this signature in database
GPG key ID: A82ED75A8DFC50A4
12 changed files with 121 additions and 104 deletions

View file

@ -1,10 +1,9 @@
use crate::{
bitcoin::{
self, current_epoch,
timelocks::{ExpiredTimelocks, Timelock},
wait_for_cancel_timelock_to_expire, BroadcastSignedTransaction, BuildTxLockPsbt,
GetBlockHeight, GetNetwork, GetRawTransaction, Transaction, TransactionBlockHeight,
TxCancel, Txid, WatchForRawTransaction,
self, current_epoch, wait_for_cancel_timelock_to_expire, BroadcastSignedTransaction,
BuildTxLockPsbt, CancelTimelock, ExpiredTimelocks, GetBlockHeight, GetNetwork,
GetRawTransaction, PunishTimelock, Transaction, TransactionBlockHeight, TxCancel, Txid,
WatchForRawTransaction,
},
execution_params::ExecutionParams,
monero,
@ -82,8 +81,8 @@ pub struct State0 {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
xmr: monero::Amount,
cancel_timelock: Timelock,
punish_timelock: Timelock,
cancel_timelock: CancelTimelock,
punish_timelock: PunishTimelock,
refund_address: bitcoin::Address,
min_monero_confirmations: u32,
}
@ -93,8 +92,8 @@ impl State0 {
rng: &mut R,
btc: bitcoin::Amount,
xmr: monero::Amount,
cancel_timelock: Timelock,
punish_timelock: Timelock,
cancel_timelock: CancelTimelock,
punish_timelock: PunishTimelock,
refund_address: bitcoin::Address,
min_monero_confirmations: u32,
) -> Self {
@ -177,8 +176,8 @@ pub struct State1 {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
xmr: monero::Amount,
cancel_timelock: Timelock,
punish_timelock: Timelock,
cancel_timelock: CancelTimelock,
punish_timelock: PunishTimelock,
refund_address: bitcoin::Address,
redeem_address: bitcoin::Address,
punish_address: bitcoin::Address,
@ -238,8 +237,8 @@ pub struct State2 {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
pub xmr: monero::Amount,
pub cancel_timelock: Timelock,
pub punish_timelock: Timelock,
pub cancel_timelock: CancelTimelock,
pub punish_timelock: PunishTimelock,
pub refund_address: bitcoin::Address,
pub redeem_address: bitcoin::Address,
pub punish_address: bitcoin::Address,
@ -307,8 +306,8 @@ pub struct State3 {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
xmr: monero::Amount,
pub cancel_timelock: Timelock,
punish_timelock: Timelock,
pub cancel_timelock: CancelTimelock,
punish_timelock: PunishTimelock,
pub refund_address: bitcoin::Address,
redeem_address: bitcoin::Address,
punish_address: bitcoin::Address,
@ -427,8 +426,8 @@ pub struct State4 {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
xmr: monero::Amount,
pub cancel_timelock: Timelock,
punish_timelock: Timelock,
pub cancel_timelock: CancelTimelock,
punish_timelock: PunishTimelock,
pub refund_address: bitcoin::Address,
pub redeem_address: bitcoin::Address,
punish_address: bitcoin::Address,
@ -614,8 +613,8 @@ pub struct State5 {
#[serde(with = "::bitcoin::util::amount::serde::as_sat")]
btc: bitcoin::Amount,
xmr: monero::Amount,
cancel_timelock: Timelock,
punish_timelock: Timelock,
cancel_timelock: CancelTimelock,
punish_timelock: PunishTimelock,
refund_address: bitcoin::Address,
pub redeem_address: bitcoin::Address,
punish_address: bitcoin::Address,