From 5930af35875223de7665bfdf363a9d1deef80c22 Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Fri, 6 Nov 2020 15:40:56 +1100 Subject: [PATCH] Move some things around in recover module --- swap/src/recover.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/swap/src/recover.rs b/swap/src/recover.rs index 37722463..21f34355 100644 --- a/swap/src/recover.rs +++ b/swap/src/recover.rs @@ -79,9 +79,10 @@ pub async fn alice_recover( bitcoin_wallet .broadcast_signed_transaction(tx_cancel) .await?; - info!("Successfully published Bitcoin cancel transaction"); } + info!("Confirmed that Bitcoin cancel transaction is on the blockchain"); + let tx_cancel_height = bitcoin_wallet .transaction_block_height(tx_cancel.txid()) .await; @@ -103,6 +104,10 @@ pub async fn alice_recover( Either::Left((tx_refund_published, ..)) => { info!("Found Bitcoin refund transaction"); + let s_a = monero::PrivateKey { + scalar: state.s_a.into_ed25519(), + }; + let tx_refund_sig = tx_refund .extract_signature_by_key(tx_refund_published, state.a.public())?; let tx_refund_encsig = state @@ -118,10 +123,6 @@ pub async fn alice_recover( xmr_btc::monero::Scalar::from_bytes_mod_order(s_b.to_bytes()), ); - let s_a = monero::PrivateKey { - scalar: state.s_a.into_ed25519(), - }; - monero_wallet .create_and_load_wallet_for_output(s_a + s_b, state.v) .await?; @@ -200,9 +201,10 @@ pub async fn alice_recover( bitcoin_wallet .broadcast_signed_transaction(tx_cancel) .await?; - info!("Successfully published Bitcoin cancel transaction"); } + info!("Confirmed that Bitcoin cancel transaction is on the blockchain"); + let tx_cancel_height = bitcoin_wallet .transaction_block_height(tx_cancel.txid()) .await; @@ -224,6 +226,10 @@ pub async fn alice_recover( Either::Left((tx_refund_published, ..)) => { info!("Found Bitcoin refund transaction"); + let s_a = monero::PrivateKey { + scalar: state.s_a.into_ed25519(), + }; + let tx_refund_sig = tx_refund .extract_signature_by_key(tx_refund_published, state.a.public())?; let tx_refund_encsig = state @@ -239,10 +245,6 @@ pub async fn alice_recover( xmr_btc::monero::Scalar::from_bytes_mod_order(s_b.to_bytes()), ); - let s_a = monero::PrivateKey { - scalar: state.s_a.into_ed25519(), - }; - monero_wallet .create_and_load_wallet_for_output(s_a + s_b, state.v) .await?;