Use domain types in fn signature instead of messages

This simplifies usage witin the swap module.
This commit is contained in:
Thomas Eizinger 2021-03-17 16:47:15 +11:00
parent 64b71d0b16
commit 575893fb51
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
2 changed files with 8 additions and 9 deletions

View File

@ -311,21 +311,23 @@ impl LatestRate for kraken::RateUpdateStream {
}
impl EventLoopHandle {
pub async fn recv_encrypted_signature(&mut self) -> Result<EncryptedSignature> {
pub async fn recv_encrypted_signature(&mut self) -> Result<bitcoin::EncryptedSignature> {
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?")

View File

@ -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(