Move some things around in recover module

This commit is contained in:
Lucas Soriano del Pino 2020-11-06 15:40:56 +11:00 committed by rishflab
parent 33b36c98fa
commit 5930af3587

View File

@ -79,9 +79,10 @@ pub async fn alice_recover(
bitcoin_wallet bitcoin_wallet
.broadcast_signed_transaction(tx_cancel) .broadcast_signed_transaction(tx_cancel)
.await?; .await?;
info!("Successfully published Bitcoin cancel transaction");
} }
info!("Confirmed that Bitcoin cancel transaction is on the blockchain");
let tx_cancel_height = bitcoin_wallet let tx_cancel_height = bitcoin_wallet
.transaction_block_height(tx_cancel.txid()) .transaction_block_height(tx_cancel.txid())
.await; .await;
@ -103,6 +104,10 @@ pub async fn alice_recover(
Either::Left((tx_refund_published, ..)) => { Either::Left((tx_refund_published, ..)) => {
info!("Found Bitcoin refund transaction"); info!("Found Bitcoin refund transaction");
let s_a = monero::PrivateKey {
scalar: state.s_a.into_ed25519(),
};
let tx_refund_sig = tx_refund let tx_refund_sig = tx_refund
.extract_signature_by_key(tx_refund_published, state.a.public())?; .extract_signature_by_key(tx_refund_published, state.a.public())?;
let tx_refund_encsig = state 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()), 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 monero_wallet
.create_and_load_wallet_for_output(s_a + s_b, state.v) .create_and_load_wallet_for_output(s_a + s_b, state.v)
.await?; .await?;
@ -200,9 +201,10 @@ pub async fn alice_recover(
bitcoin_wallet bitcoin_wallet
.broadcast_signed_transaction(tx_cancel) .broadcast_signed_transaction(tx_cancel)
.await?; .await?;
info!("Successfully published Bitcoin cancel transaction");
} }
info!("Confirmed that Bitcoin cancel transaction is on the blockchain");
let tx_cancel_height = bitcoin_wallet let tx_cancel_height = bitcoin_wallet
.transaction_block_height(tx_cancel.txid()) .transaction_block_height(tx_cancel.txid())
.await; .await;
@ -224,6 +226,10 @@ pub async fn alice_recover(
Either::Left((tx_refund_published, ..)) => { Either::Left((tx_refund_published, ..)) => {
info!("Found Bitcoin refund transaction"); info!("Found Bitcoin refund transaction");
let s_a = monero::PrivateKey {
scalar: state.s_a.into_ed25519(),
};
let tx_refund_sig = tx_refund let tx_refund_sig = tx_refund
.extract_signature_by_key(tx_refund_published, state.a.public())?; .extract_signature_by_key(tx_refund_published, state.a.public())?;
let tx_refund_encsig = state 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()), 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 monero_wallet
.create_and_load_wallet_for_output(s_a + s_b, state.v) .create_and_load_wallet_for_output(s_a + s_b, state.v)
.await?; .await?;