Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ngutech21 committed Feb 8, 2024
1 parent 0b89f9a commit 2ef479d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
5 changes: 4 additions & 1 deletion moksha-mint/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 5 additions & 13 deletions moksha-mint/src/onchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -187,8 +180,7 @@ impl Onchain for LndOnchain {
target_conf: 1,
..Default::default()
})
.await
.expect("failed to estimate fee")
.await?
.into_inner();

Ok(EstimateFeeResult {
Expand Down

0 comments on commit 2ef479d

Please sign in to comment.