2020-11-27 00:30:07 +00:00
|
|
|
//! Run an XMR/BTC swap in the role of Alice.
|
|
|
|
//! Alice holds XMR and wishes receive BTC.
|
|
|
|
use crate::{
|
|
|
|
alice::{
|
2020-12-10 02:19:18 +00:00
|
|
|
event_loop::EventLoopHandle,
|
2020-11-25 05:27:57 +00:00
|
|
|
execution::{
|
|
|
|
build_bitcoin_punish_transaction, build_bitcoin_redeem_transaction,
|
|
|
|
extract_monero_private_key, lock_xmr, negotiate, publish_bitcoin_punish_transaction,
|
|
|
|
publish_bitcoin_redeem_transaction, publish_cancel_transaction,
|
|
|
|
wait_for_bitcoin_encrypted_signature, wait_for_bitcoin_refund, wait_for_locked_bitcoin,
|
|
|
|
},
|
2020-11-27 00:30:07 +00:00
|
|
|
},
|
2020-11-25 05:27:57 +00:00
|
|
|
bitcoin::EncryptedSignature,
|
2020-11-27 00:30:07 +00:00
|
|
|
network::request_response::AliceToBob,
|
|
|
|
SwapAmounts,
|
|
|
|
};
|
2020-11-25 05:27:57 +00:00
|
|
|
use anyhow::Result;
|
2020-11-27 00:30:07 +00:00
|
|
|
use async_recursion::async_recursion;
|
|
|
|
use futures::{
|
|
|
|
future::{select, Either},
|
|
|
|
pin_mut,
|
|
|
|
};
|
|
|
|
use libp2p::request_response::ResponseChannel;
|
|
|
|
use rand::{CryptoRng, RngCore};
|
2020-12-02 01:36:47 +00:00
|
|
|
use std::{fmt, sync::Arc};
|
|
|
|
use tracing::info;
|
2020-11-27 00:30:07 +00:00
|
|
|
use xmr_btc::{
|
2020-12-10 00:18:45 +00:00
|
|
|
alice::{State0, State3},
|
2020-11-25 05:27:57 +00:00
|
|
|
bitcoin::{TransactionBlockHeight, TxCancel, TxRefund, WatchForRawTransaction},
|
2020-12-01 23:00:00 +00:00
|
|
|
config::Config,
|
2020-11-27 00:30:07 +00:00
|
|
|
monero::CreateWalletForOutput,
|
2020-12-11 05:49:19 +00:00
|
|
|
Epoch,
|
2020-11-27 00:30:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
trait Rng: RngCore + CryptoRng + Send {}
|
|
|
|
|
|
|
|
impl<T> Rng for T where T: RngCore + CryptoRng + Send {}
|
|
|
|
|
|
|
|
// The same data structure is used for swap execution and recovery.
|
|
|
|
// This allows for a seamless transition from a failed swap to recovery.
|
2020-12-01 04:38:24 +00:00
|
|
|
#[allow(clippy::large_enum_variant)]
|
2020-11-27 00:30:07 +00:00
|
|
|
pub enum AliceState {
|
|
|
|
Started {
|
|
|
|
amounts: SwapAmounts,
|
2020-12-10 00:18:45 +00:00
|
|
|
state0: State0,
|
2020-11-27 00:30:07 +00:00
|
|
|
},
|
|
|
|
Negotiated {
|
|
|
|
channel: ResponseChannel<AliceToBob>,
|
|
|
|
amounts: SwapAmounts,
|
|
|
|
state3: State3,
|
|
|
|
},
|
|
|
|
BtcLocked {
|
|
|
|
channel: ResponseChannel<AliceToBob>,
|
|
|
|
amounts: SwapAmounts,
|
|
|
|
state3: State3,
|
|
|
|
},
|
|
|
|
XmrLocked {
|
|
|
|
state3: State3,
|
|
|
|
},
|
|
|
|
EncSignLearned {
|
|
|
|
state3: State3,
|
|
|
|
encrypted_signature: EncryptedSignature,
|
|
|
|
},
|
|
|
|
BtcRedeemed,
|
|
|
|
BtcCancelled {
|
|
|
|
state3: State3,
|
|
|
|
tx_cancel: TxCancel,
|
|
|
|
},
|
|
|
|
BtcRefunded {
|
|
|
|
tx_refund: TxRefund,
|
|
|
|
published_refund_tx: ::bitcoin::Transaction,
|
|
|
|
state3: State3,
|
|
|
|
},
|
|
|
|
BtcPunishable {
|
|
|
|
tx_refund: TxRefund,
|
|
|
|
state3: State3,
|
|
|
|
},
|
|
|
|
XmrRefunded,
|
2020-12-11 05:49:19 +00:00
|
|
|
Cancelling {
|
2020-11-27 00:30:07 +00:00
|
|
|
state3: State3,
|
|
|
|
},
|
|
|
|
Punished,
|
|
|
|
SafelyAborted,
|
|
|
|
}
|
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
impl fmt::Display for AliceState {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
match self {
|
|
|
|
AliceState::Started { .. } => write!(f, "started"),
|
|
|
|
AliceState::Negotiated { .. } => write!(f, "negotiated"),
|
|
|
|
AliceState::BtcLocked { .. } => write!(f, "btc_locked"),
|
|
|
|
AliceState::XmrLocked { .. } => write!(f, "xmr_locked"),
|
2020-12-14 00:56:14 +00:00
|
|
|
AliceState::EncSignLearned { .. } => write!(f, "encsig_learned"),
|
2020-12-02 01:36:47 +00:00
|
|
|
AliceState::BtcRedeemed => write!(f, "btc_redeemed"),
|
|
|
|
AliceState::BtcCancelled { .. } => write!(f, "btc_cancelled"),
|
|
|
|
AliceState::BtcRefunded { .. } => write!(f, "btc_refunded"),
|
|
|
|
AliceState::Punished => write!(f, "punished"),
|
|
|
|
AliceState::SafelyAborted => write!(f, "safely_aborted"),
|
|
|
|
AliceState::BtcPunishable { .. } => write!(f, "btc_punishable"),
|
|
|
|
AliceState::XmrRefunded => write!(f, "xmr_refunded"),
|
2020-12-11 05:49:19 +00:00
|
|
|
AliceState::Cancelling { .. } => write!(f, "cancelling"),
|
2020-12-02 01:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub async fn swap(
|
2020-12-02 01:34:47 +00:00
|
|
|
state: AliceState,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle: EventLoopHandle,
|
2020-12-02 01:34:47 +00:00
|
|
|
bitcoin_wallet: Arc<crate::bitcoin::Wallet>,
|
|
|
|
monero_wallet: Arc<crate::monero::Wallet>,
|
2020-12-02 01:36:47 +00:00
|
|
|
config: Config,
|
2020-12-10 02:19:18 +00:00
|
|
|
) -> Result<(AliceState, EventLoopHandle)> {
|
2020-12-02 01:36:47 +00:00
|
|
|
run_until(
|
|
|
|
state,
|
|
|
|
is_complete,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
2020-12-02 01:34:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn is_complete(state: &AliceState) -> bool {
|
2020-12-02 01:36:47 +00:00
|
|
|
matches!(
|
|
|
|
state,
|
|
|
|
AliceState::XmrRefunded
|
|
|
|
| AliceState::BtcRedeemed
|
|
|
|
| AliceState::Punished
|
|
|
|
| AliceState::SafelyAborted
|
|
|
|
)
|
2020-12-02 01:34:47 +00:00
|
|
|
}
|
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
pub fn is_xmr_locked(state: &AliceState) -> bool {
|
|
|
|
matches!(
|
|
|
|
state,
|
|
|
|
AliceState::XmrLocked{..}
|
|
|
|
)
|
|
|
|
}
|
2020-12-02 01:34:47 +00:00
|
|
|
|
2020-11-27 00:30:07 +00:00
|
|
|
// State machine driver for swap execution
|
|
|
|
#[async_recursion]
|
2020-12-02 01:34:47 +00:00
|
|
|
pub async fn run_until(
|
2020-11-27 00:30:07 +00:00
|
|
|
state: AliceState,
|
2020-12-02 01:36:47 +00:00
|
|
|
is_target_state: fn(&AliceState) -> bool,
|
2020-12-10 02:55:29 +00:00
|
|
|
mut event_loop_handle: EventLoopHandle,
|
2020-11-27 00:30:07 +00:00
|
|
|
bitcoin_wallet: Arc<crate::bitcoin::Wallet>,
|
|
|
|
monero_wallet: Arc<crate::monero::Wallet>,
|
2020-12-01 23:00:00 +00:00
|
|
|
config: Config,
|
2020-12-10 02:19:18 +00:00
|
|
|
) -> Result<(AliceState, EventLoopHandle)> {
|
2020-12-07 02:55:13 +00:00
|
|
|
info!("Current state:{}", state);
|
2020-12-02 01:36:47 +00:00
|
|
|
if is_target_state(&state) {
|
2020-12-10 02:55:29 +00:00
|
|
|
Ok((state, event_loop_handle))
|
2020-12-02 01:34:47 +00:00
|
|
|
} else {
|
|
|
|
match state {
|
2020-12-10 00:18:45 +00:00
|
|
|
AliceState::Started { amounts, state0 } => {
|
2020-12-10 02:55:29 +00:00
|
|
|
let (channel, state3) =
|
|
|
|
negotiate(state0, amounts, &mut event_loop_handle, config).await?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
run_until(
|
|
|
|
AliceState::Negotiated {
|
|
|
|
channel,
|
|
|
|
amounts,
|
|
|
|
state3,
|
|
|
|
},
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
AliceState::Negotiated {
|
|
|
|
state3,
|
2020-11-27 00:30:07 +00:00
|
|
|
channel,
|
|
|
|
amounts,
|
2020-12-02 01:36:47 +00:00
|
|
|
} => {
|
|
|
|
let _ =
|
|
|
|
wait_for_locked_bitcoin(state3.tx_lock.txid(), bitcoin_wallet.clone(), config)
|
|
|
|
.await?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
run_until(
|
|
|
|
AliceState::BtcLocked {
|
|
|
|
channel,
|
|
|
|
amounts,
|
|
|
|
state3,
|
|
|
|
},
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
AliceState::BtcLocked {
|
|
|
|
channel,
|
|
|
|
amounts,
|
|
|
|
state3,
|
|
|
|
} => {
|
|
|
|
lock_xmr(
|
|
|
|
channel,
|
|
|
|
amounts,
|
|
|
|
state3.clone(),
|
2020-12-10 02:55:29 +00:00
|
|
|
&mut event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
monero_wallet.clone(),
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
run_until(
|
|
|
|
AliceState::XmrLocked { state3 },
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
AliceState::XmrLocked { state3 } => {
|
2020-12-14 00:56:14 +00:00
|
|
|
// todo: match statement and wait for t1 can probably be expressed more cleanly
|
2020-12-11 05:49:19 +00:00
|
|
|
match state3.current_epoch(bitcoin_wallet.as_ref()).await? {
|
|
|
|
Epoch::T0 => {
|
|
|
|
let wait_for_enc_sig = wait_for_bitcoin_encrypted_signature(
|
|
|
|
&mut event_loop_handle,
|
|
|
|
config.monero_max_finality_time,
|
|
|
|
);
|
|
|
|
let t1_timeout = state3.wait_for_t1(bitcoin_wallet.as_ref());
|
|
|
|
|
|
|
|
tokio::select! {
|
|
|
|
_ = t1_timeout => {
|
|
|
|
run_until(
|
|
|
|
AliceState::Cancelling { state3 },
|
|
|
|
is_target_state,
|
|
|
|
event_loop_handle,
|
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
enc_sig = wait_for_enc_sig => {
|
|
|
|
run_until(
|
|
|
|
AliceState::EncSignLearned {
|
|
|
|
state3,
|
|
|
|
encrypted_signature: enc_sig?,
|
|
|
|
},
|
|
|
|
is_target_state,
|
|
|
|
event_loop_handle,
|
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
}
|
2020-12-02 01:36:47 +00:00
|
|
|
}
|
2020-12-11 05:49:19 +00:00
|
|
|
_ => {
|
2020-12-02 01:36:47 +00:00
|
|
|
run_until(
|
2020-12-11 05:49:19 +00:00
|
|
|
AliceState::Cancelling { state3 },
|
2020-12-02 01:36:47 +00:00
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
2020-11-27 00:30:07 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-11 05:49:19 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
AliceState::EncSignLearned {
|
|
|
|
state3,
|
2020-11-25 05:27:57 +00:00
|
|
|
encrypted_signature,
|
2020-12-02 01:36:47 +00:00
|
|
|
} => {
|
|
|
|
let signed_tx_redeem = match build_bitcoin_redeem_transaction(
|
|
|
|
encrypted_signature,
|
|
|
|
&state3.tx_lock,
|
|
|
|
state3.a.clone(),
|
|
|
|
state3.s_a,
|
|
|
|
state3.B,
|
|
|
|
&state3.redeem_address,
|
|
|
|
) {
|
|
|
|
Ok(tx) => tx,
|
|
|
|
Err(_) => {
|
|
|
|
return run_until(
|
2020-12-11 05:49:19 +00:00
|
|
|
AliceState::Cancelling { state3 },
|
2020-12-02 01:36:47 +00:00
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await;
|
|
|
|
}
|
|
|
|
};
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
// TODO(Franck): Error handling is delicate here.
|
|
|
|
// If Bob sees this transaction he can redeem Monero
|
|
|
|
// e.g. If the Bitcoin node is down then the user needs to take action.
|
|
|
|
publish_bitcoin_redeem_transaction(
|
|
|
|
signed_tx_redeem,
|
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
config,
|
|
|
|
)
|
2020-12-01 23:00:00 +00:00
|
|
|
.await?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
run_until(
|
|
|
|
AliceState::BtcRedeemed,
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
2020-12-11 05:49:19 +00:00
|
|
|
AliceState::Cancelling { state3 } => {
|
2020-12-02 01:36:47 +00:00
|
|
|
let tx_cancel = publish_cancel_transaction(
|
|
|
|
state3.tx_lock.clone(),
|
|
|
|
state3.a.clone(),
|
|
|
|
state3.B,
|
|
|
|
state3.refund_timelock,
|
|
|
|
state3.tx_cancel_sig_bob.clone(),
|
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
)
|
|
|
|
.await?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
run_until(
|
|
|
|
AliceState::BtcCancelled { state3, tx_cancel },
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet,
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
AliceState::BtcCancelled { state3, tx_cancel } => {
|
|
|
|
let tx_cancel_height = bitcoin_wallet
|
|
|
|
.transaction_block_height(tx_cancel.txid())
|
|
|
|
.await;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
let (tx_refund, published_refund_tx) = wait_for_bitcoin_refund(
|
|
|
|
&tx_cancel,
|
|
|
|
tx_cancel_height,
|
|
|
|
state3.punish_timelock,
|
|
|
|
&state3.refund_address,
|
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
)
|
|
|
|
.await?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
// TODO(Franck): Review error handling
|
|
|
|
match published_refund_tx {
|
|
|
|
None => {
|
|
|
|
run_until(
|
|
|
|
AliceState::BtcPunishable { tx_refund, state3 },
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
Some(published_refund_tx) => {
|
|
|
|
run_until(
|
|
|
|
AliceState::BtcRefunded {
|
|
|
|
tx_refund,
|
|
|
|
published_refund_tx,
|
|
|
|
state3,
|
|
|
|
},
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
2020-11-27 00:30:07 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-02 01:36:47 +00:00
|
|
|
AliceState::BtcRefunded {
|
2020-11-25 05:27:57 +00:00
|
|
|
tx_refund,
|
2020-12-02 01:36:47 +00:00
|
|
|
published_refund_tx,
|
|
|
|
state3,
|
|
|
|
} => {
|
|
|
|
let spend_key = extract_monero_private_key(
|
|
|
|
published_refund_tx,
|
|
|
|
tx_refund,
|
|
|
|
state3.s_a,
|
|
|
|
state3.a.clone(),
|
|
|
|
state3.S_b_bitcoin,
|
|
|
|
)?;
|
|
|
|
let view_key = state3.v;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
monero_wallet
|
|
|
|
.create_and_load_wallet_for_output(spend_key, view_key)
|
|
|
|
.await?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-10 02:55:29 +00:00
|
|
|
Ok((AliceState::XmrRefunded, event_loop_handle))
|
2020-12-02 01:36:47 +00:00
|
|
|
}
|
|
|
|
AliceState::BtcPunishable { tx_refund, state3 } => {
|
|
|
|
let signed_tx_punish = build_bitcoin_punish_transaction(
|
|
|
|
&state3.tx_lock,
|
|
|
|
state3.refund_timelock,
|
|
|
|
&state3.punish_address,
|
|
|
|
state3.punish_timelock,
|
|
|
|
state3.tx_punish_sig_bob.clone(),
|
|
|
|
state3.a.clone(),
|
|
|
|
state3.B,
|
|
|
|
)?;
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
let punish_tx_finalised = publish_bitcoin_punish_transaction(
|
|
|
|
signed_tx_punish,
|
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
config,
|
|
|
|
);
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
let refund_tx_seen = bitcoin_wallet.watch_for_raw_transaction(tx_refund.txid());
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
pin_mut!(punish_tx_finalised);
|
|
|
|
pin_mut!(refund_tx_seen);
|
2020-11-27 00:30:07 +00:00
|
|
|
|
2020-12-02 01:36:47 +00:00
|
|
|
match select(punish_tx_finalised, refund_tx_seen).await {
|
|
|
|
Either::Left(_) => {
|
|
|
|
run_until(
|
|
|
|
AliceState::Punished,
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
|
|
|
Either::Right((published_refund_tx, _)) => {
|
|
|
|
run_until(
|
|
|
|
AliceState::BtcRefunded {
|
|
|
|
tx_refund,
|
|
|
|
published_refund_tx,
|
|
|
|
state3,
|
|
|
|
},
|
|
|
|
is_target_state,
|
2020-12-10 02:55:29 +00:00
|
|
|
event_loop_handle,
|
2020-12-02 01:36:47 +00:00
|
|
|
bitcoin_wallet.clone(),
|
|
|
|
monero_wallet,
|
|
|
|
config,
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
}
|
2020-11-27 00:30:07 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-10 02:55:29 +00:00
|
|
|
AliceState::XmrRefunded => Ok((AliceState::XmrRefunded, event_loop_handle)),
|
|
|
|
AliceState::BtcRedeemed => Ok((AliceState::BtcRedeemed, event_loop_handle)),
|
|
|
|
AliceState::Punished => Ok((AliceState::Punished, event_loop_handle)),
|
|
|
|
AliceState::SafelyAborted => Ok((AliceState::SafelyAborted, event_loop_handle)),
|
2020-11-27 00:30:07 +00:00
|
|
|
}
|
2020-12-02 01:34:47 +00:00
|
|
|
}
|
2020-11-27 00:30:07 +00:00
|
|
|
}
|