Skip to content
Open
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
228 changes: 228 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions crates/breez-sdk/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ pub enum Command {
#[arg(short = 'r', long)]
payment_request: String,

/// Optional amount to pay in satoshis
/// Optional amount to pay. By default is denominated in sats.
/// If a token identifier is provided, the amount will be denominated in the token base units.
#[arg(short = 'a', long)]
amount: Option<u64>,

/// Optional token identifier. May only be provided if the payment request is a spark address.
#[arg(short = 't', long)]
token_identifier: Option<String>,
},

/// Pay using LNURL
Expand Down Expand Up @@ -278,11 +283,13 @@ pub(crate) async fn execute_command(
Command::Pay {
payment_request,
amount,
token_identifier,
} => {
let prepared_payment = sdk
.prepare_send_payment(PrepareSendPaymentRequest {
payment_request,
amount_sats: amount,
amount,
token_identifier,
})
.await;

Expand Down
2 changes: 2 additions & 0 deletions crates/breez-sdk/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ uuid.workspace = true
uniffi = { workspace = true, optional = true }
web-time.workspace = true
x509-parser = { version = "0.16.0" }
# TODO: switch to published version once CORS issue with `api-version` header is fixed
sparkscan = { git = "https://github.com/breez/sparkscan-rs", rev = "250753cf6c9fd95a79c9f450b1f59534329251ab" }

# Non-Wasm dependencies
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
Expand Down
9 changes: 9 additions & 0 deletions crates/breez-sdk/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub enum SdkError {
#[error("Lnurl error: {0}")]
LnurlError(String),

#[error("SparkScan error: {0}")]
SparkScanApiError(String),

#[error("Error: {0}")]
Generic(String),
}
Expand Down Expand Up @@ -140,6 +143,12 @@ impl From<ServiceConnectivityError> for SdkError {
}
}

impl From<sparkscan::Error<sparkscan::types::HttpValidationError>> for SdkError {
fn from(e: sparkscan::Error<sparkscan::types::HttpValidationError>) -> Self {
SdkError::SparkScanApiError(format!("{e:?}"))
}
}

impl From<LnurlServerError> for SdkError {
fn from(value: LnurlServerError) -> Self {
match value {
Expand Down
Loading