mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-18 04:14:32 -05:00
Rename ImportOutput to reflect purpose
This commit is contained in:
parent
213034dc1f
commit
36ed3a0b8b
@ -2,7 +2,7 @@ use crate::{
|
|||||||
bitcoin,
|
bitcoin,
|
||||||
bitcoin::{BroadcastSignedTransaction, WatchForRawTransaction},
|
bitcoin::{BroadcastSignedTransaction, WatchForRawTransaction},
|
||||||
bob, monero,
|
bob, monero,
|
||||||
monero::{ImportOutput, Transfer},
|
monero::{CreateWalletForOutput, Transfer},
|
||||||
transport::SendReceive,
|
transport::SendReceive,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
@ -20,7 +20,7 @@ pub use message::{Message, Message0, Message1, Message2, UnexpectedMessage};
|
|||||||
pub async fn next_state<
|
pub async fn next_state<
|
||||||
R: RngCore + CryptoRng,
|
R: RngCore + CryptoRng,
|
||||||
B: WatchForRawTransaction + BroadcastSignedTransaction,
|
B: WatchForRawTransaction + BroadcastSignedTransaction,
|
||||||
M: ImportOutput + Transfer,
|
M: CreateWalletForOutput + Transfer,
|
||||||
T: SendReceive<Message, bob::Message>,
|
T: SendReceive<Message, bob::Message>,
|
||||||
>(
|
>(
|
||||||
bitcoin_wallet: &B,
|
bitcoin_wallet: &B,
|
||||||
@ -582,7 +582,7 @@ impl State5 {
|
|||||||
pub async fn refund_xmr<B, M>(self, bitcoin_wallet: &B, monero_wallet: &M) -> Result<()>
|
pub async fn refund_xmr<B, M>(self, bitcoin_wallet: &B, monero_wallet: &M) -> Result<()>
|
||||||
where
|
where
|
||||||
B: WatchForRawTransaction,
|
B: WatchForRawTransaction,
|
||||||
M: ImportOutput,
|
M: CreateWalletForOutput,
|
||||||
{
|
{
|
||||||
let tx_cancel = bitcoin::TxCancel::new(
|
let tx_cancel = bitcoin::TxCancel::new(
|
||||||
&self.tx_lock,
|
&self.tx_lock,
|
||||||
@ -611,7 +611,7 @@ impl State5 {
|
|||||||
// NOTE: This actually generates and opens a new wallet, closing the currently
|
// NOTE: This actually generates and opens a new wallet, closing the currently
|
||||||
// open one.
|
// open one.
|
||||||
monero_wallet
|
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?;
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -5,7 +5,7 @@ use crate::{
|
|||||||
WatchForRawTransaction,
|
WatchForRawTransaction,
|
||||||
},
|
},
|
||||||
monero,
|
monero,
|
||||||
monero::{CheckTransfer, ImportOutput},
|
monero::{CheckTransfer, CreateWalletForOutput},
|
||||||
transport::SendReceive,
|
transport::SendReceive,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
@ -24,7 +24,7 @@ pub use message::{Message, Message0, Message1, Message2, Message3, UnexpectedMes
|
|||||||
pub async fn next_state<
|
pub async fn next_state<
|
||||||
R: RngCore + CryptoRng,
|
R: RngCore + CryptoRng,
|
||||||
B: WatchForRawTransaction + SignTxLock + BuildTxLockPsbt + BroadcastSignedTransaction,
|
B: WatchForRawTransaction + SignTxLock + BuildTxLockPsbt + BroadcastSignedTransaction,
|
||||||
M: ImportOutput + CheckTransfer,
|
M: CreateWalletForOutput + CheckTransfer,
|
||||||
T: SendReceive<Message, alice::Message>,
|
T: SendReceive<Message, alice::Message>,
|
||||||
>(
|
>(
|
||||||
bitcoin_wallet: &B,
|
bitcoin_wallet: &B,
|
||||||
@ -559,7 +559,7 @@ pub struct State5 {
|
|||||||
impl State5 {
|
impl State5 {
|
||||||
pub async fn claim_xmr<W>(&self, monero_wallet: &W) -> Result<()>
|
pub async fn claim_xmr<W>(&self, monero_wallet: &W) -> Result<()>
|
||||||
where
|
where
|
||||||
W: monero::ImportOutput,
|
W: monero::CreateWalletForOutput,
|
||||||
{
|
{
|
||||||
let s_b = monero::PrivateKey {
|
let s_b = monero::PrivateKey {
|
||||||
scalar: self.s_b.into_ed25519(),
|
scalar: self.s_b.into_ed25519(),
|
||||||
@ -569,7 +569,9 @@ impl State5 {
|
|||||||
|
|
||||||
// NOTE: This actually generates and opens a new wallet, closing the currently
|
// NOTE: This actually generates and opens a new wallet, closing the currently
|
||||||
// open one.
|
// open one.
|
||||||
monero_wallet.import_output(s, self.v).await?;
|
monero_wallet
|
||||||
|
.create_and_load_wallet_for_output(s, self.v)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -122,8 +122,8 @@ pub trait CheckTransfer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait ImportOutput {
|
pub trait CreateWalletForOutput {
|
||||||
async fn import_output(
|
async fn create_and_load_wallet_for_output(
|
||||||
&self,
|
&self,
|
||||||
private_spend_key: PrivateKey,
|
private_spend_key: PrivateKey,
|
||||||
private_view_key: PrivateViewKey,
|
private_view_key: PrivateViewKey,
|
||||||
|
@ -4,8 +4,8 @@ use monero::{Address, Network, PrivateKey};
|
|||||||
use monero_harness::Monero;
|
use monero_harness::Monero;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use xmr_btc::monero::{
|
use xmr_btc::monero::{
|
||||||
Amount, CheckTransfer, ImportOutput, PrivateViewKey, PublicKey, PublicViewKey, Transfer,
|
Amount, CheckTransfer, CreateWalletForOutput, PrivateViewKey, PublicKey, PublicViewKey,
|
||||||
TransferProof, TxHash,
|
Transfer, TransferProof, TxHash,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -37,8 +37,8 @@ impl Transfer for AliceWallet<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl ImportOutput for AliceWallet<'_> {
|
impl CreateWalletForOutput for AliceWallet<'_> {
|
||||||
async fn import_output(
|
async fn create_and_load_wallet_for_output(
|
||||||
&self,
|
&self,
|
||||||
private_spend_key: PrivateKey,
|
private_spend_key: PrivateKey,
|
||||||
private_view_key: PrivateViewKey,
|
private_view_key: PrivateViewKey,
|
||||||
@ -99,8 +99,8 @@ impl CheckTransfer for BobWallet<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl ImportOutput for BobWallet<'_> {
|
impl CreateWalletForOutput for BobWallet<'_> {
|
||||||
async fn import_output(
|
async fn create_and_load_wallet_for_output(
|
||||||
&self,
|
&self,
|
||||||
private_spend_key: PrivateKey,
|
private_spend_key: PrivateKey,
|
||||||
private_view_key: PrivateViewKey,
|
private_view_key: PrivateViewKey,
|
||||||
|
Loading…
Reference in New Issue
Block a user