|
|
|
@ -70,14 +70,14 @@ async fn run_until_internal(
|
|
|
|
|
) -> Result<AliceState> {
|
|
|
|
|
info!("Current state: {}", state);
|
|
|
|
|
if is_target_state(&state) {
|
|
|
|
|
Ok(state)
|
|
|
|
|
} else {
|
|
|
|
|
return Ok(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
match state {
|
|
|
|
|
AliceState::Started { state3 } => {
|
|
|
|
|
timeout(
|
|
|
|
|
env_config.bob_time_to_act,
|
|
|
|
|
bitcoin_wallet
|
|
|
|
|
.watch_until_status(&state3.tx_lock, |status| status.has_been_seen()),
|
|
|
|
|
bitcoin_wallet.watch_until_status(&state3.tx_lock, |status| status.has_been_seen()),
|
|
|
|
|
)
|
|
|
|
|
.await
|
|
|
|
|
.context("Failed to find lock Bitcoin tx")??;
|
|
|
|
@ -267,11 +267,7 @@ async fn run_until_internal(
|
|
|
|
|
.is_err()
|
|
|
|
|
{
|
|
|
|
|
let transaction = tx_cancel
|
|
|
|
|
.complete_as_alice(
|
|
|
|
|
state3.a.clone(),
|
|
|
|
|
state3.B,
|
|
|
|
|
state3.tx_cancel_sig_bob.clone(),
|
|
|
|
|
)
|
|
|
|
|
.complete_as_alice(state3.a.clone(), state3.B, state3.tx_cancel_sig_bob.clone())
|
|
|
|
|
.context("Failed to complete Bitcoin cancel transaction")?;
|
|
|
|
|
|
|
|
|
|
if let Err(e) = bitcoin_wallet.broadcast(transaction, "cancel").await {
|
|
|
|
@ -314,8 +310,7 @@ async fn run_until_internal(
|
|
|
|
|
let seen_refund_tx =
|
|
|
|
|
bitcoin_wallet.watch_until_status(&tx_refund, |status| status.has_been_seen());
|
|
|
|
|
|
|
|
|
|
let punish_timelock_expired = bitcoin_wallet
|
|
|
|
|
.watch_until_status(&tx_cancel, |status| {
|
|
|
|
|
let punish_timelock_expired = bitcoin_wallet.watch_until_status(&tx_cancel, |status| {
|
|
|
|
|
status.is_confirmed_with(state3.punish_timelock)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -389,8 +384,7 @@ async fn run_until_internal(
|
|
|
|
|
)?;
|
|
|
|
|
|
|
|
|
|
let punish_tx_finalised = async {
|
|
|
|
|
let (txid, finality) =
|
|
|
|
|
bitcoin_wallet.broadcast(signed_tx_punish, "punish").await?;
|
|
|
|
|
let (txid, finality) = bitcoin_wallet.broadcast(signed_tx_punish, "punish").await?;
|
|
|
|
|
|
|
|
|
|
finality.await?;
|
|
|
|
|
|
|
|
|
@ -462,5 +456,4 @@ async fn run_until_internal(
|
|
|
|
|
AliceState::BtcPunished => Ok(AliceState::BtcPunished),
|
|
|
|
|
AliceState::SafelyAborted => Ok(AliceState::SafelyAborted),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|