diff --git a/swap/src/monero.rs b/swap/src/monero.rs index d086cfa7..77b7dae9 100644 --- a/swap/src/monero.rs +++ b/swap/src/monero.rs @@ -175,6 +175,12 @@ impl From for String { } } +impl fmt::Display for TxHash { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{}", self.0) + } +} + #[derive(Debug, Clone, Copy, thiserror::Error)] #[error("transaction does not pay enough: expected {expected}, got {actual}")] pub struct InsufficientFunds { diff --git a/swap/src/monero/wallet.rs b/swap/src/monero/wallet.rs index 11514ff9..44f1b8f8 100644 --- a/swap/src/monero/wallet.rs +++ b/swap/src/monero/wallet.rs @@ -160,7 +160,7 @@ impl Wallet { expected_amount: Amount, conf_target: u32, ) -> Result<(), InsufficientFunds> { - let txid = &transfer_proof.tx_hash.0; + let txid = &transfer_proof.tx_hash(); tracing::info!(%txid, "Waiting for {} confirmation{} of Monero transaction", conf_target, if conf_target > 1 { "s" } else { "" }); diff --git a/swap/src/protocol/bob/swap.rs b/swap/src/protocol/bob/swap.rs index c6eefb7a..30f84ec6 100644 --- a/swap/src/protocol/bob/swap.rs +++ b/swap/src/protocol/bob/swap.rs @@ -133,16 +133,23 @@ async fn run_until_internal( // block 0 once we create the redeem wallet. let monero_wallet_restore_blockheight = monero_wallet.block_height().await?; + tracing::info!("Waiting for Alice to lock Monero"); + select! { transfer_proof = transfer_proof_watcher => { - let transfer_proof = transfer_proof?; + let transfer_proof = transfer_proof?.tx_lock_proof; + + tracing::info!(txid = %transfer_proof.tx_hash(), "Alice locked Monero"); + BobState::XmrLockProofReceived { state: state3, - lock_transfer_proof: transfer_proof.tx_lock_proof, + lock_transfer_proof: transfer_proof, monero_wallet_restore_blockheight } }, _ = cancel_timelock_expires => { + tracing::info!("Alice took too long to lock Monero, cancelling the swap"); + let state4 = state3.cancel(); BobState::CancelTimelockExpired(state4) }