mirror of
https://github.com/aljazceru/breez-sdk-liquid.git
synced 2026-01-08 16:44:23 +01:00
Return LsSdkError if getting a wallet instance fails
Add missing import
This commit is contained in:
@@ -3,7 +3,7 @@ pub(crate) use boltz_client::util::secrets::LBtcReverseRecovery;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
use crate::{
|
||||
error::PaymentError,
|
||||
error::{LsSdkError, PaymentError},
|
||||
model::{
|
||||
Network, PrepareReceiveRequest, PrepareReceiveResponse, PrepareSendResponse,
|
||||
ReceivePaymentResponse, SendPaymentResponse, WalletInfo,
|
||||
@@ -32,7 +32,7 @@ pub fn prepare_send_payment(invoice: String) -> Result<PrepareSendResponse, Paym
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.prepare_send_payment(&invoice)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ pub fn send_payment(req: PrepareSendResponse) -> Result<SendPaymentResponse, Pay
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.send_payment(&req)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn prepare_receive_payment(
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.prepare_receive_payment(&req)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ pub fn receive_payment(
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.receive_payment(&req)
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ pub fn list_payments(with_scan: bool, include_pending: bool) -> Result<Vec<Payme
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.list_payments(with_scan, include_pending)
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ pub fn recover_funds(recovery: LBtcReverseRecovery) -> Result<String> {
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.recover_funds(&recovery)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ pub fn empty_wallet_cache() -> Result<()> {
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.empty_wallet_cache()
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ pub fn backup() -> Result<()> {
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.backup()
|
||||
}
|
||||
|
||||
@@ -100,6 +100,6 @@ pub fn restore(backup_path: Option<String>) -> Result<()> {
|
||||
WALLET_INSTANCE
|
||||
.get()
|
||||
.ok_or(anyhow!("Not initialized"))
|
||||
.map_err(|e| PaymentError::Generic { err: e.to_string() })?
|
||||
.map_err(|e| LsSdkError::Generic { err: e.to_string() })?
|
||||
.restore(backup_path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user