Skip to content

Commit

Permalink
Fix processing of the init network flag (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 committed Mar 26, 2024
1 parent e5a650e commit 011f13a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions lib/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ pub struct Wallet {

impl Wallet {
pub fn init(mnemonic: &str, data_dir: Option<String>, network: Network) -> Result<Arc<Wallet>> {
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}"))?;

Expand Down Expand Up @@ -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 })
}
Expand Down

0 comments on commit 011f13a

Please sign in to comment.