Skip to content

Commit 262ecae

Browse files
committed
Update to latest spark sdk release
1 parent 5342ae9 commit 262ecae

File tree

3 files changed

+471
-22
lines changed

3 files changed

+471
-22
lines changed

orange-sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ lightning-macros = "0.2.0"
2828
bitcoin-payment-instructions = { workspace = true, features = ["http"] }
2929
chrono = { version = "0.4", default-features = false }
3030
rand = { version = "0.8.5", optional = true }
31-
breez-sdk-spark = { git = "https://github.com/breez/spark-sdk.git", rev = "ef76a0bc517bea38fafaff8f657e82b5b52569b9", default-features = false, features = ["rustls-tls"], optional = true }
31+
breez-sdk-spark = { git = "https://github.com/breez/spark-sdk.git", rev = "1000f276d2f16592b5f6eb8fce29228f34ff88bf", default-features = false, optional = true }
3232
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "sync", "macros"] }
3333
uuid = { version = "1.0", default-features = false, optional = true }
3434
cdk = { version = "0.15.1", default-features = false, features = ["wallet"], optional = true }

orange-sdk/src/trusted_wallet/spark/mod.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ impl SparkWalletConfig {
8585
lnurl_domain: self.lnurl_domain,
8686
private_enabled_default: true,
8787
optimization_config: OptimizationConfig { auto_enabled: true, multiplicity: 1 },
88+
stable_balance_config: None,
89+
max_concurrent_claims: 4,
90+
support_lnurl_verify: false,
8891
})
8992
}
9093
}
@@ -138,6 +141,7 @@ impl TrustedWalletInterface for Spark {
138141
description: "".to_string(), // empty description for smaller QRs and better privacy
139142
amount_sats,
140143
expiry_secs: None,
144+
payment_hash: None,
141145
},
142146
};
143147
let res = self.spark_wallet.receive_payment(params).await?;
@@ -176,6 +180,7 @@ impl TrustedWalletInterface for Spark {
176180
amount: Some(sats.into()),
177181
token_identifier: None,
178182
conversion_options: None,
183+
fee_policy: None,
179184
};
180185
let prepare = self.spark_wallet.prepare_send_payment(params).await?;
181186
match prepare.payment_method {
@@ -209,6 +214,7 @@ impl TrustedWalletInterface for Spark {
209214
amount: Some(sats.into()),
210215
token_identifier: None,
211216
conversion_options: None,
217+
fee_policy: None,
212218
};
213219
let prepare = self.spark_wallet.prepare_send_payment(params).await?;
214220

@@ -240,8 +246,9 @@ impl TrustedWalletInterface for Spark {
240246
self.spark_wallet.list_payments(ListPaymentsRequest::default()).await.ok()?;
241247

242248
let tx = res.payments.into_iter().find(|p| {
243-
if let Some(PaymentDetails::Lightning { payment_hash: ph, .. }) = &p.details {
244-
let hash: Option<[u8; 32]> = FromHex::from_hex(ph).ok();
249+
if let Some(PaymentDetails::Lightning { htlc_details, .. }) = &p.details {
250+
let hash: Option<[u8; 32]> =
251+
FromHex::from_hex(&htlc_details.payment_hash).ok();
245252
hash == Some(payment_hash)
246253
} else {
247254
false
@@ -412,7 +419,7 @@ impl SparkEventHandler {
412419
match payment.payment_type {
413420
PaymentType::Send => {
414421
match payment.details {
415-
Some(PaymentDetails::Lightning { preimage, payment_hash, .. }) => {
422+
Some(PaymentDetails::Lightning { htlc_details, .. }) => {
416423
let payment_id = PaymentId::Trusted(id);
417424
let is_rebalance = {
418425
let map = self.tx_metadata.read();
@@ -429,17 +436,17 @@ impl SparkEventHandler {
429436
return Ok(());
430437
}
431438

432-
let preimage = preimage.ok_or_else(|| {
439+
let preimage_hex = htlc_details.preimage.ok_or_else(|| {
433440
TrustedError::Other(
434441
"Payment succeeded but preimage is missing".to_string(),
435442
)
436443
})?;
437444

438-
let preimage: [u8; 32] = FromHex::from_hex(&preimage).map_err(|e| {
445+
let preimage: [u8; 32] = FromHex::from_hex(&preimage_hex).map_err(|e| {
439446
TrustedError::Other(format!("Invalid preimage hex: {e:?}"))
440447
})?;
441-
let payment_hash: [u8; 32] =
442-
FromHex::from_hex(&payment_hash).map_err(|e| {
448+
let payment_hash: [u8; 32] = FromHex::from_hex(&htlc_details.payment_hash)
449+
.map_err(|e| {
443450
TrustedError::Other(format!("Invalid payment_hash hex: {e:?}"))
444451
})?;
445452

@@ -468,9 +475,9 @@ impl SparkEventHandler {
468475
},
469476
PaymentType::Receive => {
470477
match payment.details {
471-
Some(PaymentDetails::Lightning { payment_hash, .. }) => {
472-
let payment_hash: [u8; 32] =
473-
FromHex::from_hex(&payment_hash).map_err(|e| {
478+
Some(PaymentDetails::Lightning { htlc_details, .. }) => {
479+
let payment_hash: [u8; 32] = FromHex::from_hex(&htlc_details.payment_hash)
480+
.map_err(|e| {
474481
TrustedError::Other(format!("Invalid payment_hash hex: {e:?}"))
475482
})?;
476483

@@ -512,7 +519,7 @@ impl SparkEventHandler {
512519

513520
match payment.payment_type {
514521
PaymentType::Send => match payment.details {
515-
Some(PaymentDetails::Lightning { payment_hash, .. }) => {
522+
Some(PaymentDetails::Lightning { htlc_details, .. }) => {
516523
let payment_id = PaymentId::Trusted(id);
517524
let is_rebalance = {
518525
let map = self.tx_metadata.read();
@@ -527,9 +534,10 @@ impl SparkEventHandler {
527534
return Ok(());
528535
}
529536

530-
let payment_hash: [u8; 32] = FromHex::from_hex(&payment_hash).map_err(|e| {
531-
TrustedError::Other(format!("Invalid payment_hash hex: {e:?}"))
532-
})?;
537+
let payment_hash: [u8; 32] = FromHex::from_hex(&htlc_details.payment_hash)
538+
.map_err(|e| {
539+
TrustedError::Other(format!("Invalid payment_hash hex: {e:?}"))
540+
})?;
533541

534542
self.event_queue
535543
.add_event(Event::PaymentFailed {

0 commit comments

Comments
 (0)