Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix processing of the init network flag #57

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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