mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-10-01 01:45:40 -04:00
Use -ed
terminology for cancel state
This commit is contained in:
parent
b83ab71669
commit
8cc470a80e
@ -80,7 +80,7 @@ pub enum AliceState {
|
|||||||
state3: State3,
|
state3: State3,
|
||||||
},
|
},
|
||||||
XmrRefunded,
|
XmrRefunded,
|
||||||
Cancelling {
|
T1Expired {
|
||||||
state3: State3,
|
state3: State3,
|
||||||
},
|
},
|
||||||
Punished,
|
Punished,
|
||||||
@ -102,7 +102,7 @@ impl fmt::Display for AliceState {
|
|||||||
AliceState::SafelyAborted => write!(f, "safely_aborted"),
|
AliceState::SafelyAborted => write!(f, "safely_aborted"),
|
||||||
AliceState::BtcPunishable { .. } => write!(f, "btc_punishable"),
|
AliceState::BtcPunishable { .. } => write!(f, "btc_punishable"),
|
||||||
AliceState::XmrRefunded => write!(f, "xmr_refunded"),
|
AliceState::XmrRefunded => write!(f, "xmr_refunded"),
|
||||||
AliceState::Cancelling { .. } => write!(f, "cancelling"),
|
AliceState::T1Expired { .. } => write!(f, "t1 is expired"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ impl From<&AliceState> for state::Alice {
|
|||||||
AliceState::BtcRefunded { .. } => Alice::SwapComplete,
|
AliceState::BtcRefunded { .. } => Alice::SwapComplete,
|
||||||
AliceState::BtcPunishable { state3, .. } => Alice::BtcPunishable(state3.clone()),
|
AliceState::BtcPunishable { state3, .. } => Alice::BtcPunishable(state3.clone()),
|
||||||
AliceState::XmrRefunded => Alice::SwapComplete,
|
AliceState::XmrRefunded => Alice::SwapComplete,
|
||||||
AliceState::Cancelling { state3 } => Alice::Cancelling(state3.clone()),
|
AliceState::T1Expired { state3 } => Alice::T1Expired(state3.clone()),
|
||||||
AliceState::Punished => Alice::SwapComplete,
|
AliceState::Punished => Alice::SwapComplete,
|
||||||
AliceState::SafelyAborted => Alice::SwapComplete,
|
AliceState::SafelyAborted => Alice::SwapComplete,
|
||||||
// TODO: Potentially add support to recover swaps that are not Negotiated
|
// TODO: Potentially add support to recover swaps that are not Negotiated
|
||||||
@ -168,7 +168,7 @@ impl TryFrom<state::Swap> for AliceState {
|
|||||||
state3: state,
|
state3: state,
|
||||||
encrypted_signature,
|
encrypted_signature,
|
||||||
},
|
},
|
||||||
Alice::Cancelling(state3) => AliceState::Cancelling { state3 },
|
Alice::T1Expired(state3) => AliceState::T1Expired { state3 },
|
||||||
Alice::BtcCancelled(state) => {
|
Alice::BtcCancelled(state) => {
|
||||||
let tx_cancel = bitcoin::TxCancel::new(
|
let tx_cancel = bitcoin::TxCancel::new(
|
||||||
&state.tx_lock,
|
&state.tx_lock,
|
||||||
@ -425,14 +425,14 @@ pub async fn run_until(
|
|||||||
pin_mut!(t1_timeout);
|
pin_mut!(t1_timeout);
|
||||||
|
|
||||||
match select(t1_timeout, wait_for_enc_sig).await {
|
match select(t1_timeout, wait_for_enc_sig).await {
|
||||||
Either::Left(_) => AliceState::Cancelling { state3 },
|
Either::Left(_) => AliceState::T1Expired { state3 },
|
||||||
Either::Right((enc_sig, _)) => AliceState::EncSignLearned {
|
Either::Right((enc_sig, _)) => AliceState::EncSignLearned {
|
||||||
state3,
|
state3,
|
||||||
encrypted_signature: enc_sig?,
|
encrypted_signature: enc_sig?,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => AliceState::Cancelling { state3 },
|
_ => AliceState::T1Expired { state3 },
|
||||||
};
|
};
|
||||||
|
|
||||||
let db_state = (&state).into();
|
let db_state = (&state).into();
|
||||||
@ -464,7 +464,9 @@ pub async fn run_until(
|
|||||||
) {
|
) {
|
||||||
Ok(tx) => tx,
|
Ok(tx) => tx,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
let state = AliceState::Cancelling { state3 };
|
state3.wait_for_t1(bitcoin_wallet.as_ref()).await?;
|
||||||
|
|
||||||
|
let state = AliceState::T1Expired { state3 };
|
||||||
let db_state = (&state).into();
|
let db_state = (&state).into();
|
||||||
db.insert_latest_state(swap_id, Swap::Alice(db_state))
|
db.insert_latest_state(swap_id, Swap::Alice(db_state))
|
||||||
.await?;
|
.await?;
|
||||||
@ -508,7 +510,7 @@ pub async fn run_until(
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
AliceState::Cancelling { state3 } => {
|
AliceState::T1Expired { state3 } => {
|
||||||
let tx_cancel = publish_cancel_transaction(
|
let tx_cancel = publish_cancel_transaction(
|
||||||
state3.tx_lock.clone(),
|
state3.tx_lock.clone(),
|
||||||
state3.a.clone(),
|
state3.a.clone(),
|
||||||
|
@ -25,7 +25,7 @@ pub enum Alice {
|
|||||||
state: alice::State3,
|
state: alice::State3,
|
||||||
encrypted_signature: EncryptedSignature,
|
encrypted_signature: EncryptedSignature,
|
||||||
},
|
},
|
||||||
Cancelling(alice::State3),
|
T1Expired(alice::State3),
|
||||||
BtcCancelled(alice::State3),
|
BtcCancelled(alice::State3),
|
||||||
BtcPunishable(alice::State3),
|
BtcPunishable(alice::State3),
|
||||||
BtcRefunded {
|
BtcRefunded {
|
||||||
@ -92,7 +92,7 @@ impl Display for Alice {
|
|||||||
Alice::BtcLocked(_) => f.write_str("Bitcoin locked"),
|
Alice::BtcLocked(_) => f.write_str("Bitcoin locked"),
|
||||||
Alice::XmrLocked(_) => f.write_str("Monero locked"),
|
Alice::XmrLocked(_) => f.write_str("Monero locked"),
|
||||||
Alice::BtcRedeemable { .. } => f.write_str("Bitcoin redeemable"),
|
Alice::BtcRedeemable { .. } => f.write_str("Bitcoin redeemable"),
|
||||||
Alice::Cancelling(_) => f.write_str("Submitting TxCancel"),
|
Alice::T1Expired(_) => f.write_str("Submitting TxCancel"),
|
||||||
Alice::BtcCancelled(_) => f.write_str("Bitcoin cancel transaction published"),
|
Alice::BtcCancelled(_) => f.write_str("Bitcoin cancel transaction published"),
|
||||||
Alice::BtcPunishable(_) => f.write_str("Bitcoin punishable"),
|
Alice::BtcPunishable(_) => f.write_str("Bitcoin punishable"),
|
||||||
Alice::BtcRefunded { .. } => f.write_str("Monero refundable"),
|
Alice::BtcRefunded { .. } => f.write_str("Monero refundable"),
|
||||||
|
Loading…
Reference in New Issue
Block a user