diff --git a/moksha-mint/src/error.rs b/moksha-mint/src/error.rs index 09d98b11..0ad7a16d 100644 --- a/moksha-mint/src/error.rs +++ b/moksha-mint/src/error.rs @@ -5,7 +5,7 @@ use axum::{ response::{IntoResponse, Response}, Json, }; -use fedimint_tonic_lnd::ConnectError; +use fedimint_tonic_lnd::{tonic::Status, ConnectError}; use lightning_invoice::ParseOrSemanticError; use moksha_core::primitives::CurrencyUnit; @@ -76,6 +76,9 @@ pub enum MokshaMintError { #[error("Not Enough tokens: {0}")] NotEnoughTokens(String), + + #[error("BtcOnchain error: {0}")] + BtcOnchain(#[from] Status), } impl IntoResponse for MokshaMintError { diff --git a/moksha-mint/src/onchain/mod.rs b/moksha-mint/src/onchain/mod.rs index 80332849..d7d5ab24 100644 --- a/moksha-mint/src/onchain/mod.rs +++ b/moksha-mint/src/onchain/mod.rs @@ -97,8 +97,7 @@ impl Onchain for LndOnchain { .await .expect("failed to lock wallet") .list_unspent(request) - .await - .expect("failed to get response"); + .await?; Ok(response .get_ref() @@ -124,8 +123,7 @@ impl Onchain for LndOnchain { .await .expect("failed to lock wallet") .list_unspent(request) - .await - .expect("failed to get response"); + .await?; Ok(response.get_ref().utxos.iter().any(|utxo| { utxo.address == address @@ -140,11 +138,7 @@ impl Onchain for LndOnchain { r#type: AddressType::WitnessPubkeyHash as i32, ..Default::default() }); - Ok(response - .await - .expect("failed to create address") - .into_inner() - .address) + Ok(response.await?.into_inner().address) } async fn send_coins( @@ -163,8 +157,7 @@ impl Onchain for LndOnchain { sat_per_vbyte: sat_per_vbyte as u64, ..Default::default() }) - .await - .expect("failed to send coins"); + .await?; Ok(SendCoinsResult { txid: response.into_inner().txid, @@ -187,8 +180,7 @@ impl Onchain for LndOnchain { target_conf: 1, ..Default::default() }) - .await - .expect("failed to estimate fee") + .await? .into_inner(); Ok(EstimateFeeResult {