Skip to content

Commit d883683

Browse files
committed
Update spark-sdk to latest release
1 parent 5342ae9 commit d883683

File tree

3 files changed

+79
-20
lines changed

3 files changed

+79
-20
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 {

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

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ use std::sync::Arc;
44

55
use crate::io;
66

7+
use breez_sdk_spark::sync_storage::{
8+
IncomingChange, OutgoingChange, Record, UnversionedRecordChange,
9+
};
710
use breez_sdk_spark::{
8-
DepositInfo, ListPaymentsRequest, Payment, PaymentDetails, PaymentMetadata,
9-
SetLnurlMetadataItem, StorageError, UpdateDepositPayload,
11+
DepositInfo, Payment, PaymentDetails, PaymentMetadata, SetLnurlMetadataItem, StorageError,
12+
StorageListPaymentsRequest, UpdateDepositPayload,
1013
};
1114
use ldk_node::DynStore;
1215
use ldk_node::lightning::util::persist::KVSTORE_NAMESPACE_KEY_MAX_LEN;
@@ -78,7 +81,7 @@ impl breez_sdk_spark::Storage for SparkStore {
7881
}
7982

8083
async fn list_payments(
81-
&self, request: ListPaymentsRequest,
84+
&self, request: StorageListPaymentsRequest,
8285
) -> Result<Vec<breez_sdk_spark::Payment>, StorageError> {
8386
let keys =
8487
KVStore::list(self.0.as_ref(), SPARK_PRIMARY_NAMESPACE, SPARK_PAYMENTS_NAMESPACE)
@@ -137,7 +140,7 @@ impl breez_sdk_spark::Storage for SparkStore {
137140
Ok(())
138141
}
139142

140-
async fn set_payment_metadata(
143+
async fn insert_payment_metadata(
141144
&self, _: String, _: PaymentMetadata,
142145
) -> Result<(), StorageError> {
143146
// we don't use this
@@ -160,7 +163,7 @@ impl breez_sdk_spark::Storage for SparkStore {
160163
async fn get_payment_by_invoice(
161164
&self, invoice: String,
162165
) -> Result<Option<Payment>, StorageError> {
163-
let payments = self.list_payments(ListPaymentsRequest::default()).await?;
166+
let payments = self.list_payments(StorageListPaymentsRequest::default()).await?;
164167

165168
let p = payments.into_iter().find(|p| {
166169
if let Some(details) = p.details.as_ref() {
@@ -313,4 +316,52 @@ impl breez_sdk_spark::Storage for SparkStore {
313316
// we don't use this
314317
Ok(())
315318
}
319+
320+
async fn get_payments_by_parent_ids(
321+
&self, _parent_ids: Vec<String>,
322+
) -> Result<std::collections::HashMap<String, Vec<Payment>>, StorageError> {
323+
Ok(std::collections::HashMap::new())
324+
}
325+
326+
async fn add_outgoing_change(
327+
&self, _change: UnversionedRecordChange,
328+
) -> Result<u64, StorageError> {
329+
Ok(0)
330+
}
331+
332+
async fn complete_outgoing_sync(
333+
&self, _record: Record, _change_id: u64,
334+
) -> Result<(), StorageError> {
335+
Ok(())
336+
}
337+
338+
async fn get_pending_outgoing_changes(
339+
&self, _limit: u32,
340+
) -> Result<Vec<OutgoingChange>, StorageError> {
341+
Ok(Vec::new())
342+
}
343+
344+
async fn get_last_revision(&self) -> Result<u64, StorageError> {
345+
Ok(0)
346+
}
347+
348+
async fn insert_incoming_records(&self, _records: Vec<Record>) -> Result<(), StorageError> {
349+
Ok(())
350+
}
351+
352+
async fn delete_incoming_record(&self, _record: Record) -> Result<(), StorageError> {
353+
Ok(())
354+
}
355+
356+
async fn get_incoming_records(&self, _limit: u32) -> Result<Vec<IncomingChange>, StorageError> {
357+
Ok(Vec::new())
358+
}
359+
360+
async fn get_latest_outgoing_change(&self) -> Result<Option<OutgoingChange>, StorageError> {
361+
Ok(None)
362+
}
363+
364+
async fn update_record_from_incoming(&self, _record: Record) -> Result<(), StorageError> {
365+
Ok(())
366+
}
316367
}

0 commit comments

Comments
 (0)