From 36ed3a0b8b917f17c39fd3c39c51a267d36f5164 Mon Sep 17 00:00:00 2001 From: rishflab Date: Thu, 8 Oct 2020 11:27:54 +1100 Subject: [PATCH] Rename ImportOutput to reflect purpose --- xmr-btc/src/alice.rs | 8 ++++---- xmr-btc/src/bob.rs | 10 ++++++---- xmr-btc/src/monero.rs | 4 ++-- xmr-btc/tests/wallet/monero.rs | 12 ++++++------ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/xmr-btc/src/alice.rs b/xmr-btc/src/alice.rs index 4bbb04aa..d6ecbc67 100644 --- a/xmr-btc/src/alice.rs +++ b/xmr-btc/src/alice.rs @@ -2,7 +2,7 @@ use crate::{ bitcoin, bitcoin::{BroadcastSignedTransaction, WatchForRawTransaction}, bob, monero, - monero::{ImportOutput, Transfer}, + monero::{CreateWalletForOutput, Transfer}, transport::SendReceive, }; use anyhow::{anyhow, Result}; @@ -20,7 +20,7 @@ pub use message::{Message, Message0, Message1, Message2, UnexpectedMessage}; pub async fn next_state< R: RngCore + CryptoRng, B: WatchForRawTransaction + BroadcastSignedTransaction, - M: ImportOutput + Transfer, + M: CreateWalletForOutput + Transfer, T: SendReceive, >( bitcoin_wallet: &B, @@ -582,7 +582,7 @@ impl State5 { pub async fn refund_xmr(self, bitcoin_wallet: &B, monero_wallet: &M) -> Result<()> where B: WatchForRawTransaction, - M: ImportOutput, + M: CreateWalletForOutput, { let tx_cancel = bitcoin::TxCancel::new( &self.tx_lock, @@ -611,7 +611,7 @@ impl State5 { // NOTE: This actually generates and opens a new wallet, closing the currently // open one. monero_wallet - .import_output(monero::PrivateKey::from_scalar(s), self.v) + .create_and_load_wallet_for_output(monero::PrivateKey::from_scalar(s), self.v) .await?; Ok(()) diff --git a/xmr-btc/src/bob.rs b/xmr-btc/src/bob.rs index 53bf1431..44a8a407 100644 --- a/xmr-btc/src/bob.rs +++ b/xmr-btc/src/bob.rs @@ -5,7 +5,7 @@ use crate::{ WatchForRawTransaction, }, monero, - monero::{CheckTransfer, ImportOutput}, + monero::{CheckTransfer, CreateWalletForOutput}, transport::SendReceive, }; use anyhow::{anyhow, Result}; @@ -24,7 +24,7 @@ pub use message::{Message, Message0, Message1, Message2, Message3, UnexpectedMes pub async fn next_state< R: RngCore + CryptoRng, B: WatchForRawTransaction + SignTxLock + BuildTxLockPsbt + BroadcastSignedTransaction, - M: ImportOutput + CheckTransfer, + M: CreateWalletForOutput + CheckTransfer, T: SendReceive, >( bitcoin_wallet: &B, @@ -559,7 +559,7 @@ pub struct State5 { impl State5 { pub async fn claim_xmr(&self, monero_wallet: &W) -> Result<()> where - W: monero::ImportOutput, + W: monero::CreateWalletForOutput, { let s_b = monero::PrivateKey { scalar: self.s_b.into_ed25519(), @@ -569,7 +569,9 @@ impl State5 { // NOTE: This actually generates and opens a new wallet, closing the currently // open one. - monero_wallet.import_output(s, self.v).await?; + monero_wallet + .create_and_load_wallet_for_output(s, self.v) + .await?; Ok(()) } diff --git a/xmr-btc/src/monero.rs b/xmr-btc/src/monero.rs index d4832f1b..459fa708 100644 --- a/xmr-btc/src/monero.rs +++ b/xmr-btc/src/monero.rs @@ -122,8 +122,8 @@ pub trait CheckTransfer { } #[async_trait] -pub trait ImportOutput { - async fn import_output( +pub trait CreateWalletForOutput { + async fn create_and_load_wallet_for_output( &self, private_spend_key: PrivateKey, private_view_key: PrivateViewKey, diff --git a/xmr-btc/tests/wallet/monero.rs b/xmr-btc/tests/wallet/monero.rs index 6f47d3b4..ca5e9039 100644 --- a/xmr-btc/tests/wallet/monero.rs +++ b/xmr-btc/tests/wallet/monero.rs @@ -4,8 +4,8 @@ use monero::{Address, Network, PrivateKey}; use monero_harness::Monero; use std::str::FromStr; use xmr_btc::monero::{ - Amount, CheckTransfer, ImportOutput, PrivateViewKey, PublicKey, PublicViewKey, Transfer, - TransferProof, TxHash, + Amount, CheckTransfer, CreateWalletForOutput, PrivateViewKey, PublicKey, PublicViewKey, + Transfer, TransferProof, TxHash, }; #[derive(Debug)] @@ -37,8 +37,8 @@ impl Transfer for AliceWallet<'_> { } #[async_trait] -impl ImportOutput for AliceWallet<'_> { - async fn import_output( +impl CreateWalletForOutput for AliceWallet<'_> { + async fn create_and_load_wallet_for_output( &self, private_spend_key: PrivateKey, private_view_key: PrivateViewKey, @@ -99,8 +99,8 @@ impl CheckTransfer for BobWallet<'_> { } #[async_trait] -impl ImportOutput for BobWallet<'_> { - async fn import_output( +impl CreateWalletForOutput for BobWallet<'_> { + async fn create_and_load_wallet_for_output( &self, private_spend_key: PrivateKey, private_view_key: PrivateViewKey,