From 382dcb8a4966870bdbe00aa7968a2d95d4d8917a Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Sat, 23 Mar 2024 08:48:19 +0100 Subject: [PATCH] Fix processing of the init network flag --- lib/src/model.rs | 4 ++-- lib/src/wallet.rs | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/model.rs b/lib/src/model.rs index a1efa528a..2b64e2908 100644 --- a/lib/src/model.rs +++ b/lib/src/model.rs @@ -76,8 +76,8 @@ pub enum SwapError { #[error("The specified invoice is not valid")] InvalidInvoice, - #[error("Could not sign/send the transaction")] - SendError, + #[error("Could not sign/send the transaction: {err}")] + SendError { err: String }, #[error("Could not fetch the required wallet information")] WalletError, diff --git a/lib/src/wallet.rs b/lib/src/wallet.rs index 5b307d5b0..95873c3fc 100644 --- a/lib/src/wallet.rs +++ b/lib/src/wallet.rs @@ -40,12 +40,13 @@ pub struct Wallet { impl Wallet { pub fn init(mnemonic: &str, data_dir: Option, network: Network) -> Result> { - let signer = SwSigner::new(mnemonic, network == Network::Liquid)?; + let is_mainnet = network == Network::Liquid; + let signer = SwSigner::new(mnemonic, is_mainnet)?; let descriptor = singlesig_desc( &signer, Singlesig::Wpkh, lwk_common::DescriptorBlindingKey::Slip77, - false, + is_mainnet, ) .map_err(|e| anyhow!("Invalid descriptor: {e}"))?; @@ -225,7 +226,7 @@ impl Wallet { let txid = self .sign_and_send(&[signer], None, &funding_addr, funding_amount) - .map_err(|_| SwapError::SendError)?; + .map_err(|e| SwapError::SendError { err: e.to_string() })?; Ok(SendPaymentResponse { txid }) }