Include Bob being inactive as a reason for failure

This commit is contained in:
Lucas Soriano del Pino 2020-10-26 11:33:51 +11:00
parent 41e8c7283c
commit aa2a20916e
2 changed files with 8 additions and 4 deletions

View File

@ -92,13 +92,15 @@ where
{
#[derive(Debug)]
enum SwapFailed {
BeforeBtcLock,
BeforeBtcLock(Reason),
AfterXmrLock { tx_lock_height: u32, reason: Reason },
}
/// Reason why the swap has failed.
#[derive(Debug)]
enum Reason {
/// Bob was too slow to lock the bitcoin.
InactiveBob,
/// Bob's encrypted signature on the Bitcoin redeem transaction is
/// invalid.
InvalidEncryptedSignature,
@ -126,7 +128,7 @@ where
bitcoin_client.watch_for_raw_transaction(tx_lock.txid()),
)
.await
.map_err(|_| SwapFailed::BeforeBtcLock)?;
.map_err(|_| SwapFailed::BeforeBtcLock(Reason::InactiveBob))?;
let tx_lock_height = bitcoin_client
.transaction_block_height(tx_lock.txid())

View File

@ -97,7 +97,7 @@ where
{
#[derive(Debug)]
enum SwapFailed {
BeforeBtcLock,
BeforeBtcLock(Reason),
AfterBtcLock(Reason),
AfterBtcRedeem(Reason),
}
@ -105,6 +105,8 @@ where
/// Reason why the swap has failed.
#[derive(Debug)]
enum Reason {
/// Bob was too slow to lock the bitcoin.
InactiveBob,
/// The refund timelock has been reached.
BtcExpired,
/// Alice did not lock up enough monero in the shared output.
@ -127,7 +129,7 @@ where
)
.await
.map(|tx| tx.txid())
.map_err(|_| SwapFailed::BeforeBtcLock)?;
.map_err(|_| SwapFailed::BeforeBtcLock(Reason::InactiveBob))?;
let tx_lock_height = bitcoin_client
.transaction_block_height(tx_lock.txid())