Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add destination pubkey and bolt12 invoice to payment details #649

Merged
merged 2 commits into from
Jan 10, 2025
Merged
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
2 changes: 1 addition & 1 deletion cli/Cargo.lock

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

2 changes: 1 addition & 1 deletion lib/Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,10 @@ typedef struct wire_cst_PaymentDetails_Lightning {
struct wire_cst_list_prim_u_8_strict *description;
uint32_t liquid_expiration_blockheight;
struct wire_cst_list_prim_u_8_strict *preimage;
struct wire_cst_list_prim_u_8_strict *bolt11;
struct wire_cst_list_prim_u_8_strict *invoice;
struct wire_cst_list_prim_u_8_strict *bolt12_offer;
struct wire_cst_list_prim_u_8_strict *payment_hash;
struct wire_cst_list_prim_u_8_strict *destination_pubkey;
struct wire_cst_ln_url_info *lnurl_info;
struct wire_cst_list_prim_u_8_strict *refund_tx_id;
uint64_t *refund_tx_amount_sat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SwapUpdatedTask : TaskProtocol {
switch details {
case let .bitcoin(swapId, _, _, _, _, _):
return swapId
case let .lightning(swapId, _, _, _, _, _, _, _, _, _):
case let .lightning(swapId, _, _, _, _, _, _, _, _, _, _):
return swapId
default:
break
Expand Down
2 changes: 1 addition & 1 deletion lib/bindings/src/breez_sdk_liquid.udl
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ dictionary LnUrlInfo {

[Enum]
interface PaymentDetails {
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);
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);
Liquid(string destination, string description);
Bitcoin(string swap_id, string description, u32? bitcoin_expiration_blockheight, u32? liquid_expiration_blockheight, string? refund_tx_id, u64? refund_tx_amount_sat);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ lwk_wollet = { git = "https://github.com/dangeross/lwk", branch = "savage-full-s
#lwk_wollet = "0.7.0"
rusqlite = { version = "0.31", features = ["backup", "bundled"] }
rusqlite_migration = "1.0"
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "e0f2548b4ba917e69c532eb9ff900b64ed9a3da3", features = [
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "f3256140944e52eb10e80608be804a0e43084c35", features = [
"liquid",
] }
serde = { version = "1.0.197", features = ["derive"] }
Expand Down
24 changes: 16 additions & 8 deletions lib/core/src/frb_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3769,9 +3769,10 @@ impl SseDecode for crate::model::PaymentDetails {
let mut var_description = <String>::sse_decode(deserializer);
let mut var_liquidExpirationBlockheight = <u32>::sse_decode(deserializer);
let mut var_preimage = <Option<String>>::sse_decode(deserializer);
let mut var_bolt11 = <Option<String>>::sse_decode(deserializer);
let mut var_invoice = <Option<String>>::sse_decode(deserializer);
let mut var_bolt12Offer = <Option<String>>::sse_decode(deserializer);
let mut var_paymentHash = <Option<String>>::sse_decode(deserializer);
let mut var_destinationPubkey = <Option<String>>::sse_decode(deserializer);
let mut var_lnurlInfo = <Option<crate::model::LnUrlInfo>>::sse_decode(deserializer);
let mut var_refundTxId = <Option<String>>::sse_decode(deserializer);
let mut var_refundTxAmountSat = <Option<u64>>::sse_decode(deserializer);
Expand All @@ -3780,9 +3781,10 @@ impl SseDecode for crate::model::PaymentDetails {
description: var_description,
liquid_expiration_blockheight: var_liquidExpirationBlockheight,
preimage: var_preimage,
bolt11: var_bolt11,
invoice: var_invoice,
bolt12_offer: var_bolt12Offer,
payment_hash: var_paymentHash,
destination_pubkey: var_destinationPubkey,
lnurl_info: var_lnurlInfo,
refund_tx_id: var_refundTxId,
refund_tx_amount_sat: var_refundTxAmountSat,
Expand Down Expand Up @@ -5944,9 +5946,10 @@ impl flutter_rust_bridge::IntoDart for crate::model::PaymentDetails {
description,
liquid_expiration_blockheight,
preimage,
bolt11,
invoice,
bolt12_offer,
payment_hash,
destination_pubkey,
lnurl_info,
refund_tx_id,
refund_tx_amount_sat,
Expand All @@ -5956,9 +5959,10 @@ impl flutter_rust_bridge::IntoDart for crate::model::PaymentDetails {
description.into_into_dart().into_dart(),
liquid_expiration_blockheight.into_into_dart().into_dart(),
preimage.into_into_dart().into_dart(),
bolt11.into_into_dart().into_dart(),
invoice.into_into_dart().into_dart(),
bolt12_offer.into_into_dart().into_dart(),
payment_hash.into_into_dart().into_dart(),
destination_pubkey.into_into_dart().into_dart(),
lnurl_info.into_into_dart().into_dart(),
refund_tx_id.into_into_dart().into_dart(),
refund_tx_amount_sat.into_into_dart().into_dart(),
Expand Down Expand Up @@ -8060,9 +8064,10 @@ impl SseEncode for crate::model::PaymentDetails {
description,
liquid_expiration_blockheight,
preimage,
bolt11,
invoice,
bolt12_offer,
payment_hash,
destination_pubkey,
lnurl_info,
refund_tx_id,
refund_tx_amount_sat,
Expand All @@ -8072,9 +8077,10 @@ impl SseEncode for crate::model::PaymentDetails {
<String>::sse_encode(description, serializer);
<u32>::sse_encode(liquid_expiration_blockheight, serializer);
<Option<String>>::sse_encode(preimage, serializer);
<Option<String>>::sse_encode(bolt11, serializer);
<Option<String>>::sse_encode(invoice, serializer);
<Option<String>>::sse_encode(bolt12_offer, serializer);
<Option<String>>::sse_encode(payment_hash, serializer);
<Option<String>>::sse_encode(destination_pubkey, serializer);
<Option<crate::model::LnUrlInfo>>::sse_encode(lnurl_info, serializer);
<Option<String>>::sse_encode(refund_tx_id, serializer);
<Option<u64>>::sse_encode(refund_tx_amount_sat, serializer);
Expand Down Expand Up @@ -10160,9 +10166,10 @@ mod io {
.liquid_expiration_blockheight
.cst_decode(),
preimage: ans.preimage.cst_decode(),
bolt11: ans.bolt11.cst_decode(),
invoice: ans.invoice.cst_decode(),
bolt12_offer: ans.bolt12_offer.cst_decode(),
payment_hash: ans.payment_hash.cst_decode(),
destination_pubkey: ans.destination_pubkey.cst_decode(),
lnurl_info: ans.lnurl_info.cst_decode(),
refund_tx_id: ans.refund_tx_id.cst_decode(),
refund_tx_amount_sat: ans.refund_tx_amount_sat.cst_decode(),
Expand Down Expand Up @@ -13752,9 +13759,10 @@ mod io {
description: *mut wire_cst_list_prim_u_8_strict,
liquid_expiration_blockheight: u32,
preimage: *mut wire_cst_list_prim_u_8_strict,
bolt11: *mut wire_cst_list_prim_u_8_strict,
invoice: *mut wire_cst_list_prim_u_8_strict,
bolt12_offer: *mut wire_cst_list_prim_u_8_strict,
payment_hash: *mut wire_cst_list_prim_u_8_strict,
destination_pubkey: *mut wire_cst_list_prim_u_8_strict,
lnurl_info: *mut wire_cst_ln_url_info,
refund_tx_id: *mut wire_cst_list_prim_u_8_strict,
refund_tx_amount_sat: *mut u64,
Expand Down
22 changes: 14 additions & 8 deletions lib/core/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ pub(crate) struct SendSwap {
/// The bolt12 offer, if this swap sends to a Bolt12 offer
pub(crate) bolt12_offer: Option<String>,
pub(crate) payment_hash: Option<String>,
pub(crate) destination_pubkey: Option<String>,
pub(crate) description: Option<String>,
pub(crate) preimage: Option<String>,
pub(crate) payer_amount_sat: u64,
Expand Down Expand Up @@ -999,6 +1000,7 @@ pub(crate) struct ReceiveSwap {
pub(crate) claim_private_key: String,
pub(crate) invoice: String,
pub(crate) payment_hash: Option<String>,
pub(crate) destination_pubkey: Option<String>,
pub(crate) description: Option<String>,
/// The amount of the invoice
pub(crate) payer_amount_sat: u64,
Expand Down Expand Up @@ -1316,9 +1318,10 @@ pub struct PaymentSwapData {
pub expiration_blockheight: u32,

pub preimage: Option<String>,
pub bolt11: Option<String>,
pub invoice: Option<String>,
pub bolt12_offer: Option<String>,
pub payment_hash: Option<String>,
pub destination_pubkey: Option<String>,
pub description: String,

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

/// Represents the Bolt11 invoice associated with a payment
/// Represents the Bolt11/Bolt12 invoice associated with a payment
/// In the case of a Send payment, this is the invoice paid by the swapper
/// In the case of a Receive payment, this is the invoice paid by the user
bolt11: Option<String>,
invoice: Option<String>,

bolt12_offer: Option<String>,

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

/// The invoice destination/payee pubkey
destination_pubkey: Option<String>,

/// The payment LNURL info
lnurl_info: Option<LnUrlInfo>,

Expand Down Expand Up @@ -1518,7 +1524,7 @@ impl Payment {
};

Payment {
destination: swap.bolt11.clone(),
destination: swap.invoice.clone(),
tx_id: None,
unblinding_data: None,
timestamp: swap.created_at,
Expand All @@ -1545,15 +1551,15 @@ impl Payment {
destination: match &swap {
Some(PaymentSwapData {
swap_type: PaymentSwapType::Receive,
bolt11,
invoice,
..
}) => bolt11.clone(),
}) => invoice.clone(),
Some(PaymentSwapData {
swap_type: PaymentSwapType::Send,
bolt11,
invoice,
bolt12_offer,
..
}) => bolt11.clone().or(bolt12_offer.clone()),
}) => bolt12_offer.clone().or(invoice.clone()),
Some(PaymentSwapData {
swap_type: PaymentSwapType::Chain,
claim_address,
Expand Down
4 changes: 4 additions & 0 deletions lib/core/src/persist/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,9 @@ pub(crate) fn current_migrations() -> Vec<&'static str> {
ALTER TABLE receive_swaps ADD COLUMN timeout_block_height INTEGER NOT NULL DEFAULT 0;
ALTER TABLE send_swaps ADD COLUMN timeout_block_height INTEGER NOT NULL DEFAULT 0;
",
"
ALTER TABLE receive_swaps ADD COLUMN destination_pubkey TEXT;
ALTER TABLE send_swaps ADD COLUMN destination_pubkey TEXT;
",
]
}
Loading
Loading