Skip to content

Commit 470fbe8

Browse files
committed
Add destination pubkey and bolt12 invoice to payment details
1 parent 66810ec commit 470fbe8

File tree

25 files changed

+252
-133
lines changed

25 files changed

+252
-133
lines changed

cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,10 @@ typedef struct wire_cst_PaymentDetails_Lightning {
491491
struct wire_cst_list_prim_u_8_strict *description;
492492
uint32_t liquid_expiration_blockheight;
493493
struct wire_cst_list_prim_u_8_strict *preimage;
494-
struct wire_cst_list_prim_u_8_strict *bolt11;
494+
struct wire_cst_list_prim_u_8_strict *invoice;
495495
struct wire_cst_list_prim_u_8_strict *bolt12_offer;
496496
struct wire_cst_list_prim_u_8_strict *payment_hash;
497+
struct wire_cst_list_prim_u_8_strict *destination_pubkey;
497498
struct wire_cst_ln_url_info *lnurl_info;
498499
struct wire_cst_list_prim_u_8_strict *refund_tx_id;
499500
uint64_t *refund_tx_amount_sat;

lib/bindings/langs/swift/Sources/BreezSDKLiquid/Task/SwapUpdated.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SwapUpdatedTask : TaskProtocol {
6161
switch details {
6262
case let .bitcoin(swapId, _, _, _, _, _):
6363
return swapId
64-
case let .lightning(swapId, _, _, _, _, _, _, _, _, _):
64+
case let .lightning(swapId, _, _, _, _, _, _, _, _, _, _):
6565
return swapId
6666
default:
6767
break

lib/bindings/src/breez_sdk_liquid.udl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ dictionary LnUrlInfo {
579579

580580
[Enum]
581581
interface PaymentDetails {
582-
Lightning(string swap_id, string description, u32 liquid_expiration_blockheight, string? preimage, string? bolt11, string? bolt12_offer, string? payment_hash, LnUrlInfo? lnurl_info, string? refund_tx_id, u64? refund_tx_amount_sat);
582+
Lightning(string swap_id, string description, u32 liquid_expiration_blockheight, string? preimage, string? invoice, string? bolt12_offer, string? payment_hash, string? destination_pubkey, LnUrlInfo? lnurl_info, string? refund_tx_id, u64? refund_tx_amount_sat);
583583
Liquid(string destination, string description);
584584
Bitcoin(string swap_id, string description, u32? bitcoin_expiration_blockheight, u32? liquid_expiration_blockheight, string? refund_tx_id, u64? refund_tx_amount_sat);
585585
};

lib/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ lwk_wollet = { git = "https://github.com/dangeross/lwk", branch = "savage-full-s
2828
#lwk_wollet = "0.7.0"
2929
rusqlite = { version = "0.31", features = ["backup", "bundled"] }
3030
rusqlite_migration = "1.0"
31-
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "e0f2548b4ba917e69c532eb9ff900b64ed9a3da3", features = [
31+
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "f3256140944e52eb10e80608be804a0e43084c35", features = [
3232
"liquid",
3333
] }
3434
serde = { version = "1.0.197", features = ["derive"] }

lib/core/src/frb_generated.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3769,9 +3769,10 @@ impl SseDecode for crate::model::PaymentDetails {
37693769
let mut var_description = <String>::sse_decode(deserializer);
37703770
let mut var_liquidExpirationBlockheight = <u32>::sse_decode(deserializer);
37713771
let mut var_preimage = <Option<String>>::sse_decode(deserializer);
3772-
let mut var_bolt11 = <Option<String>>::sse_decode(deserializer);
3772+
let mut var_invoice = <Option<String>>::sse_decode(deserializer);
37733773
let mut var_bolt12Offer = <Option<String>>::sse_decode(deserializer);
37743774
let mut var_paymentHash = <Option<String>>::sse_decode(deserializer);
3775+
let mut var_destinationPubkey = <Option<String>>::sse_decode(deserializer);
37753776
let mut var_lnurlInfo = <Option<crate::model::LnUrlInfo>>::sse_decode(deserializer);
37763777
let mut var_refundTxId = <Option<String>>::sse_decode(deserializer);
37773778
let mut var_refundTxAmountSat = <Option<u64>>::sse_decode(deserializer);
@@ -3780,9 +3781,10 @@ impl SseDecode for crate::model::PaymentDetails {
37803781
description: var_description,
37813782
liquid_expiration_blockheight: var_liquidExpirationBlockheight,
37823783
preimage: var_preimage,
3783-
bolt11: var_bolt11,
3784+
invoice: var_invoice,
37843785
bolt12_offer: var_bolt12Offer,
37853786
payment_hash: var_paymentHash,
3787+
destination_pubkey: var_destinationPubkey,
37863788
lnurl_info: var_lnurlInfo,
37873789
refund_tx_id: var_refundTxId,
37883790
refund_tx_amount_sat: var_refundTxAmountSat,
@@ -5944,9 +5946,10 @@ impl flutter_rust_bridge::IntoDart for crate::model::PaymentDetails {
59445946
description,
59455947
liquid_expiration_blockheight,
59465948
preimage,
5947-
bolt11,
5949+
invoice,
59485950
bolt12_offer,
59495951
payment_hash,
5952+
destination_pubkey,
59505953
lnurl_info,
59515954
refund_tx_id,
59525955
refund_tx_amount_sat,
@@ -5956,9 +5959,10 @@ impl flutter_rust_bridge::IntoDart for crate::model::PaymentDetails {
59565959
description.into_into_dart().into_dart(),
59575960
liquid_expiration_blockheight.into_into_dart().into_dart(),
59585961
preimage.into_into_dart().into_dart(),
5959-
bolt11.into_into_dart().into_dart(),
5962+
invoice.into_into_dart().into_dart(),
59605963
bolt12_offer.into_into_dart().into_dart(),
59615964
payment_hash.into_into_dart().into_dart(),
5965+
destination_pubkey.into_into_dart().into_dart(),
59625966
lnurl_info.into_into_dart().into_dart(),
59635967
refund_tx_id.into_into_dart().into_dart(),
59645968
refund_tx_amount_sat.into_into_dart().into_dart(),
@@ -8060,9 +8064,10 @@ impl SseEncode for crate::model::PaymentDetails {
80608064
description,
80618065
liquid_expiration_blockheight,
80628066
preimage,
8063-
bolt11,
8067+
invoice,
80648068
bolt12_offer,
80658069
payment_hash,
8070+
destination_pubkey,
80668071
lnurl_info,
80678072
refund_tx_id,
80688073
refund_tx_amount_sat,
@@ -8072,9 +8077,10 @@ impl SseEncode for crate::model::PaymentDetails {
80728077
<String>::sse_encode(description, serializer);
80738078
<u32>::sse_encode(liquid_expiration_blockheight, serializer);
80748079
<Option<String>>::sse_encode(preimage, serializer);
8075-
<Option<String>>::sse_encode(bolt11, serializer);
8080+
<Option<String>>::sse_encode(invoice, serializer);
80768081
<Option<String>>::sse_encode(bolt12_offer, serializer);
80778082
<Option<String>>::sse_encode(payment_hash, serializer);
8083+
<Option<String>>::sse_encode(destination_pubkey, serializer);
80788084
<Option<crate::model::LnUrlInfo>>::sse_encode(lnurl_info, serializer);
80798085
<Option<String>>::sse_encode(refund_tx_id, serializer);
80808086
<Option<u64>>::sse_encode(refund_tx_amount_sat, serializer);
@@ -10160,9 +10166,10 @@ mod io {
1016010166
.liquid_expiration_blockheight
1016110167
.cst_decode(),
1016210168
preimage: ans.preimage.cst_decode(),
10163-
bolt11: ans.bolt11.cst_decode(),
10169+
invoice: ans.invoice.cst_decode(),
1016410170
bolt12_offer: ans.bolt12_offer.cst_decode(),
1016510171
payment_hash: ans.payment_hash.cst_decode(),
10172+
destination_pubkey: ans.destination_pubkey.cst_decode(),
1016610173
lnurl_info: ans.lnurl_info.cst_decode(),
1016710174
refund_tx_id: ans.refund_tx_id.cst_decode(),
1016810175
refund_tx_amount_sat: ans.refund_tx_amount_sat.cst_decode(),
@@ -13752,9 +13759,10 @@ mod io {
1375213759
description: *mut wire_cst_list_prim_u_8_strict,
1375313760
liquid_expiration_blockheight: u32,
1375413761
preimage: *mut wire_cst_list_prim_u_8_strict,
13755-
bolt11: *mut wire_cst_list_prim_u_8_strict,
13762+
invoice: *mut wire_cst_list_prim_u_8_strict,
1375613763
bolt12_offer: *mut wire_cst_list_prim_u_8_strict,
1375713764
payment_hash: *mut wire_cst_list_prim_u_8_strict,
13765+
destination_pubkey: *mut wire_cst_list_prim_u_8_strict,
1375813766
lnurl_info: *mut wire_cst_ln_url_info,
1375913767
refund_tx_id: *mut wire_cst_list_prim_u_8_strict,
1376013768
refund_tx_amount_sat: *mut u64,

lib/core/src/model.rs

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ pub(crate) struct SendSwap {
910910
/// The bolt12 offer, if this swap sends to a Bolt12 offer
911911
pub(crate) bolt12_offer: Option<String>,
912912
pub(crate) payment_hash: Option<String>,
913+
pub(crate) destination_pubkey: Option<String>,
913914
pub(crate) description: Option<String>,
914915
pub(crate) preimage: Option<String>,
915916
pub(crate) payer_amount_sat: u64,
@@ -999,6 +1000,7 @@ pub(crate) struct ReceiveSwap {
9991000
pub(crate) claim_private_key: String,
10001001
pub(crate) invoice: String,
10011002
pub(crate) payment_hash: Option<String>,
1003+
pub(crate) destination_pubkey: Option<String>,
10021004
pub(crate) description: Option<String>,
10031005
/// The amount of the invoice
10041006
pub(crate) payer_amount_sat: u64,
@@ -1316,9 +1318,10 @@ pub struct PaymentSwapData {
13161318
pub expiration_blockheight: u32,
13171319

13181320
pub preimage: Option<String>,
1319-
pub bolt11: Option<String>,
1321+
pub invoice: Option<String>,
13201322
pub bolt12_offer: Option<String>,
13211323
pub payment_hash: Option<String>,
1324+
pub destination_pubkey: Option<String>,
13221325
pub description: String,
13231326

13241327
/// Amount sent by the swap payer
@@ -1371,16 +1374,19 @@ pub enum PaymentDetails {
13711374
/// The preimage of the paid invoice (proof of payment).
13721375
preimage: Option<String>,
13731376

1374-
/// Represents the Bolt11 invoice associated with a payment
1377+
/// Represents the Bolt11/Bolt12 invoice associated with a payment
13751378
/// In the case of a Send payment, this is the invoice paid by the swapper
13761379
/// In the case of a Receive payment, this is the invoice paid by the user
1377-
bolt11: Option<String>,
1380+
invoice: Option<String>,
13781381

13791382
bolt12_offer: Option<String>,
13801383

13811384
/// The payment hash of the invoice
13821385
payment_hash: Option<String>,
13831386

1387+
/// The invoice destination/payee pubkey
1388+
destination_pubkey: Option<String>,
1389+
13841390
/// The payment LNURL info
13851391
lnurl_info: Option<LnUrlInfo>,
13861392

@@ -1518,7 +1524,7 @@ impl Payment {
15181524
};
15191525

15201526
Payment {
1521-
destination: swap.bolt11.clone(),
1527+
destination: swap.invoice.clone(),
15221528
tx_id: None,
15231529
unblinding_data: None,
15241530
timestamp: swap.created_at,
@@ -1545,15 +1551,15 @@ impl Payment {
15451551
destination: match &swap {
15461552
Some(PaymentSwapData {
15471553
swap_type: PaymentSwapType::Receive,
1548-
bolt11,
1554+
invoice,
15491555
..
1550-
}) => bolt11.clone(),
1556+
}) => invoice.clone(),
15511557
Some(PaymentSwapData {
15521558
swap_type: PaymentSwapType::Send,
1553-
bolt11,
1559+
invoice,
15541560
bolt12_offer,
15551561
..
1556-
}) => bolt11.clone().or(bolt12_offer.clone()),
1562+
}) => bolt12_offer.clone().or(invoice.clone()),
15571563
Some(PaymentSwapData {
15581564
swap_type: PaymentSwapType::Chain,
15591565
claim_address,
@@ -1871,6 +1877,23 @@ macro_rules! get_invoice_description {
18711877
};
18721878
}
18731879

1880+
#[macro_export]
1881+
macro_rules! get_invoice_destination_pubkey {
1882+
($invoice:expr, $is_bolt12:expr) => {
1883+
if $is_bolt12 {
1884+
utils::parse_bolt12_invoice($invoice)
1885+
.ok()
1886+
.map(|i| i.signing_pubkey().to_hex())
1887+
} else {
1888+
$invoice
1889+
.trim()
1890+
.parse::<Bolt11Invoice>()
1891+
.ok()
1892+
.map(|i| sdk_common::prelude::invoice_pubkey(&i))
1893+
}
1894+
};
1895+
}
1896+
18741897
#[macro_export]
18751898
macro_rules! get_updated_fields {
18761899
($($var:ident),* $(,)?) => {{

lib/core/src/persist/migrations.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,9 @@ pub(crate) fn current_migrations() -> Vec<&'static str> {
221221
ALTER TABLE receive_swaps ADD COLUMN timeout_block_height INTEGER NOT NULL DEFAULT 0;
222222
ALTER TABLE send_swaps ADD COLUMN timeout_block_height INTEGER NOT NULL DEFAULT 0;
223223
",
224+
"
225+
ALTER TABLE receive_swaps ADD COLUMN destination_pubkey TEXT;
226+
ALTER TABLE send_swaps ADD COLUMN destination_pubkey TEXT;
227+
",
224228
]
225229
}

0 commit comments

Comments
 (0)