Skip to content

Commit 983ec28

Browse files
committed
Always use cashu quote id for PaymentId
1 parent c27e912 commit 983ec28

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

orange-sdk/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ reqwest = { version = "0.12.23", default-features = false, features = ["rustls-t
2626
spark-wallet = { git = "https://github.com/breez/spark-sdk.git", rev = "6e12f98be3f100fca0411e3209a610decfa32279", default-features = false, features = ["rustls-tls"], optional = true }
2727
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "sync"] }
2828
uuid = { version = "1.0", default-features = false, optional = true }
29-
cdk = { git = "https://github.com/benthecarman/cdk.git", branch = "orange-fork", default-features = false, features = ["wallet"], optional = true }
29+
cdk = { git = "https://github.com/benthecarman/cdk.git", rev = "7d25e9ae5ed7f47f9ae7e87d8a9ee16797fee8cd", default-features = false, features = ["wallet"], optional = true }
3030
serde_json = { version = "1.0", optional = true }
3131
async-trait = "0.1"
3232

3333
corepc-node = { version = "0.8.0", features = ["29_0", "download"], optional = true }
34-
cdk-ldk-node = { git = "https://github.com/benthecarman/cdk.git", branch = "orange-fork", optional = true }
35-
cdk-sqlite = { git = "https://github.com/benthecarman/cdk.git", branch = "orange-fork", optional = true }
36-
cdk-axum = { git = "https://github.com/benthecarman/cdk.git", branch = "orange-fork", optional = true }
34+
cdk-ldk-node = { git = "https://github.com/benthecarman/cdk.git", rev = "7d25e9ae5ed7f47f9ae7e87d8a9ee16797fee8cd", optional = true }
35+
cdk-sqlite = { git = "https://github.com/benthecarman/cdk.git", rev = "7d25e9ae5ed7f47f9ae7e87d8a9ee16797fee8cd", optional = true }
36+
cdk-axum = { git = "https://github.com/benthecarman/cdk.git", rev = "7d25e9ae5ed7f47f9ae7e87d8a9ee16797fee8cd", optional = true }
3737
axum = { version = "0.8.1", optional = true }
3838

3939
uniffi = { version = "0.29", features = ["cli", "tokio"], optional = true }

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ impl Cashu {
550550
transaction: Transaction, unit: &CurrencyUnit,
551551
) -> Result<Payment, TrustedError> {
552552
// Convert transaction ID to a 32-byte array
553-
let payment_id = Self::id_to_32_byte_array(&transaction.id().to_string());
553+
let id = transaction.quote_id.ok_or(TrustedError::WalletOperationFailed(
554+
"Missing quote ID in transaction".to_owned(),
555+
))?;
556+
let payment_id = Self::id_to_32_byte_array(&id);
554557

555558
// Convert amounts - CDK amounts are u64 representing sats
556559
let amount = convert_amount(transaction.amount, unit)?;
@@ -589,9 +592,12 @@ impl Cashu {
589592
// Convert quote ID to a 32-byte payment ID
590593
let payment_id = Self::id_to_32_byte_array(&mint_quote.id);
591594

592-
// Create a payment hash from the quote ID
593-
// fixme: can we get the actual payment hash?
594-
let hash = Sha256::hash(mint_quote.id.as_bytes());
595+
// Parse the invoice to get the payment hash
596+
// todo this won't work for bolt12
597+
let invoice = Bolt11Invoice::from_str(&mint_quote.request).map_err(|e| {
598+
TrustedError::Other(format!("Failed to parse invoice from mint quote: {e}"))
599+
})?;
600+
let hash = invoice.payment_hash();
595601

596602
// Send a PaymentReceived event
597603
event_queue

0 commit comments

Comments
 (0)