From 575893fb51f08c7fd0db86454866ef91c91ae230 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Wed, 17 Mar 2021 16:47:15 +1100 Subject: [PATCH] Use domain types in fn signature instead of messages This simplifies usage witin the swap module. --- swap/src/protocol/alice/event_loop.rs | 10 ++++++---- swap/src/protocol/alice/steps.rs | 7 ++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/swap/src/protocol/alice/event_loop.rs b/swap/src/protocol/alice/event_loop.rs index 34b196e5..537a476e 100644 --- a/swap/src/protocol/alice/event_loop.rs +++ b/swap/src/protocol/alice/event_loop.rs @@ -311,21 +311,23 @@ impl LatestRate for kraken::RateUpdateStream { } impl EventLoopHandle { - pub async fn recv_encrypted_signature(&mut self) -> Result { + pub async fn recv_encrypted_signature(&mut self) -> Result { let signature = self .recv_encrypted_signature .take() .context("Encrypted signature was already received")? - .await?; + .await? + .tx_redeem_encsig; Ok(signature) } - pub async fn send_transfer_proof(&mut self, msg: TransferProof) -> Result<()> { + + pub async fn send_transfer_proof(&mut self, msg: monero::TransferProof) -> Result<()> { if self .send_transfer_proof .take() .context("Transfer proof was already sent")? - .send(msg) + .send(TransferProof { tx_lock_proof: msg }) .is_err() { bail!("Failed to send transfer proof, receiver no longer listening?") diff --git a/swap/src/protocol/alice/steps.rs b/swap/src/protocol/alice/steps.rs index 192ca522..a6917539 100644 --- a/swap/src/protocol/alice/steps.rs +++ b/swap/src/protocol/alice/steps.rs @@ -3,7 +3,6 @@ use crate::bitcoin::{ }; use crate::protocol::alice; use crate::protocol::alice::event_loop::EventLoopHandle; -use crate::protocol::alice::TransferProof; use crate::{bitcoin, monero}; use anyhow::{bail, Context, Result}; @@ -27,9 +26,7 @@ pub async fn lock_xmr( // Otherwise Alice might publish the lock tx twice! event_loop_handle - .send_transfer_proof(TransferProof { - tx_lock_proof: transfer_proof, - }) + .send_transfer_proof(transfer_proof) .await?; Ok(()) @@ -45,7 +42,7 @@ pub async fn wait_for_bitcoin_encrypted_signature( tracing::debug!("Message 3 received, returning it"); - Ok(msg3.tx_redeem_encsig) + Ok(msg3) } pub async fn publish_cancel_transaction(