diff --git a/cli/Cargo.lock b/cli/Cargo.lock index 9018e60..86fdb9c 100644 --- a/cli/Cargo.lock +++ b/cli/Cargo.lock @@ -3934,7 +3934,7 @@ dependencies = [ [[package]] name = "sdk-common" version = "0.6.2" -source = "git+https://github.com/breez/breez-sdk?rev=7a96ce7e5c12d837948e1e37687a1bd0cd0f884c#7a96ce7e5c12d837948e1e37687a1bd0cd0f884c" +source = "git+https://github.com/breez/breez-sdk?rev=84578d9abe1dd0d59867f93a22a92220ab16a52e#84578d9abe1dd0d59867f93a22a92220ab16a52e" dependencies = [ "aes", "anyhow", diff --git a/cli/src/commands.rs b/cli/src/commands.rs index 011f72a..0a6495d 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -692,7 +692,10 @@ pub(crate) async fn handle_command( } => { let input = sdk.parse(&lnurl).await?; let res = match input { - InputType::LnUrlPay { data: pd } => { + InputType::LnUrlPay { + data: pd, + bip353_address, + } => { let amount = match drain.unwrap_or(false) { true => PayAmount::Drain, false => { @@ -713,6 +716,7 @@ pub(crate) async fn handle_command( .prepare_lnurl_pay(PrepareLnUrlPayRequest { data: pd, amount, + bip353_address, comment: None, validate_success_action_url: validate_success_url, }) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 8873f10..0153df7 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -4164,7 +4164,7 @@ dependencies = [ [[package]] name = "sdk-common" version = "0.6.2" -source = "git+https://github.com/breez/breez-sdk?rev=7a96ce7e5c12d837948e1e37687a1bd0cd0f884c#7a96ce7e5c12d837948e1e37687a1bd0cd0f884c" +source = "git+https://github.com/breez/breez-sdk?rev=84578d9abe1dd0d59867f93a22a92220ab16a52e#84578d9abe1dd0d59867f93a22a92220ab16a52e" dependencies = [ "aes", "anyhow", diff --git a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h index 6171ae6..f7b6bec 100644 --- a/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h +++ b/lib/bindings/langs/flutter/breez_sdk_liquid/include/breez_sdk_liquid.h @@ -198,6 +198,7 @@ typedef struct wire_cst_ln_invoice { typedef struct wire_cst_SendDestination_Bolt11 { struct wire_cst_ln_invoice *invoice; + struct wire_cst_list_prim_u_8_strict *bip353_address; } wire_cst_SendDestination_Bolt11; typedef struct wire_cst_list_String { @@ -247,6 +248,7 @@ typedef struct wire_cst_ln_offer { typedef struct wire_cst_SendDestination_Bolt12 { struct wire_cst_ln_offer *offer; uint64_t receiver_amount_sat; + struct wire_cst_list_prim_u_8_strict *bip353_address; } wire_cst_SendDestination_Bolt12; typedef union SendDestinationKind { @@ -375,6 +377,7 @@ typedef struct wire_cst_pay_amount { typedef struct wire_cst_prepare_ln_url_pay_request { struct wire_cst_ln_url_pay_request_data data; struct wire_cst_pay_amount amount; + struct wire_cst_list_prim_u_8_strict *bip353_address; struct wire_cst_list_prim_u_8_strict *comment; bool *validate_success_action_url; } wire_cst_prepare_ln_url_pay_request; @@ -527,6 +530,7 @@ typedef struct wire_cst_PaymentDetails_Lightning { 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 *bip353_address; struct wire_cst_list_prim_u_8_strict *claim_tx_id; struct wire_cst_list_prim_u_8_strict *refund_tx_id; uint64_t *refund_tx_amount_sat; @@ -826,6 +830,7 @@ typedef struct wire_cst_InputType_Bolt11 { typedef struct wire_cst_InputType_Bolt12Offer { struct wire_cst_ln_offer *offer; + struct wire_cst_list_prim_u_8_strict *bip353_address; } wire_cst_InputType_Bolt12Offer; typedef struct wire_cst_InputType_NodeId { @@ -838,6 +843,7 @@ typedef struct wire_cst_InputType_Url { typedef struct wire_cst_InputType_LnUrlPay { struct wire_cst_ln_url_pay_request_data *data; + struct wire_cst_list_prim_u_8_strict *bip353_address; } wire_cst_InputType_LnUrlPay; typedef struct wire_cst_InputType_LnUrlWithdraw { diff --git a/lib/bindings/langs/swift/Sources/BreezSDKLiquid/Task/SwapUpdated.swift b/lib/bindings/langs/swift/Sources/BreezSDKLiquid/Task/SwapUpdated.swift index e8ae7af..6ce4b47 100644 --- a/lib/bindings/langs/swift/Sources/BreezSDKLiquid/Task/SwapUpdated.swift +++ b/lib/bindings/langs/swift/Sources/BreezSDKLiquid/Task/SwapUpdated.swift @@ -110,7 +110,7 @@ class SwapUpdatedTask : TaskProtocol { switch details { case let .bitcoin(swapId, _, _, _, _, _, _, _): return swapId - case let .lightning(swapId, _, _, _, _, _, _, _, _, _, _, _): + case let .lightning(swapId, _, _, _, _, _, _, _, _, _, _, _, _): return swapId default: break @@ -123,7 +123,7 @@ class SwapUpdatedTask : TaskProtocol { switch details { case let .bitcoin(_, _, _, _, _, claimTxId, _, _): return claimTxId != nil - case let .lightning( _, _, _, _, _, _, _, _, _, claimTxId, _, _): + case let .lightning(_, _, _, _, _, _, _, _, _, _, claimTxId, _, _): return claimTxId != nil default: return false diff --git a/lib/bindings/src/breez_sdk_liquid.udl b/lib/bindings/src/breez_sdk_liquid.udl index 360131a..a135497 100644 --- a/lib/bindings/src/breez_sdk_liquid.udl +++ b/lib/bindings/src/breez_sdk_liquid.udl @@ -64,10 +64,10 @@ interface InputType { BitcoinAddress(BitcoinAddressData address); LiquidAddress(LiquidAddressData address); Bolt11(LNInvoice invoice); - Bolt12Offer(LNOffer offer); + Bolt12Offer(LNOffer offer, string? bip353_address); NodeId(string node_id); Url(string url); - LnUrlPay(LnUrlPayRequestData data); + LnUrlPay(LnUrlPayRequestData data, string? bip353_address); LnUrlWithdraw(LnUrlWithdrawRequestData data); LnUrlAuth(LnUrlAuthRequestData data); LnUrlError(LnUrlErrorData data); @@ -408,6 +408,7 @@ dictionary CheckMessageResponse { dictionary PrepareLnUrlPayRequest { LnUrlPayRequestData data; PayAmount amount; + string? bip353_address = null; string? comment = null; boolean? validate_success_action_url = null; }; @@ -432,8 +433,8 @@ dictionary PrepareSendRequest { [Enum] interface SendDestination { LiquidAddress(LiquidAddressData address_data); - Bolt11(LNInvoice invoice); - Bolt12(LNOffer offer, u64 receiver_amount_sat); + Bolt11(LNInvoice invoice, string? bip353_address); + Bolt12(LNOffer offer, u64 receiver_amount_sat, string? bip353_address); }; dictionary PrepareSendResponse { @@ -608,7 +609,7 @@ dictionary AssetInfo { [Enum] interface PaymentDetails { - 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? claim_tx_id, 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? bip353_address, string? claim_tx_id, string? refund_tx_id, u64? refund_tx_amount_sat); Liquid(string asset_id, string destination, string description, AssetInfo? asset_info); Bitcoin(string swap_id, string description, boolean auto_accepted_fees, u32? bitcoin_expiration_blockheight, u32? liquid_expiration_blockheight, string? claim_tx_id, string? refund_tx_id, u64? refund_tx_amount_sat); }; diff --git a/lib/core/Cargo.toml b/lib/core/Cargo.toml index 4bf1ca8..38f7733 100644 --- a/lib/core/Cargo.toml +++ b/lib/core/Cargo.toml @@ -31,7 +31,7 @@ lwk_wollet = { git = "https://github.com/breez/lwk", branch = "breez-sdk-liquid- #lwk_wollet = "0.8.0" rusqlite = { version = "0.31", features = ["backup", "bundled"] } rusqlite_migration = "1.0" -sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "7a96ce7e5c12d837948e1e37687a1bd0cd0f884c", features = ["liquid"] } +sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "84578d9abe1dd0d59867f93a22a92220ab16a52e", features = ["liquid"] } serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.116" strum = "0.25" diff --git a/lib/core/src/bindings.rs b/lib/core/src/bindings.rs index ecb4d08..326d59c 100644 --- a/lib/core/src/bindings.rs +++ b/lib/core/src/bindings.rs @@ -380,16 +380,38 @@ pub struct _LNOffer { #[frb(mirror(InputType))] pub enum _InputType { - BitcoinAddress { address: BitcoinAddressData }, - LiquidAddress { address: LiquidAddressData }, - Bolt11 { invoice: LNInvoice }, - Bolt12Offer { offer: LNOffer }, - NodeId { node_id: String }, - Url { url: String }, - LnUrlPay { data: LnUrlPayRequestData }, - LnUrlWithdraw { data: LnUrlWithdrawRequestData }, - LnUrlAuth { data: LnUrlAuthRequestData }, - LnUrlError { data: LnUrlErrorData }, + BitcoinAddress { + address: BitcoinAddressData, + }, + LiquidAddress { + address: LiquidAddressData, + }, + Bolt11 { + invoice: LNInvoice, + }, + Bolt12Offer { + offer: LNOffer, + bip353_address: Option, + }, + NodeId { + node_id: String, + }, + Url { + url: String, + }, + LnUrlPay { + data: LnUrlPayRequestData, + bip353_address: Option, + }, + LnUrlWithdraw { + data: LnUrlWithdrawRequestData, + }, + LnUrlAuth { + data: LnUrlAuthRequestData, + }, + LnUrlError { + data: LnUrlErrorData, + }, } #[frb(mirror(BitcoinAddressData))] diff --git a/lib/core/src/frb_generated.rs b/lib/core/src/frb_generated.rs index d5badc9..a9208b4 100644 --- a/lib/core/src/frb_generated.rs +++ b/lib/core/src/frb_generated.rs @@ -1939,8 +1939,12 @@ const _: fn() = || { crate::bindings::InputType::Bolt11 { invoice } => { let _: crate::bindings::LNInvoice = invoice; } - crate::bindings::InputType::Bolt12Offer { offer } => { + crate::bindings::InputType::Bolt12Offer { + offer, + bip353_address, + } => { let _: crate::bindings::LNOffer = offer; + let _: Option = bip353_address; } crate::bindings::InputType::NodeId { node_id } => { let _: String = node_id; @@ -1948,8 +1952,12 @@ const _: fn() = || { crate::bindings::InputType::Url { url } => { let _: String = url; } - crate::bindings::InputType::LnUrlPay { data } => { + crate::bindings::InputType::LnUrlPay { + data, + bip353_address, + } => { let _: crate::bindings::LnUrlPayRequestData = data; + let _: Option = bip353_address; } crate::bindings::InputType::LnUrlWithdraw { data } => { let _: crate::bindings::LnUrlWithdrawRequestData = data; @@ -2748,7 +2756,11 @@ impl SseDecode for crate::bindings::InputType { } 3 => { let mut var_offer = ::sse_decode(deserializer); - return crate::bindings::InputType::Bolt12Offer { offer: var_offer }; + let mut var_bip353Address = >::sse_decode(deserializer); + return crate::bindings::InputType::Bolt12Offer { + offer: var_offer, + bip353_address: var_bip353Address, + }; } 4 => { let mut var_nodeId = ::sse_decode(deserializer); @@ -2762,7 +2774,11 @@ impl SseDecode for crate::bindings::InputType { } 6 => { let mut var_data = ::sse_decode(deserializer); - return crate::bindings::InputType::LnUrlPay { data: var_data }; + let mut var_bip353Address = >::sse_decode(deserializer); + return crate::bindings::InputType::LnUrlPay { + data: var_data, + bip353_address: var_bip353Address, + }; } 7 => { let mut var_data = @@ -3907,6 +3923,7 @@ impl SseDecode for crate::model::PaymentDetails { let mut var_paymentHash = >::sse_decode(deserializer); let mut var_destinationPubkey = >::sse_decode(deserializer); let mut var_lnurlInfo = >::sse_decode(deserializer); + let mut var_bip353Address = >::sse_decode(deserializer); let mut var_claimTxId = >::sse_decode(deserializer); let mut var_refundTxId = >::sse_decode(deserializer); let mut var_refundTxAmountSat = >::sse_decode(deserializer); @@ -3920,6 +3937,7 @@ impl SseDecode for crate::model::PaymentDetails { payment_hash: var_paymentHash, destination_pubkey: var_destinationPubkey, lnurl_info: var_lnurlInfo, + bip353_address: var_bip353Address, claim_tx_id: var_claimTxId, refund_tx_id: var_refundTxId, refund_tx_amount_sat: var_refundTxAmountSat, @@ -4131,11 +4149,13 @@ impl SseDecode for crate::model::PrepareLnUrlPayRequest { fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self { let mut var_data = ::sse_decode(deserializer); let mut var_amount = ::sse_decode(deserializer); + let mut var_bip353Address = >::sse_decode(deserializer); let mut var_comment = >::sse_decode(deserializer); let mut var_validateSuccessActionUrl = >::sse_decode(deserializer); return crate::model::PrepareLnUrlPayRequest { data: var_data, amount: var_amount, + bip353_address: var_bip353Address, comment: var_comment, validate_success_action_url: var_validateSuccessActionUrl, }; @@ -4535,16 +4555,20 @@ impl SseDecode for crate::model::SendDestination { } 1 => { let mut var_invoice = ::sse_decode(deserializer); + let mut var_bip353Address = >::sse_decode(deserializer); return crate::model::SendDestination::Bolt11 { invoice: var_invoice, + bip353_address: var_bip353Address, }; } 2 => { let mut var_offer = ::sse_decode(deserializer); let mut var_receiverAmountSat = ::sse_decode(deserializer); + let mut var_bip353Address = >::sse_decode(deserializer); return crate::model::SendDestination::Bolt12 { offer: var_offer, receiver_amount_sat: var_receiverAmountSat, + bip353_address: var_bip353Address, }; } _ => { @@ -5330,18 +5354,30 @@ impl flutter_rust_bridge::IntoDart for FrbWrapper { crate::bindings::InputType::Bolt11 { invoice } => { [2.into_dart(), invoice.into_into_dart().into_dart()].into_dart() } - crate::bindings::InputType::Bolt12Offer { offer } => { - [3.into_dart(), offer.into_into_dart().into_dart()].into_dart() - } + crate::bindings::InputType::Bolt12Offer { + offer, + bip353_address, + } => [ + 3.into_dart(), + offer.into_into_dart().into_dart(), + bip353_address.into_into_dart().into_dart(), + ] + .into_dart(), crate::bindings::InputType::NodeId { node_id } => { [4.into_dart(), node_id.into_into_dart().into_dart()].into_dart() } crate::bindings::InputType::Url { url } => { [5.into_dart(), url.into_into_dart().into_dart()].into_dart() } - crate::bindings::InputType::LnUrlPay { data } => { - [6.into_dart(), data.into_into_dart().into_dart()].into_dart() - } + crate::bindings::InputType::LnUrlPay { + data, + bip353_address, + } => [ + 6.into_dart(), + data.into_into_dart().into_dart(), + bip353_address.into_into_dart().into_dart(), + ] + .into_dart(), crate::bindings::InputType::LnUrlWithdraw { data } => { [7.into_dart(), data.into_into_dart().into_dart()].into_dart() } @@ -6217,6 +6253,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::PaymentDetails { payment_hash, destination_pubkey, lnurl_info, + bip353_address, claim_tx_id, refund_tx_id, refund_tx_amount_sat, @@ -6231,6 +6268,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::PaymentDetails { payment_hash.into_into_dart().into_dart(), destination_pubkey.into_into_dart().into_dart(), lnurl_info.into_into_dart().into_dart(), + bip353_address.into_into_dart().into_dart(), claim_tx_id.into_into_dart().into_dart(), refund_tx_id.into_into_dart().into_dart(), refund_tx_amount_sat.into_into_dart().into_dart(), @@ -6453,6 +6491,7 @@ impl flutter_rust_bridge::IntoDart for crate::model::PrepareLnUrlPayRequest { [ self.data.into_into_dart().into_dart(), self.amount.into_into_dart().into_dart(), + self.bip353_address.into_into_dart().into_dart(), self.comment.into_into_dart().into_dart(), self.validate_success_action_url .into_into_dart() @@ -6967,16 +7006,24 @@ impl flutter_rust_bridge::IntoDart for crate::model::SendDestination { crate::model::SendDestination::LiquidAddress { address_data } => { [0.into_dart(), address_data.into_into_dart().into_dart()].into_dart() } - crate::model::SendDestination::Bolt11 { invoice } => { - [1.into_dart(), invoice.into_into_dart().into_dart()].into_dart() - } + crate::model::SendDestination::Bolt11 { + invoice, + bip353_address, + } => [ + 1.into_dart(), + invoice.into_into_dart().into_dart(), + bip353_address.into_into_dart().into_dart(), + ] + .into_dart(), crate::model::SendDestination::Bolt12 { offer, receiver_amount_sat, + bip353_address, } => [ 2.into_dart(), offer.into_into_dart().into_dart(), receiver_amount_sat.into_into_dart().into_dart(), + bip353_address.into_into_dart().into_dart(), ] .into_dart(), _ => { @@ -7556,9 +7603,13 @@ impl SseEncode for crate::bindings::InputType { ::sse_encode(2, serializer); ::sse_encode(invoice, serializer); } - crate::bindings::InputType::Bolt12Offer { offer } => { + crate::bindings::InputType::Bolt12Offer { + offer, + bip353_address, + } => { ::sse_encode(3, serializer); ::sse_encode(offer, serializer); + >::sse_encode(bip353_address, serializer); } crate::bindings::InputType::NodeId { node_id } => { ::sse_encode(4, serializer); @@ -7568,9 +7619,13 @@ impl SseEncode for crate::bindings::InputType { ::sse_encode(5, serializer); ::sse_encode(url, serializer); } - crate::bindings::InputType::LnUrlPay { data } => { + crate::bindings::InputType::LnUrlPay { + data, + bip353_address, + } => { ::sse_encode(6, serializer); ::sse_encode(data, serializer); + >::sse_encode(bip353_address, serializer); } crate::bindings::InputType::LnUrlWithdraw { data } => { ::sse_encode(7, serializer); @@ -8486,6 +8541,7 @@ impl SseEncode for crate::model::PaymentDetails { payment_hash, destination_pubkey, lnurl_info, + bip353_address, claim_tx_id, refund_tx_id, refund_tx_amount_sat, @@ -8500,6 +8556,7 @@ impl SseEncode for crate::model::PaymentDetails { >::sse_encode(payment_hash, serializer); >::sse_encode(destination_pubkey, serializer); >::sse_encode(lnurl_info, serializer); + >::sse_encode(bip353_address, serializer); >::sse_encode(claim_tx_id, serializer); >::sse_encode(refund_tx_id, serializer); >::sse_encode(refund_tx_amount_sat, serializer); @@ -8709,6 +8766,7 @@ impl SseEncode for crate::model::PrepareLnUrlPayRequest { fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) { ::sse_encode(self.data, serializer); ::sse_encode(self.amount, serializer); + >::sse_encode(self.bip353_address, serializer); >::sse_encode(self.comment, serializer); >::sse_encode(self.validate_success_action_url, serializer); } @@ -8986,17 +9044,23 @@ impl SseEncode for crate::model::SendDestination { ::sse_encode(0, serializer); ::sse_encode(address_data, serializer); } - crate::model::SendDestination::Bolt11 { invoice } => { + crate::model::SendDestination::Bolt11 { + invoice, + bip353_address, + } => { ::sse_encode(1, serializer); ::sse_encode(invoice, serializer); + >::sse_encode(bip353_address, serializer); } crate::model::SendDestination::Bolt12 { offer, receiver_amount_sat, + bip353_address, } => { ::sse_encode(2, serializer); ::sse_encode(offer, serializer); ::sse_encode(receiver_amount_sat, serializer); + >::sse_encode(bip353_address, serializer); } _ => { unimplemented!(""); @@ -9958,6 +10022,7 @@ mod io { let ans = unsafe { self.kind.Bolt12Offer }; crate::bindings::InputType::Bolt12Offer { offer: ans.offer.cst_decode(), + bip353_address: ans.bip353_address.cst_decode(), } } 4 => { @@ -9976,6 +10041,7 @@ mod io { let ans = unsafe { self.kind.LnUrlPay }; crate::bindings::InputType::LnUrlPay { data: ans.data.cst_decode(), + bip353_address: ans.bip353_address.cst_decode(), } } 7 => { @@ -10716,6 +10782,7 @@ mod io { payment_hash: ans.payment_hash.cst_decode(), destination_pubkey: ans.destination_pubkey.cst_decode(), lnurl_info: ans.lnurl_info.cst_decode(), + bip353_address: ans.bip353_address.cst_decode(), claim_tx_id: ans.claim_tx_id.cst_decode(), refund_tx_id: ans.refund_tx_id.cst_decode(), refund_tx_amount_sat: ans.refund_tx_amount_sat.cst_decode(), @@ -10862,6 +10929,7 @@ mod io { crate::model::PrepareLnUrlPayRequest { data: self.data.cst_decode(), amount: self.amount.cst_decode(), + bip353_address: self.bip353_address.cst_decode(), comment: self.comment.cst_decode(), validate_success_action_url: self.validate_success_action_url.cst_decode(), } @@ -11170,6 +11238,7 @@ mod io { let ans = unsafe { self.kind.Bolt11 }; crate::model::SendDestination::Bolt11 { invoice: ans.invoice.cst_decode(), + bip353_address: ans.bip353_address.cst_decode(), } } 2 => { @@ -11177,6 +11246,7 @@ mod io { crate::model::SendDestination::Bolt12 { offer: ans.offer.cst_decode(), receiver_amount_sat: ans.receiver_amount_sat.cst_decode(), + bip353_address: ans.bip353_address.cst_decode(), } } _ => unreachable!(), @@ -12178,6 +12248,7 @@ mod io { Self { data: Default::default(), amount: Default::default(), + bip353_address: core::ptr::null_mut(), comment: core::ptr::null_mut(), validate_success_action_url: core::ptr::null_mut(), } @@ -13888,6 +13959,7 @@ mod io { #[derive(Clone, Copy)] pub struct wire_cst_InputType_Bolt12Offer { offer: *mut wire_cst_ln_offer, + bip353_address: *mut wire_cst_list_prim_u_8_strict, } #[repr(C)] #[derive(Clone, Copy)] @@ -13903,6 +13975,7 @@ mod io { #[derive(Clone, Copy)] pub struct wire_cst_InputType_LnUrlPay { data: *mut wire_cst_ln_url_pay_request_data, + bip353_address: *mut wire_cst_list_prim_u_8_strict, } #[repr(C)] #[derive(Clone, Copy)] @@ -14511,6 +14584,7 @@ mod io { 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, + bip353_address: *mut wire_cst_list_prim_u_8_strict, claim_tx_id: *mut wire_cst_list_prim_u_8_strict, refund_tx_id: *mut wire_cst_list_prim_u_8_strict, refund_tx_amount_sat: *mut u64, @@ -14631,6 +14705,7 @@ mod io { pub struct wire_cst_prepare_ln_url_pay_request { data: wire_cst_ln_url_pay_request_data, amount: wire_cst_pay_amount, + bip353_address: *mut wire_cst_list_prim_u_8_strict, comment: *mut wire_cst_list_prim_u_8_strict, validate_success_action_url: *mut bool, } @@ -14895,12 +14970,14 @@ mod io { #[derive(Clone, Copy)] pub struct wire_cst_SendDestination_Bolt11 { invoice: *mut wire_cst_ln_invoice, + bip353_address: *mut wire_cst_list_prim_u_8_strict, } #[repr(C)] #[derive(Clone, Copy)] pub struct wire_cst_SendDestination_Bolt12 { offer: *mut wire_cst_ln_offer, receiver_amount_sat: u64, + bip353_address: *mut wire_cst_list_prim_u_8_strict, } #[repr(C)] #[derive(Clone, Copy)] diff --git a/lib/core/src/model.rs b/lib/core/src/model.rs index 0847fbd..00308ed 100644 --- a/lib/core/src/model.rs +++ b/lib/core/src/model.rs @@ -513,10 +513,14 @@ pub enum SendDestination { }, Bolt11 { invoice: LNInvoice, + /// A BIP353 address, in case one was used to resolve this BOLT11 + bip353_address: Option, }, Bolt12 { offer: LNOffer, receiver_amount_sat: u64, + /// A BIP353 address, in case one was used to resolve this BOLT12 + bip353_address: Option, }, } @@ -1596,6 +1600,9 @@ pub enum PaymentDetails { /// The payment LNURL info lnurl_info: Option, + /// The BIP353 address used to resolve this payment + bip353_address: Option, + /// For a Receive payment, this is the claim tx id in case it has already been broadcast claim_tx_id: Option, @@ -1947,10 +1954,13 @@ impl From for InternalSwapTree { /// An argument when calling [crate::sdk::LiquidSdk::prepare_lnurl_pay]. #[derive(Debug, Serialize)] pub struct PrepareLnUrlPayRequest { - /// The [LnUrlPayRequestData] returned by [crate::input_parser::parse] + /// The [LnUrlPayRequestData] returned by [parse] pub data: LnUrlPayRequestData, /// The amount to send pub amount: PayAmount, + /// A BIP353 address, in case one was used in order to fetch the LNURL Pay request data. + /// Returned by [parse]. + pub bip353_address: Option, /// An optional comment for this payment pub comment: Option, /// Validates that, if there is a URL success action, the URL domain matches @@ -1965,7 +1975,7 @@ pub struct PrepareLnUrlPayResponse { pub destination: SendDestination, /// The fees in satoshis to send the payment pub fees_sat: u64, - /// The [LnUrlPayRequestData] returned by [crate::input_parser::parse] + /// The [LnUrlPayRequestData] returned by [parse] pub data: LnUrlPayRequestData, /// An optional comment for this payment pub comment: Option, diff --git a/lib/core/src/persist/migrations.rs b/lib/core/src/persist/migrations.rs index cf289c1..34d8f7e 100644 --- a/lib/core/src/persist/migrations.rs +++ b/lib/core/src/persist/migrations.rs @@ -291,5 +291,6 @@ pub(crate) fn current_migrations(network: LiquidNetwork) -> Vec<&'static str> { ) STRICT; ", insert_default_asset_metadata, + "ALTER TABLE payment_details ADD COLUMN bip353_address TEXT;", ] } diff --git a/lib/core/src/persist/mod.rs b/lib/core/src/persist/mod.rs index 1be4ae3..cfed934 100644 --- a/lib/core/src/persist/mod.rs +++ b/lib/core/src/persist/mod.rs @@ -299,18 +299,20 @@ impl Persister { con.execute( &format!( "INSERT INTO payment_details ( - tx_id, - destination, - description, - lnurl_info_json - ) - VALUES (?, ?, ?, ?) - ON CONFLICT (tx_id) - DO UPDATE SET - {destination_update} - description = COALESCE(excluded.description, description), - lnurl_info_json = COALESCE(excluded.lnurl_info_json, lnurl_info_json) - " + tx_id, + destination, + description, + lnurl_info_json, + bip353_address + ) + VALUES (?, ?, ?, ?, ?) + ON CONFLICT (tx_id) + DO UPDATE SET + {destination_update} + description = COALESCE(excluded.description, description), + lnurl_info_json = COALESCE(excluded.lnurl_info_json, lnurl_info_json), + bip353_address = COALESCE(excluded.bip353_address, bip353_address) + " ), ( &payment_tx_details.tx_id, @@ -320,6 +322,7 @@ impl Persister { .lnurl_info .as_ref() .map(|info| serde_json::to_string(&info).ok()), + &payment_tx_details.bip353_address, ), )?; Ok(()) @@ -348,7 +351,7 @@ impl Persister { pub(crate) fn get_payment_details(&self, tx_id: &str) -> Result> { let con = self.get_connection()?; let mut stmt = con.prepare( - "SELECT destination, description, lnurl_info_json + "SELECT destination, description, lnurl_info_json, bip353_address FROM payment_details WHERE tx_id = ?", )?; @@ -356,12 +359,14 @@ impl Persister { let destination = row.get(0)?; let description = row.get(1)?; let maybe_lnurl_info_json: Option = row.get(2)?; + let maybe_bip353_address = row.get(3)?; Ok(PaymentTxDetails { tx_id: tx_id.to_string(), destination, description, lnurl_info: maybe_lnurl_info_json .and_then(|info| serde_json::from_str::(&info).ok()), + bip353_address: maybe_bip353_address, }) }); Ok(res.ok()) @@ -456,6 +461,7 @@ impl Persister { pd.destination, pd.description, pd.lnurl_info_json, + pd.bip353_address, am.name, am.ticker, am.precision @@ -577,10 +583,11 @@ impl Persister { let maybe_payment_details_lnurl_info_json: Option = row.get(54)?; let maybe_payment_details_lnurl_info: Option = maybe_payment_details_lnurl_info_json.and_then(|info| serde_json::from_str(&info).ok()); + let maybe_payment_details_bip353_address: Option = row.get(55)?; - let maybe_asset_metadata_name: Option = row.get(55)?; - let maybe_asset_metadata_ticker: Option = row.get(56)?; - let maybe_asset_metadata_precision: Option = row.get(57)?; + let maybe_asset_metadata_name: Option = row.get(56)?; + let maybe_asset_metadata_ticker: Option = row.get(57)?; + let maybe_asset_metadata_precision: Option = row.get(58)?; let (swap, payment_type) = match maybe_receive_swap_id { Some(receive_swap_id) => { @@ -742,6 +749,7 @@ impl Persister { }) }), lnurl_info: maybe_payment_details_lnurl_info, + bip353_address: maybe_payment_details_bip353_address, claim_tx_id: maybe_claim_tx_id, refund_tx_id, refund_tx_amount_sat, diff --git a/lib/core/src/persist/model.rs b/lib/core/src/persist/model.rs index 309d725..7e953ae 100644 --- a/lib/core/src/persist/model.rs +++ b/lib/core/src/persist/model.rs @@ -6,4 +6,5 @@ pub(crate) struct PaymentTxDetails { pub(crate) destination: String, pub(crate) description: Option, pub(crate) lnurl_info: Option, + pub(crate) bip353_address: Option, } diff --git a/lib/core/src/sdk.rs b/lib/core/src/sdk.rs index d9f7f1e..9c4f56f 100644 --- a/lib/core/src/sdk.rs +++ b/lib/core/src/sdk.rs @@ -1095,7 +1095,10 @@ impl LiquidSdk { ( invoice_amount_sat, fees_sat, - SendDestination::Bolt11 { invoice }, + SendDestination::Bolt11 { + invoice, + bip353_address: None, + }, ) } (None, _) => { @@ -1109,12 +1112,18 @@ impl LiquidSdk { ( invoice_amount_sat, fees_sat, - SendDestination::Bolt11 { invoice }, + SendDestination::Bolt11 { + invoice, + bip353_address: None, + }, ) } }; } - Ok(InputType::Bolt12Offer { offer }) => { + Ok(InputType::Bolt12Offer { + offer, + bip353_address, + }) => { receiver_amount_sat = match req.amount { Some(PayAmount::Bitcoin { receiver_amount_sat: amount_sat, @@ -1144,6 +1153,7 @@ impl LiquidSdk { payment_destination = SendDestination::Bolt12 { offer, receiver_amount_sat, + bip353_address, }; } _ => { @@ -1235,19 +1245,54 @@ impl LiquidSdk { self.pay_liquid(liquid_address_data.clone(), amount_sat, *fees_sat, true) .await } - SendDestination::Bolt11 { invoice } => { - self.pay_bolt11_invoice(&invoice.bolt11, *fees_sat).await + SendDestination::Bolt11 { + invoice, + bip353_address, + } => { + let response = self.pay_bolt11_invoice(&invoice.bolt11, *fees_sat).await?; + if bip353_address.is_some() { + if let (Some(tx_id), Some(destination)) = + (&response.payment.tx_id, &response.payment.destination) + { + self.persister + .insert_or_update_payment_details(PaymentTxDetails { + tx_id: tx_id.clone(), + destination: destination.clone(), + description: None, + lnurl_info: None, + bip353_address: bip353_address.clone(), + })?; + } + } + Ok(response) } SendDestination::Bolt12 { offer, receiver_amount_sat, + bip353_address, } => { let bolt12_invoice = self .swapper .get_bolt12_invoice(&offer.offer, *receiver_amount_sat) .await?; - self.pay_bolt12_invoice(offer, *receiver_amount_sat, &bolt12_invoice, *fees_sat) - .await + let response = self + .pay_bolt12_invoice(offer, *receiver_amount_sat, &bolt12_invoice, *fees_sat) + .await?; + if bip353_address.is_some() { + if let (Some(tx_id), Some(destination)) = + (&response.payment.tx_id, &response.payment.destination) + { + self.persister + .insert_or_update_payment_details(PaymentTxDetails { + tx_id: tx_id.clone(), + destination: destination.clone(), + description: None, + lnurl_info: None, + bip353_address: bip353_address.clone(), + })?; + } + } + Ok(response) } } } @@ -3092,13 +3137,18 @@ impl LiquidSdk { /// * `amount` - The optional amount of type [PayAmount]. /// - [PayAmount::Drain] which uses all funds /// - [PayAmount::Receiver] which sets the amount the receiver should receive + /// * `bip353_address` - A BIP353 address, in case one was used in order to fetch the LNURL + /// Pay request data. Returned by [parse]. /// * `comment` - an optional comment for this payment /// * `validate_success_action_url` - validates that, if there is a URL success action, the URL domain matches /// the LNURL callback domain. Defaults to 'true' /// /// # Returns /// Returns a [PrepareLnUrlPayResponse] containing: - /// * `prepare_send_response` - the prepared [PrepareSendResponse] for the retreived invoice + /// * `destination` - the destination of the payment + /// * `fees_sat` - The fees in satoshis to send the payment + /// * `data` - The [LnUrlPayRequestData] returned by [parse] + /// * `comment` - An optional comment for this payment /// * `success_action` - the optional unprocessed LUD-09 success action pub async fn prepare_lnurl_pay( &self, @@ -3178,8 +3228,20 @@ impl LiquidSdk { .await .map_err(|e| LnUrlPayError::Generic { err: e.to_string() })?; + let destination = + if let SendDestination::Bolt11 { invoice, .. } = prepare_response.destination { + SendDestination::Bolt11 { + invoice, + bip353_address: req.bip353_address, + } + } else { + return Err(LnUrlPayError::Generic { + err: "SendDestination for LNURL Pay is not BOLT11 invoice".to_string(), + }); + }; + Ok(PrepareLnUrlPayResponse { - destination: prepare_response.destination, + destination, fees_sat: prepare_response.fees_sat, data: req.data, comment: req.comment, @@ -3209,7 +3271,7 @@ impl LiquidSdk { let payment = self .send_payment(&SendPaymentRequest { prepare_response: PrepareSendResponse { - destination: prepare_response.destination, + destination: prepare_response.destination.clone(), fees_sat: prepare_response.fees_sat, }, }) @@ -3291,6 +3353,7 @@ impl LiquidSdk { lnurl_pay_unprocessed_success_action: prepare_response.success_action, lnurl_withdraw_endpoint: None, }), + bip353_address: None, })?; } @@ -3354,6 +3417,7 @@ impl LiquidSdk { lnurl_withdraw_endpoint: Some(req.data.callback), ..Default::default() }), + bip353_address: None, })?; } } diff --git a/lib/core/src/send_swap.rs b/lib/core/src/send_swap.rs index 3d0ef8a..dcf1124 100644 --- a/lib/core/src/send_swap.rs +++ b/lib/core/src/send_swap.rs @@ -285,6 +285,7 @@ impl SendSwapHandler { destination, description, lnurl_info: Some(mut lnurl_info), + bip353_address, .. }) = self.persister.get_payment_details(&tx_id)? { @@ -311,6 +312,7 @@ impl SendSwapHandler { destination, description, lnurl_info: Some(lnurl_info), + bip353_address, })?; return Ok(true); } diff --git a/lib/core/src/sync/model/data.rs b/lib/core/src/sync/model/data.rs index fce8d75..31e2615 100644 --- a/lib/core/src/sync/model/data.rs +++ b/lib/core/src/sync/model/data.rs @@ -304,6 +304,7 @@ pub(crate) struct PaymentDetailsSyncData { pub(crate) destination: String, pub(crate) description: Option, pub(crate) lnurl_info: Option, + pub(crate) bip353_address: Option, } impl PaymentDetailsSyncData { @@ -313,6 +314,7 @@ impl PaymentDetailsSyncData { "destination" => self.destination.clone_from(&other.destination), "description" => clone_if_set(&mut self.description, &other.description), "lnurl_info" => clone_if_set(&mut self.lnurl_info, &other.lnurl_info), + "bip353_address" => clone_if_set(&mut self.bip353_address, &other.bip353_address), _ => continue, } } @@ -326,6 +328,7 @@ impl From for PaymentDetailsSyncData { destination: value.destination, description: value.description, lnurl_info: value.lnurl_info, + bip353_address: value.bip353_address, } } } @@ -337,6 +340,7 @@ impl From for PaymentTxDetails { destination: val.destination, description: val.description, lnurl_info: val.lnurl_info, + bip353_address: val.bip353_address, } } } diff --git a/lib/core/src/sync/model/mod.rs b/lib/core/src/sync/model/mod.rs index 7fa9167..fd5a313 100644 --- a/lib/core/src/sync/model/mod.rs +++ b/lib/core/src/sync/model/mod.rs @@ -20,7 +20,7 @@ pub(crate) mod data; const MESSAGE_PREFIX: &[u8; 13] = b"realtimesync:"; lazy_static! { - static ref CURRENT_SCHEMA_VERSION: Version = Version::parse("0.3.0").unwrap(); + static ref CURRENT_SCHEMA_VERSION: Version = Version::parse("0.4.0").unwrap(); } #[derive(Copy, Clone)] diff --git a/packages/dart/lib/src/bindings.dart b/packages/dart/lib/src/bindings.dart index b2f1597..5e897d8 100644 --- a/packages/dart/lib/src/bindings.dart +++ b/packages/dart/lib/src/bindings.dart @@ -325,6 +325,7 @@ sealed class InputType with _$InputType { }) = InputType_Bolt11; const factory InputType.bolt12Offer({ required LNOffer offer, + String? bip353Address, }) = InputType_Bolt12Offer; const factory InputType.nodeId({ required String nodeId, @@ -334,6 +335,7 @@ sealed class InputType with _$InputType { }) = InputType_Url; const factory InputType.lnUrlPay({ required LnUrlPayRequestData data, + String? bip353Address, }) = InputType_LnUrlPay; const factory InputType.lnUrlWithdraw({ required LnUrlWithdrawRequestData data, diff --git a/packages/dart/lib/src/bindings.freezed.dart b/packages/dart/lib/src/bindings.freezed.dart index cf786c0..aeb88c2 100644 --- a/packages/dart/lib/src/bindings.freezed.dart +++ b/packages/dart/lib/src/bindings.freezed.dart @@ -653,7 +653,7 @@ abstract class _$$InputType_Bolt12OfferImplCopyWith<$Res> { _$InputType_Bolt12OfferImpl value, $Res Function(_$InputType_Bolt12OfferImpl) then) = __$$InputType_Bolt12OfferImplCopyWithImpl<$Res>; @useResult - $Res call({LNOffer offer}); + $Res call({LNOffer offer, String? bip353Address}); } /// @nodoc @@ -670,12 +670,17 @@ class __$$InputType_Bolt12OfferImplCopyWithImpl<$Res> @override $Res call({ Object? offer = null, + Object? bip353Address = freezed, }) { return _then(_$InputType_Bolt12OfferImpl( offer: null == offer ? _value.offer : offer // ignore: cast_nullable_to_non_nullable as LNOffer, + bip353Address: freezed == bip353Address + ? _value.bip353Address + : bip353Address // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -683,14 +688,16 @@ class __$$InputType_Bolt12OfferImplCopyWithImpl<$Res> /// @nodoc class _$InputType_Bolt12OfferImpl extends InputType_Bolt12Offer { - const _$InputType_Bolt12OfferImpl({required this.offer}) : super._(); + const _$InputType_Bolt12OfferImpl({required this.offer, this.bip353Address}) : super._(); @override final LNOffer offer; + @override + final String? bip353Address; @override String toString() { - return 'InputType.bolt12Offer(offer: $offer)'; + return 'InputType.bolt12Offer(offer: $offer, bip353Address: $bip353Address)'; } @override @@ -698,11 +705,12 @@ class _$InputType_Bolt12OfferImpl extends InputType_Bolt12Offer { return identical(this, other) || (other.runtimeType == runtimeType && other is _$InputType_Bolt12OfferImpl && - (identical(other.offer, offer) || other.offer == offer)); + (identical(other.offer, offer) || other.offer == offer) && + (identical(other.bip353Address, bip353Address) || other.bip353Address == bip353Address)); } @override - int get hashCode => Object.hash(runtimeType, offer); + int get hashCode => Object.hash(runtimeType, offer, bip353Address); /// Create a copy of InputType /// with the given fields replaced by the non-null parameter values. @@ -714,10 +722,12 @@ class _$InputType_Bolt12OfferImpl extends InputType_Bolt12Offer { } abstract class InputType_Bolt12Offer extends InputType { - const factory InputType_Bolt12Offer({required final LNOffer offer}) = _$InputType_Bolt12OfferImpl; + const factory InputType_Bolt12Offer({required final LNOffer offer, final String? bip353Address}) = + _$InputType_Bolt12OfferImpl; const InputType_Bolt12Offer._() : super._(); LNOffer get offer; + String? get bip353Address; /// Create a copy of InputType /// with the given fields replaced by the non-null parameter values. @@ -884,7 +894,7 @@ abstract class _$$InputType_LnUrlPayImplCopyWith<$Res> { _$InputType_LnUrlPayImpl value, $Res Function(_$InputType_LnUrlPayImpl) then) = __$$InputType_LnUrlPayImplCopyWithImpl<$Res>; @useResult - $Res call({LnUrlPayRequestData data}); + $Res call({LnUrlPayRequestData data, String? bip353Address}); } /// @nodoc @@ -901,12 +911,17 @@ class __$$InputType_LnUrlPayImplCopyWithImpl<$Res> @override $Res call({ Object? data = null, + Object? bip353Address = freezed, }) { return _then(_$InputType_LnUrlPayImpl( data: null == data ? _value.data : data // ignore: cast_nullable_to_non_nullable as LnUrlPayRequestData, + bip353Address: freezed == bip353Address + ? _value.bip353Address + : bip353Address // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -914,14 +929,16 @@ class __$$InputType_LnUrlPayImplCopyWithImpl<$Res> /// @nodoc class _$InputType_LnUrlPayImpl extends InputType_LnUrlPay { - const _$InputType_LnUrlPayImpl({required this.data}) : super._(); + const _$InputType_LnUrlPayImpl({required this.data, this.bip353Address}) : super._(); @override final LnUrlPayRequestData data; + @override + final String? bip353Address; @override String toString() { - return 'InputType.lnUrlPay(data: $data)'; + return 'InputType.lnUrlPay(data: $data, bip353Address: $bip353Address)'; } @override @@ -929,11 +946,12 @@ class _$InputType_LnUrlPayImpl extends InputType_LnUrlPay { return identical(this, other) || (other.runtimeType == runtimeType && other is _$InputType_LnUrlPayImpl && - (identical(other.data, data) || other.data == data)); + (identical(other.data, data) || other.data == data) && + (identical(other.bip353Address, bip353Address) || other.bip353Address == bip353Address)); } @override - int get hashCode => Object.hash(runtimeType, data); + int get hashCode => Object.hash(runtimeType, data, bip353Address); /// Create a copy of InputType /// with the given fields replaced by the non-null parameter values. @@ -945,10 +963,12 @@ class _$InputType_LnUrlPayImpl extends InputType_LnUrlPay { } abstract class InputType_LnUrlPay extends InputType { - const factory InputType_LnUrlPay({required final LnUrlPayRequestData data}) = _$InputType_LnUrlPayImpl; + const factory InputType_LnUrlPay({required final LnUrlPayRequestData data, final String? bip353Address}) = + _$InputType_LnUrlPayImpl; const InputType_LnUrlPay._() : super._(); LnUrlPayRequestData get data; + String? get bip353Address; /// Create a copy of InputType /// with the given fields replaced by the non-null parameter values. diff --git a/packages/dart/lib/src/frb_generated.dart b/packages/dart/lib/src/frb_generated.dart index 287dacb..e0003d3 100644 --- a/packages/dart/lib/src/frb_generated.dart +++ b/packages/dart/lib/src/frb_generated.dart @@ -2000,6 +2000,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { case 3: return InputType_Bolt12Offer( offer: dco_decode_box_autoadd_ln_offer(raw[1]), + bip353Address: dco_decode_opt_String(raw[2]), ); case 4: return InputType_NodeId( @@ -2012,6 +2013,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { case 6: return InputType_LnUrlPay( data: dco_decode_box_autoadd_ln_url_pay_request_data(raw[1]), + bip353Address: dco_decode_opt_String(raw[2]), ); case 7: return InputType_LnUrlWithdraw( @@ -2791,9 +2793,10 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { paymentHash: dco_decode_opt_String(raw[7]), destinationPubkey: dco_decode_opt_String(raw[8]), lnurlInfo: dco_decode_opt_box_autoadd_ln_url_info(raw[9]), - claimTxId: dco_decode_opt_String(raw[10]), - refundTxId: dco_decode_opt_String(raw[11]), - refundTxAmountSat: dco_decode_opt_box_autoadd_u_64(raw[12]), + bip353Address: dco_decode_opt_String(raw[10]), + claimTxId: dco_decode_opt_String(raw[11]), + refundTxId: dco_decode_opt_String(raw[12]), + refundTxAmountSat: dco_decode_opt_box_autoadd_u_64(raw[13]), ); case 1: return PaymentDetails_Liquid( @@ -2939,12 +2942,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { PrepareLnUrlPayRequest dco_decode_prepare_ln_url_pay_request(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs final arr = raw as List; - if (arr.length != 4) throw Exception('unexpected arr length: expect 4 but see ${arr.length}'); + if (arr.length != 5) throw Exception('unexpected arr length: expect 5 but see ${arr.length}'); return PrepareLnUrlPayRequest( data: dco_decode_ln_url_pay_request_data(arr[0]), amount: dco_decode_pay_amount(arr[1]), - comment: dco_decode_opt_String(arr[2]), - validateSuccessActionUrl: dco_decode_opt_box_autoadd_bool(arr[3]), + bip353Address: dco_decode_opt_String(arr[2]), + comment: dco_decode_opt_String(arr[3]), + validateSuccessActionUrl: dco_decode_opt_box_autoadd_bool(arr[4]), ); } @@ -3268,11 +3272,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { case 1: return SendDestination_Bolt11( invoice: dco_decode_box_autoadd_ln_invoice(raw[1]), + bip353Address: dco_decode_opt_String(raw[2]), ); case 2: return SendDestination_Bolt12( offer: dco_decode_box_autoadd_ln_offer(raw[1]), receiverAmountSat: dco_decode_u_64(raw[2]), + bip353Address: dco_decode_opt_String(raw[3]), ); default: throw Exception("unreachable"); @@ -4159,7 +4165,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return InputType_Bolt11(invoice: var_invoice); case 3: var var_offer = sse_decode_box_autoadd_ln_offer(deserializer); - return InputType_Bolt12Offer(offer: var_offer); + var var_bip353Address = sse_decode_opt_String(deserializer); + return InputType_Bolt12Offer(offer: var_offer, bip353Address: var_bip353Address); case 4: var var_nodeId = sse_decode_String(deserializer); return InputType_NodeId(nodeId: var_nodeId); @@ -4168,7 +4175,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return InputType_Url(url: var_url); case 6: var var_data = sse_decode_box_autoadd_ln_url_pay_request_data(deserializer); - return InputType_LnUrlPay(data: var_data); + var var_bip353Address = sse_decode_opt_String(deserializer); + return InputType_LnUrlPay(data: var_data, bip353Address: var_bip353Address); case 7: var var_data = sse_decode_box_autoadd_ln_url_withdraw_request_data(deserializer); return InputType_LnUrlWithdraw(data: var_data); @@ -5117,6 +5125,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { var var_paymentHash = sse_decode_opt_String(deserializer); var var_destinationPubkey = sse_decode_opt_String(deserializer); var var_lnurlInfo = sse_decode_opt_box_autoadd_ln_url_info(deserializer); + var var_bip353Address = sse_decode_opt_String(deserializer); var var_claimTxId = sse_decode_opt_String(deserializer); var var_refundTxId = sse_decode_opt_String(deserializer); var var_refundTxAmountSat = sse_decode_opt_box_autoadd_u_64(deserializer); @@ -5130,6 +5139,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { paymentHash: var_paymentHash, destinationPubkey: var_destinationPubkey, lnurlInfo: var_lnurlInfo, + bip353Address: var_bip353Address, claimTxId: var_claimTxId, refundTxId: var_refundTxId, refundTxAmountSat: var_refundTxAmountSat); @@ -5276,11 +5286,13 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Sse (Serialization based), see doc to use other codecs var var_data = sse_decode_ln_url_pay_request_data(deserializer); var var_amount = sse_decode_pay_amount(deserializer); + var var_bip353Address = sse_decode_opt_String(deserializer); var var_comment = sse_decode_opt_String(deserializer); var var_validateSuccessActionUrl = sse_decode_opt_box_autoadd_bool(deserializer); return PrepareLnUrlPayRequest( data: var_data, amount: var_amount, + bip353Address: var_bip353Address, comment: var_comment, validateSuccessActionUrl: var_validateSuccessActionUrl); } @@ -5582,11 +5594,14 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { return SendDestination_LiquidAddress(addressData: var_addressData); case 1: var var_invoice = sse_decode_box_autoadd_ln_invoice(deserializer); - return SendDestination_Bolt11(invoice: var_invoice); + var var_bip353Address = sse_decode_opt_String(deserializer); + return SendDestination_Bolt11(invoice: var_invoice, bip353Address: var_bip353Address); case 2: var var_offer = sse_decode_box_autoadd_ln_offer(deserializer); var var_receiverAmountSat = sse_decode_u_64(deserializer); - return SendDestination_Bolt12(offer: var_offer, receiverAmountSat: var_receiverAmountSat); + var var_bip353Address = sse_decode_opt_String(deserializer); + return SendDestination_Bolt12( + offer: var_offer, receiverAmountSat: var_receiverAmountSat, bip353Address: var_bip353Address); default: throw UnimplementedError(''); } @@ -6495,18 +6510,20 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { case InputType_Bolt11(invoice: final invoice): sse_encode_i_32(2, serializer); sse_encode_box_autoadd_ln_invoice(invoice, serializer); - case InputType_Bolt12Offer(offer: final offer): + case InputType_Bolt12Offer(offer: final offer, bip353Address: final bip353Address): sse_encode_i_32(3, serializer); sse_encode_box_autoadd_ln_offer(offer, serializer); + sse_encode_opt_String(bip353Address, serializer); case InputType_NodeId(nodeId: final nodeId): sse_encode_i_32(4, serializer); sse_encode_String(nodeId, serializer); case InputType_Url(url: final url): sse_encode_i_32(5, serializer); sse_encode_String(url, serializer); - case InputType_LnUrlPay(data: final data): + case InputType_LnUrlPay(data: final data, bip353Address: final bip353Address): sse_encode_i_32(6, serializer); sse_encode_box_autoadd_ln_url_pay_request_data(data, serializer); + sse_encode_opt_String(bip353Address, serializer); case InputType_LnUrlWithdraw(data: final data): sse_encode_i_32(7, serializer); sse_encode_box_autoadd_ln_url_withdraw_request_data(data, serializer); @@ -7265,6 +7282,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { paymentHash: final paymentHash, destinationPubkey: final destinationPubkey, lnurlInfo: final lnurlInfo, + bip353Address: final bip353Address, claimTxId: final claimTxId, refundTxId: final refundTxId, refundTxAmountSat: final refundTxAmountSat @@ -7279,6 +7297,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { sse_encode_opt_String(paymentHash, serializer); sse_encode_opt_String(destinationPubkey, serializer); sse_encode_opt_box_autoadd_ln_url_info(lnurlInfo, serializer); + sse_encode_opt_String(bip353Address, serializer); sse_encode_opt_String(claimTxId, serializer); sse_encode_opt_String(refundTxId, serializer); sse_encode_opt_box_autoadd_u_64(refundTxAmountSat, serializer); @@ -7416,6 +7435,7 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { // Codec=Sse (Serialization based), see doc to use other codecs sse_encode_ln_url_pay_request_data(self.data, serializer); sse_encode_pay_amount(self.amount, serializer); + sse_encode_opt_String(self.bip353Address, serializer); sse_encode_opt_String(self.comment, serializer); sse_encode_opt_box_autoadd_bool(self.validateSuccessActionUrl, serializer); } @@ -7642,13 +7662,19 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { case SendDestination_LiquidAddress(addressData: final addressData): sse_encode_i_32(0, serializer); sse_encode_box_autoadd_liquid_address_data(addressData, serializer); - case SendDestination_Bolt11(invoice: final invoice): + case SendDestination_Bolt11(invoice: final invoice, bip353Address: final bip353Address): sse_encode_i_32(1, serializer); sse_encode_box_autoadd_ln_invoice(invoice, serializer); - case SendDestination_Bolt12(offer: final offer, receiverAmountSat: final receiverAmountSat): + sse_encode_opt_String(bip353Address, serializer); + case SendDestination_Bolt12( + offer: final offer, + receiverAmountSat: final receiverAmountSat, + bip353Address: final bip353Address + ): sse_encode_i_32(2, serializer); sse_encode_box_autoadd_ln_offer(offer, serializer); sse_encode_u_64(receiverAmountSat, serializer); + sse_encode_opt_String(bip353Address, serializer); } } diff --git a/packages/dart/lib/src/frb_generated.io.dart b/packages/dart/lib/src/frb_generated.io.dart index 03e2dae..d0b494b 100644 --- a/packages/dart/lib/src/frb_generated.io.dart +++ b/packages/dart/lib/src/frb_generated.io.dart @@ -2624,8 +2624,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } if (apiObj is InputType_Bolt12Offer) { var pre_offer = cst_encode_box_autoadd_ln_offer(apiObj.offer); + var pre_bip353_address = cst_encode_opt_String(apiObj.bip353Address); wireObj.tag = 3; wireObj.kind.Bolt12Offer.offer = pre_offer; + wireObj.kind.Bolt12Offer.bip353_address = pre_bip353_address; return; } if (apiObj is InputType_NodeId) { @@ -2642,8 +2644,10 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } if (apiObj is InputType_LnUrlPay) { var pre_data = cst_encode_box_autoadd_ln_url_pay_request_data(apiObj.data); + var pre_bip353_address = cst_encode_opt_String(apiObj.bip353Address); wireObj.tag = 6; wireObj.kind.LnUrlPay.data = pre_data; + wireObj.kind.LnUrlPay.bip353_address = pre_bip353_address; return; } if (apiObj is InputType_LnUrlWithdraw) { @@ -3126,6 +3130,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { var pre_payment_hash = cst_encode_opt_String(apiObj.paymentHash); var pre_destination_pubkey = cst_encode_opt_String(apiObj.destinationPubkey); var pre_lnurl_info = cst_encode_opt_box_autoadd_ln_url_info(apiObj.lnurlInfo); + var pre_bip353_address = cst_encode_opt_String(apiObj.bip353Address); var pre_claim_tx_id = cst_encode_opt_String(apiObj.claimTxId); var pre_refund_tx_id = cst_encode_opt_String(apiObj.refundTxId); var pre_refund_tx_amount_sat = cst_encode_opt_box_autoadd_u_64(apiObj.refundTxAmountSat); @@ -3139,6 +3144,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { wireObj.kind.Lightning.payment_hash = pre_payment_hash; wireObj.kind.Lightning.destination_pubkey = pre_destination_pubkey; wireObj.kind.Lightning.lnurl_info = pre_lnurl_info; + wireObj.kind.Lightning.bip353_address = pre_bip353_address; wireObj.kind.Lightning.claim_tx_id = pre_claim_tx_id; wireObj.kind.Lightning.refund_tx_id = pre_refund_tx_id; wireObj.kind.Lightning.refund_tx_amount_sat = pre_refund_tx_amount_sat; @@ -3316,6 +3322,7 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { PrepareLnUrlPayRequest apiObj, wire_cst_prepare_ln_url_pay_request wireObj) { cst_api_fill_to_wire_ln_url_pay_request_data(apiObj.data, wireObj.data); cst_api_fill_to_wire_pay_amount(apiObj.amount, wireObj.amount); + wireObj.bip353_address = cst_encode_opt_String(apiObj.bip353Address); wireObj.comment = cst_encode_opt_String(apiObj.comment); wireObj.validate_success_action_url = cst_encode_opt_box_autoadd_bool(apiObj.validateSuccessActionUrl); } @@ -3571,16 +3578,20 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl { } if (apiObj is SendDestination_Bolt11) { var pre_invoice = cst_encode_box_autoadd_ln_invoice(apiObj.invoice); + var pre_bip353_address = cst_encode_opt_String(apiObj.bip353Address); wireObj.tag = 1; wireObj.kind.Bolt11.invoice = pre_invoice; + wireObj.kind.Bolt11.bip353_address = pre_bip353_address; return; } if (apiObj is SendDestination_Bolt12) { var pre_offer = cst_encode_box_autoadd_ln_offer(apiObj.offer); var pre_receiver_amount_sat = cst_encode_u_64(apiObj.receiverAmountSat); + var pre_bip353_address = cst_encode_opt_String(apiObj.bip353Address); wireObj.tag = 2; wireObj.kind.Bolt12.offer = pre_offer; wireObj.kind.Bolt12.receiver_amount_sat = pre_receiver_amount_sat; + wireObj.kind.Bolt12.bip353_address = pre_bip353_address; return; } } @@ -6271,6 +6282,8 @@ final class wire_cst_ln_invoice extends ffi.Struct { final class wire_cst_SendDestination_Bolt11 extends ffi.Struct { external ffi.Pointer invoice; + + external ffi.Pointer bip353_address; } final class wire_cst_list_String extends ffi.Struct { @@ -6339,6 +6352,8 @@ final class wire_cst_SendDestination_Bolt12 extends ffi.Struct { @ffi.Uint64() external int receiver_amount_sat; + + external ffi.Pointer bip353_address; } final class SendDestinationKind extends ffi.Union { @@ -6523,6 +6538,8 @@ final class wire_cst_prepare_ln_url_pay_request extends ffi.Struct { external wire_cst_pay_amount amount; + external ffi.Pointer bip353_address; + external ffi.Pointer comment; external ffi.Pointer validate_success_action_url; @@ -6726,6 +6743,8 @@ final class wire_cst_PaymentDetails_Lightning extends ffi.Struct { external ffi.Pointer lnurl_info; + external ffi.Pointer bip353_address; + external ffi.Pointer claim_tx_id; external ffi.Pointer refund_tx_id; @@ -7158,6 +7177,8 @@ final class wire_cst_InputType_Bolt11 extends ffi.Struct { final class wire_cst_InputType_Bolt12Offer extends ffi.Struct { external ffi.Pointer offer; + + external ffi.Pointer bip353_address; } final class wire_cst_InputType_NodeId extends ffi.Struct { @@ -7170,6 +7191,8 @@ final class wire_cst_InputType_Url extends ffi.Struct { final class wire_cst_InputType_LnUrlPay extends ffi.Struct { external ffi.Pointer data; + + external ffi.Pointer bip353_address; } final class wire_cst_InputType_LnUrlWithdraw extends ffi.Struct { diff --git a/packages/dart/lib/src/model.dart b/packages/dart/lib/src/model.dart index ffb8731..3d082cb 100644 --- a/packages/dart/lib/src/model.dart +++ b/packages/dart/lib/src/model.dart @@ -945,6 +945,9 @@ sealed class PaymentDetails with _$PaymentDetails { /// The payment LNURL info LnUrlInfo? lnurlInfo, + /// The BIP353 address used to resolve this payment + String? bip353Address, + /// For a Receive payment, this is the claim tx id in case it has already been broadcast String? claimTxId, @@ -1145,12 +1148,16 @@ class PrepareBuyBitcoinResponse { /// An argument when calling [crate::sdk::LiquidSdk::prepare_lnurl_pay]. class PrepareLnUrlPayRequest { - /// The [LnUrlPayRequestData] returned by [crate::input_parser::parse] + /// The [LnUrlPayRequestData] returned by [parse] final LnUrlPayRequestData data; /// The amount to send final PayAmount amount; + /// A BIP353 address, in case one was used in order to fetch the LNURL Pay request data. + /// Returned by [parse]. + final String? bip353Address; + /// An optional comment for this payment final String? comment; @@ -1161,12 +1168,18 @@ class PrepareLnUrlPayRequest { const PrepareLnUrlPayRequest({ required this.data, required this.amount, + this.bip353Address, this.comment, this.validateSuccessActionUrl, }); @override - int get hashCode => data.hashCode ^ amount.hashCode ^ comment.hashCode ^ validateSuccessActionUrl.hashCode; + int get hashCode => + data.hashCode ^ + amount.hashCode ^ + bip353Address.hashCode ^ + comment.hashCode ^ + validateSuccessActionUrl.hashCode; @override bool operator ==(Object other) => @@ -1175,6 +1188,7 @@ class PrepareLnUrlPayRequest { runtimeType == other.runtimeType && data == other.data && amount == other.amount && + bip353Address == other.bip353Address && comment == other.comment && validateSuccessActionUrl == other.validateSuccessActionUrl; } @@ -1187,7 +1201,7 @@ class PrepareLnUrlPayResponse { /// The fees in satoshis to send the payment final BigInt feesSat; - /// The [LnUrlPayRequestData] returned by [crate::input_parser::parse] + /// The [LnUrlPayRequestData] returned by [parse] final LnUrlPayRequestData data; /// An optional comment for this payment @@ -1699,10 +1713,16 @@ sealed class SendDestination with _$SendDestination { }) = SendDestination_LiquidAddress; const factory SendDestination.bolt11({ required LNInvoice invoice, + + /// A BIP353 address, in case one was used to resolve this BOLT11 + String? bip353Address, }) = SendDestination_Bolt11; const factory SendDestination.bolt12({ required LNOffer offer, required BigInt receiverAmountSat, + + /// A BIP353 address, in case one was used to resolve this BOLT12 + String? bip353Address, }) = SendDestination_Bolt12; } diff --git a/packages/dart/lib/src/model.freezed.dart b/packages/dart/lib/src/model.freezed.dart index 41adcec..c2f56fd 100644 --- a/packages/dart/lib/src/model.freezed.dart +++ b/packages/dart/lib/src/model.freezed.dart @@ -958,6 +958,7 @@ abstract class _$$PaymentDetails_LightningImplCopyWith<$Res> implements $Payment String? paymentHash, String? destinationPubkey, LnUrlInfo? lnurlInfo, + String? bip353Address, String? claimTxId, String? refundTxId, BigInt? refundTxAmountSat}); @@ -985,6 +986,7 @@ class __$$PaymentDetails_LightningImplCopyWithImpl<$Res> Object? paymentHash = freezed, Object? destinationPubkey = freezed, Object? lnurlInfo = freezed, + Object? bip353Address = freezed, Object? claimTxId = freezed, Object? refundTxId = freezed, Object? refundTxAmountSat = freezed, @@ -1026,6 +1028,10 @@ class __$$PaymentDetails_LightningImplCopyWithImpl<$Res> ? _value.lnurlInfo : lnurlInfo // ignore: cast_nullable_to_non_nullable as LnUrlInfo?, + bip353Address: freezed == bip353Address + ? _value.bip353Address + : bip353Address // ignore: cast_nullable_to_non_nullable + as String?, claimTxId: freezed == claimTxId ? _value.claimTxId : claimTxId // ignore: cast_nullable_to_non_nullable @@ -1055,6 +1061,7 @@ class _$PaymentDetails_LightningImpl extends PaymentDetails_Lightning { this.paymentHash, this.destinationPubkey, this.lnurlInfo, + this.bip353Address, this.claimTxId, this.refundTxId, this.refundTxAmountSat}) @@ -1095,6 +1102,10 @@ class _$PaymentDetails_LightningImpl extends PaymentDetails_Lightning { @override final LnUrlInfo? lnurlInfo; + /// The BIP353 address used to resolve this payment + @override + final String? bip353Address; + /// For a Receive payment, this is the claim tx id in case it has already been broadcast @override final String? claimTxId; @@ -1109,7 +1120,7 @@ class _$PaymentDetails_LightningImpl extends PaymentDetails_Lightning { @override String toString() { - return 'PaymentDetails.lightning(swapId: $swapId, description: $description, liquidExpirationBlockheight: $liquidExpirationBlockheight, preimage: $preimage, invoice: $invoice, bolt12Offer: $bolt12Offer, paymentHash: $paymentHash, destinationPubkey: $destinationPubkey, lnurlInfo: $lnurlInfo, claimTxId: $claimTxId, refundTxId: $refundTxId, refundTxAmountSat: $refundTxAmountSat)'; + return 'PaymentDetails.lightning(swapId: $swapId, description: $description, liquidExpirationBlockheight: $liquidExpirationBlockheight, preimage: $preimage, invoice: $invoice, bolt12Offer: $bolt12Offer, paymentHash: $paymentHash, destinationPubkey: $destinationPubkey, lnurlInfo: $lnurlInfo, bip353Address: $bip353Address, claimTxId: $claimTxId, refundTxId: $refundTxId, refundTxAmountSat: $refundTxAmountSat)'; } @override @@ -1128,6 +1139,7 @@ class _$PaymentDetails_LightningImpl extends PaymentDetails_Lightning { (identical(other.destinationPubkey, destinationPubkey) || other.destinationPubkey == destinationPubkey) && (identical(other.lnurlInfo, lnurlInfo) || other.lnurlInfo == lnurlInfo) && + (identical(other.bip353Address, bip353Address) || other.bip353Address == bip353Address) && (identical(other.claimTxId, claimTxId) || other.claimTxId == claimTxId) && (identical(other.refundTxId, refundTxId) || other.refundTxId == refundTxId) && (identical(other.refundTxAmountSat, refundTxAmountSat) || @@ -1146,6 +1158,7 @@ class _$PaymentDetails_LightningImpl extends PaymentDetails_Lightning { paymentHash, destinationPubkey, lnurlInfo, + bip353Address, claimTxId, refundTxId, refundTxAmountSat); @@ -1170,6 +1183,7 @@ abstract class PaymentDetails_Lightning extends PaymentDetails { final String? paymentHash, final String? destinationPubkey, final LnUrlInfo? lnurlInfo, + final String? bip353Address, final String? claimTxId, final String? refundTxId, final BigInt? refundTxAmountSat}) = _$PaymentDetails_LightningImpl; @@ -1202,6 +1216,9 @@ abstract class PaymentDetails_Lightning extends PaymentDetails { /// The payment LNURL info LnUrlInfo? get lnurlInfo; + /// The BIP353 address used to resolve this payment + String? get bip353Address; + /// For a Receive payment, this is the claim tx id in case it has already been broadcast String? get claimTxId; @@ -2564,7 +2581,7 @@ abstract class _$$SendDestination_Bolt11ImplCopyWith<$Res> { _$SendDestination_Bolt11Impl value, $Res Function(_$SendDestination_Bolt11Impl) then) = __$$SendDestination_Bolt11ImplCopyWithImpl<$Res>; @useResult - $Res call({LNInvoice invoice}); + $Res call({LNInvoice invoice, String? bip353Address}); } /// @nodoc @@ -2581,12 +2598,17 @@ class __$$SendDestination_Bolt11ImplCopyWithImpl<$Res> @override $Res call({ Object? invoice = null, + Object? bip353Address = freezed, }) { return _then(_$SendDestination_Bolt11Impl( invoice: null == invoice ? _value.invoice : invoice // ignore: cast_nullable_to_non_nullable as LNInvoice, + bip353Address: freezed == bip353Address + ? _value.bip353Address + : bip353Address // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -2594,14 +2616,18 @@ class __$$SendDestination_Bolt11ImplCopyWithImpl<$Res> /// @nodoc class _$SendDestination_Bolt11Impl extends SendDestination_Bolt11 { - const _$SendDestination_Bolt11Impl({required this.invoice}) : super._(); + const _$SendDestination_Bolt11Impl({required this.invoice, this.bip353Address}) : super._(); @override final LNInvoice invoice; + /// A BIP353 address, in case one was used to resolve this BOLT11 + @override + final String? bip353Address; + @override String toString() { - return 'SendDestination.bolt11(invoice: $invoice)'; + return 'SendDestination.bolt11(invoice: $invoice, bip353Address: $bip353Address)'; } @override @@ -2609,11 +2635,12 @@ class _$SendDestination_Bolt11Impl extends SendDestination_Bolt11 { return identical(this, other) || (other.runtimeType == runtimeType && other is _$SendDestination_Bolt11Impl && - (identical(other.invoice, invoice) || other.invoice == invoice)); + (identical(other.invoice, invoice) || other.invoice == invoice) && + (identical(other.bip353Address, bip353Address) || other.bip353Address == bip353Address)); } @override - int get hashCode => Object.hash(runtimeType, invoice); + int get hashCode => Object.hash(runtimeType, invoice, bip353Address); /// Create a copy of SendDestination /// with the given fields replaced by the non-null parameter values. @@ -2625,11 +2652,15 @@ class _$SendDestination_Bolt11Impl extends SendDestination_Bolt11 { } abstract class SendDestination_Bolt11 extends SendDestination { - const factory SendDestination_Bolt11({required final LNInvoice invoice}) = _$SendDestination_Bolt11Impl; + const factory SendDestination_Bolt11({required final LNInvoice invoice, final String? bip353Address}) = + _$SendDestination_Bolt11Impl; const SendDestination_Bolt11._() : super._(); LNInvoice get invoice; + /// A BIP353 address, in case one was used to resolve this BOLT11 + String? get bip353Address; + /// Create a copy of SendDestination /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -2643,7 +2674,7 @@ abstract class _$$SendDestination_Bolt12ImplCopyWith<$Res> { _$SendDestination_Bolt12Impl value, $Res Function(_$SendDestination_Bolt12Impl) then) = __$$SendDestination_Bolt12ImplCopyWithImpl<$Res>; @useResult - $Res call({LNOffer offer, BigInt receiverAmountSat}); + $Res call({LNOffer offer, BigInt receiverAmountSat, String? bip353Address}); } /// @nodoc @@ -2661,6 +2692,7 @@ class __$$SendDestination_Bolt12ImplCopyWithImpl<$Res> $Res call({ Object? offer = null, Object? receiverAmountSat = null, + Object? bip353Address = freezed, }) { return _then(_$SendDestination_Bolt12Impl( offer: null == offer @@ -2671,6 +2703,10 @@ class __$$SendDestination_Bolt12ImplCopyWithImpl<$Res> ? _value.receiverAmountSat : receiverAmountSat // ignore: cast_nullable_to_non_nullable as BigInt, + bip353Address: freezed == bip353Address + ? _value.bip353Address + : bip353Address // ignore: cast_nullable_to_non_nullable + as String?, )); } } @@ -2678,16 +2714,22 @@ class __$$SendDestination_Bolt12ImplCopyWithImpl<$Res> /// @nodoc class _$SendDestination_Bolt12Impl extends SendDestination_Bolt12 { - const _$SendDestination_Bolt12Impl({required this.offer, required this.receiverAmountSat}) : super._(); + const _$SendDestination_Bolt12Impl( + {required this.offer, required this.receiverAmountSat, this.bip353Address}) + : super._(); @override final LNOffer offer; @override final BigInt receiverAmountSat; + /// A BIP353 address, in case one was used to resolve this BOLT12 + @override + final String? bip353Address; + @override String toString() { - return 'SendDestination.bolt12(offer: $offer, receiverAmountSat: $receiverAmountSat)'; + return 'SendDestination.bolt12(offer: $offer, receiverAmountSat: $receiverAmountSat, bip353Address: $bip353Address)'; } @override @@ -2697,11 +2739,12 @@ class _$SendDestination_Bolt12Impl extends SendDestination_Bolt12 { other is _$SendDestination_Bolt12Impl && (identical(other.offer, offer) || other.offer == offer) && (identical(other.receiverAmountSat, receiverAmountSat) || - other.receiverAmountSat == receiverAmountSat)); + other.receiverAmountSat == receiverAmountSat) && + (identical(other.bip353Address, bip353Address) || other.bip353Address == bip353Address)); } @override - int get hashCode => Object.hash(runtimeType, offer, receiverAmountSat); + int get hashCode => Object.hash(runtimeType, offer, receiverAmountSat, bip353Address); /// Create a copy of SendDestination /// with the given fields replaced by the non-null parameter values. @@ -2714,12 +2757,17 @@ class _$SendDestination_Bolt12Impl extends SendDestination_Bolt12 { abstract class SendDestination_Bolt12 extends SendDestination { const factory SendDestination_Bolt12( - {required final LNOffer offer, required final BigInt receiverAmountSat}) = _$SendDestination_Bolt12Impl; + {required final LNOffer offer, + required final BigInt receiverAmountSat, + final String? bip353Address}) = _$SendDestination_Bolt12Impl; const SendDestination_Bolt12._() : super._(); LNOffer get offer; BigInt get receiverAmountSat; + /// A BIP353 address, in case one was used to resolve this BOLT12 + String? get bip353Address; + /// Create a copy of SendDestination /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) diff --git a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart index 24b1c58..335884f 100644 --- a/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart +++ b/packages/flutter/lib/flutter_breez_liquid_bindings_generated.dart @@ -4354,6 +4354,8 @@ final class wire_cst_ln_invoice extends ffi.Struct { final class wire_cst_SendDestination_Bolt11 extends ffi.Struct { external ffi.Pointer invoice; + + external ffi.Pointer bip353_address; } final class wire_cst_list_String extends ffi.Struct { @@ -4422,6 +4424,8 @@ final class wire_cst_SendDestination_Bolt12 extends ffi.Struct { @ffi.Uint64() external int receiver_amount_sat; + + external ffi.Pointer bip353_address; } final class SendDestinationKind extends ffi.Union { @@ -4606,6 +4610,8 @@ final class wire_cst_prepare_ln_url_pay_request extends ffi.Struct { external wire_cst_pay_amount amount; + external ffi.Pointer bip353_address; + external ffi.Pointer comment; external ffi.Pointer validate_success_action_url; @@ -4809,6 +4815,8 @@ final class wire_cst_PaymentDetails_Lightning extends ffi.Struct { external ffi.Pointer lnurl_info; + external ffi.Pointer bip353_address; + external ffi.Pointer claim_tx_id; external ffi.Pointer refund_tx_id; @@ -5241,6 +5249,8 @@ final class wire_cst_InputType_Bolt11 extends ffi.Struct { final class wire_cst_InputType_Bolt12Offer extends ffi.Struct { external ffi.Pointer offer; + + external ffi.Pointer bip353_address; } final class wire_cst_InputType_NodeId extends ffi.Struct { @@ -5253,6 +5263,8 @@ final class wire_cst_InputType_Url extends ffi.Struct { final class wire_cst_InputType_LnUrlPay extends ffi.Struct { external ffi.Pointer data; + + external ffi.Pointer bip353_address; } final class wire_cst_InputType_LnUrlWithdraw extends ffi.Struct { diff --git a/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt b/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt index c99952e..da5dff6 100644 --- a/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt +++ b/packages/react-native/android/src/main/java/com/breezsdkliquid/BreezSDKLiquidMapper.kt @@ -1889,6 +1889,16 @@ fun asPrepareLnUrlPayRequest(prepareLnUrlPayRequest: ReadableMap): PrepareLnUrlP } val data = prepareLnUrlPayRequest.getMap("data")?.let { asLnUrlPayRequestData(it) }!! val amount = prepareLnUrlPayRequest.getMap("amount")?.let { asPayAmount(it) }!! + val bip353Address = + if (hasNonNullKey( + prepareLnUrlPayRequest, + "bip353Address", + ) + ) { + prepareLnUrlPayRequest.getString("bip353Address") + } else { + null + } val comment = if (hasNonNullKey(prepareLnUrlPayRequest, "comment")) prepareLnUrlPayRequest.getString("comment") else null val validateSuccessActionUrl = if (hasNonNullKey( @@ -1900,13 +1910,14 @@ fun asPrepareLnUrlPayRequest(prepareLnUrlPayRequest: ReadableMap): PrepareLnUrlP } else { null } - return PrepareLnUrlPayRequest(data, amount, comment, validateSuccessActionUrl) + return PrepareLnUrlPayRequest(data, amount, bip353Address, comment, validateSuccessActionUrl) } fun readableMapOf(prepareLnUrlPayRequest: PrepareLnUrlPayRequest): ReadableMap = readableMapOf( "data" to readableMapOf(prepareLnUrlPayRequest.data), "amount" to readableMapOf(prepareLnUrlPayRequest.amount), + "bip353Address" to prepareLnUrlPayRequest.bip353Address, "comment" to prepareLnUrlPayRequest.comment, "validateSuccessActionUrl" to prepareLnUrlPayRequest.validateSuccessActionUrl, ) @@ -3056,7 +3067,8 @@ fun asInputType(inputType: ReadableMap): InputType? { } if (type == "bolt12Offer") { val offer = inputType.getMap("offer")?.let { asLnOffer(it) }!! - return InputType.Bolt12Offer(offer) + val bip353Address = if (hasNonNullKey(inputType, "bip353Address")) inputType.getString("bip353Address") else null + return InputType.Bolt12Offer(offer, bip353Address) } if (type == "nodeId") { val nodeId = inputType.getString("nodeId")!! @@ -3068,7 +3080,8 @@ fun asInputType(inputType: ReadableMap): InputType? { } if (type == "lnUrlPay") { val data = inputType.getMap("data")?.let { asLnUrlPayRequestData(it) }!! - return InputType.LnUrlPay(data) + val bip353Address = if (hasNonNullKey(inputType, "bip353Address")) inputType.getString("bip353Address") else null + return InputType.LnUrlPay(data, bip353Address) } if (type == "lnUrlWithdraw") { val data = inputType.getMap("data")?.let { asLnUrlWithdrawRequestData(it) }!! @@ -3103,6 +3116,7 @@ fun readableMapOf(inputType: InputType): ReadableMap? { is InputType.Bolt12Offer -> { pushToMap(map, "type", "bolt12Offer") pushToMap(map, "offer", readableMapOf(inputType.offer)) + pushToMap(map, "bip353Address", inputType.bip353Address) } is InputType.NodeId -> { pushToMap(map, "type", "nodeId") @@ -3115,6 +3129,7 @@ fun readableMapOf(inputType: InputType): ReadableMap? { is InputType.LnUrlPay -> { pushToMap(map, "type", "lnUrlPay") pushToMap(map, "data", readableMapOf(inputType.data)) + pushToMap(map, "bip353Address", inputType.bip353Address) } is InputType.LnUrlWithdraw -> { pushToMap(map, "type", "lnUrlWithdraw") @@ -3424,6 +3439,7 @@ fun asPaymentDetails(paymentDetails: ReadableMap): PaymentDetails? { } else { null } + val bip353Address = if (hasNonNullKey(paymentDetails, "bip353Address")) paymentDetails.getString("bip353Address") else null val claimTxId = if (hasNonNullKey(paymentDetails, "claimTxId")) paymentDetails.getString("claimTxId") else null val refundTxId = if (hasNonNullKey(paymentDetails, "refundTxId")) paymentDetails.getString("refundTxId") else null val refundTxAmountSat = @@ -3446,6 +3462,7 @@ fun asPaymentDetails(paymentDetails: ReadableMap): PaymentDetails? { paymentHash, destinationPubkey, lnurlInfo, + bip353Address, claimTxId, refundTxId, refundTxAmountSat, @@ -3531,6 +3548,7 @@ fun readableMapOf(paymentDetails: PaymentDetails): ReadableMap? { pushToMap(map, "paymentHash", paymentDetails.paymentHash) pushToMap(map, "destinationPubkey", paymentDetails.destinationPubkey) pushToMap(map, "lnurlInfo", paymentDetails.lnurlInfo?.let { readableMapOf(it) }) + pushToMap(map, "bip353Address", paymentDetails.bip353Address) pushToMap(map, "claimTxId", paymentDetails.claimTxId) pushToMap(map, "refundTxId", paymentDetails.refundTxId) pushToMap(map, "refundTxAmountSat", paymentDetails.refundTxAmountSat) @@ -3752,12 +3770,14 @@ fun asSendDestination(sendDestination: ReadableMap): SendDestination? { } if (type == "bolt11") { val invoice = sendDestination.getMap("invoice")?.let { asLnInvoice(it) }!! - return SendDestination.Bolt11(invoice) + val bip353Address = if (hasNonNullKey(sendDestination, "bip353Address")) sendDestination.getString("bip353Address") else null + return SendDestination.Bolt11(invoice, bip353Address) } if (type == "bolt12") { val offer = sendDestination.getMap("offer")?.let { asLnOffer(it) }!! val receiverAmountSat = sendDestination.getDouble("receiverAmountSat").toULong() - return SendDestination.Bolt12(offer, receiverAmountSat) + val bip353Address = if (hasNonNullKey(sendDestination, "bip353Address")) sendDestination.getString("bip353Address") else null + return SendDestination.Bolt12(offer, receiverAmountSat, bip353Address) } return null } @@ -3772,11 +3792,13 @@ fun readableMapOf(sendDestination: SendDestination): ReadableMap? { is SendDestination.Bolt11 -> { pushToMap(map, "type", "bolt11") pushToMap(map, "invoice", readableMapOf(sendDestination.invoice)) + pushToMap(map, "bip353Address", sendDestination.bip353Address) } is SendDestination.Bolt12 -> { pushToMap(map, "type", "bolt12") pushToMap(map, "offer", readableMapOf(sendDestination.offer)) pushToMap(map, "receiverAmountSat", sendDestination.receiverAmountSat) + pushToMap(map, "bip353Address", sendDestination.bip353Address) } } return map diff --git a/packages/react-native/ios/BreezSDKLiquidMapper.swift b/packages/react-native/ios/BreezSDKLiquidMapper.swift index 15d249a..065692f 100644 --- a/packages/react-native/ios/BreezSDKLiquidMapper.swift +++ b/packages/react-native/ios/BreezSDKLiquidMapper.swift @@ -2227,6 +2227,13 @@ enum BreezSDKLiquidMapper { } let amount = try asPayAmount(payAmount: amountTmp) + var bip353Address: String? + if hasNonNilKey(data: prepareLnUrlPayRequest, key: "bip353Address") { + guard let bip353AddressTmp = prepareLnUrlPayRequest["bip353Address"] as? String else { + throw SdkError.Generic(message: errUnexpectedValue(fieldName: "bip353Address")) + } + bip353Address = bip353AddressTmp + } var comment: String? if hasNonNilKey(data: prepareLnUrlPayRequest, key: "comment") { guard let commentTmp = prepareLnUrlPayRequest["comment"] as? String else { @@ -2242,13 +2249,14 @@ enum BreezSDKLiquidMapper { validateSuccessActionUrl = validateSuccessActionUrlTmp } - return PrepareLnUrlPayRequest(data: data, amount: amount, comment: comment, validateSuccessActionUrl: validateSuccessActionUrl) + return PrepareLnUrlPayRequest(data: data, amount: amount, bip353Address: bip353Address, comment: comment, validateSuccessActionUrl: validateSuccessActionUrl) } static func dictionaryOf(prepareLnUrlPayRequest: PrepareLnUrlPayRequest) -> [String: Any?] { return [ "data": dictionaryOf(lnUrlPayRequestData: prepareLnUrlPayRequest.data), "amount": dictionaryOf(payAmount: prepareLnUrlPayRequest.amount), + "bip353Address": prepareLnUrlPayRequest.bip353Address == nil ? nil : prepareLnUrlPayRequest.bip353Address, "comment": prepareLnUrlPayRequest.comment == nil ? nil : prepareLnUrlPayRequest.comment, "validateSuccessActionUrl": prepareLnUrlPayRequest.validateSuccessActionUrl == nil ? nil : prepareLnUrlPayRequest.validateSuccessActionUrl, ] @@ -3588,7 +3596,9 @@ enum BreezSDKLiquidMapper { } let _offer = try asLnOffer(lnOffer: offerTmp) - return InputType.bolt12Offer(offer: _offer) + let _bip353Address = inputType["bip353Address"] as? String + + return InputType.bolt12Offer(offer: _offer, bip353Address: _bip353Address) } if type == "nodeId" { guard let _nodeId = inputType["nodeId"] as? String else { @@ -3608,7 +3618,9 @@ enum BreezSDKLiquidMapper { } let _data = try asLnUrlPayRequestData(lnUrlPayRequestData: dataTmp) - return InputType.lnUrlPay(data: _data) + let _bip353Address = inputType["bip353Address"] as? String + + return InputType.lnUrlPay(data: _data, bip353Address: _bip353Address) } if type == "lnUrlWithdraw" { guard let dataTmp = inputType["data"] as? [String: Any?] else { @@ -3665,11 +3677,12 @@ enum BreezSDKLiquidMapper { ] case let .bolt12Offer( - offer + offer, bip353Address ): return [ "type": "bolt12Offer", "offer": dictionaryOf(lnOffer: offer), + "bip353Address": bip353Address == nil ? nil : bip353Address, ] case let .nodeId( @@ -3689,11 +3702,12 @@ enum BreezSDKLiquidMapper { ] case let .lnUrlPay( - data + data, bip353Address ): return [ "type": "lnUrlPay", "data": dictionaryOf(lnUrlPayRequestData: data), + "bip353Address": bip353Address == nil ? nil : bip353Address, ] case let .lnUrlWithdraw( @@ -4186,13 +4200,15 @@ enum BreezSDKLiquidMapper { _lnurlInfo = try asLnUrlInfo(lnUrlInfo: lnurlInfoTmp) } + let _bip353Address = paymentDetails["bip353Address"] as? String + let _claimTxId = paymentDetails["claimTxId"] as? String let _refundTxId = paymentDetails["refundTxId"] as? String let _refundTxAmountSat = paymentDetails["refundTxAmountSat"] as? UInt64 - return PaymentDetails.lightning(swapId: _swapId, description: _description, liquidExpirationBlockheight: _liquidExpirationBlockheight, preimage: _preimage, invoice: _invoice, bolt12Offer: _bolt12Offer, paymentHash: _paymentHash, destinationPubkey: _destinationPubkey, lnurlInfo: _lnurlInfo, claimTxId: _claimTxId, refundTxId: _refundTxId, refundTxAmountSat: _refundTxAmountSat) + return PaymentDetails.lightning(swapId: _swapId, description: _description, liquidExpirationBlockheight: _liquidExpirationBlockheight, preimage: _preimage, invoice: _invoice, bolt12Offer: _bolt12Offer, paymentHash: _paymentHash, destinationPubkey: _destinationPubkey, lnurlInfo: _lnurlInfo, bip353Address: _bip353Address, claimTxId: _claimTxId, refundTxId: _refundTxId, refundTxAmountSat: _refundTxAmountSat) } if type == "liquid" { guard let _assetId = paymentDetails["assetId"] as? String else { @@ -4240,7 +4256,7 @@ enum BreezSDKLiquidMapper { static func dictionaryOf(paymentDetails: PaymentDetails) -> [String: Any?] { switch paymentDetails { case let .lightning( - swapId, description, liquidExpirationBlockheight, preimage, invoice, bolt12Offer, paymentHash, destinationPubkey, lnurlInfo, claimTxId, refundTxId, refundTxAmountSat + swapId, description, liquidExpirationBlockheight, preimage, invoice, bolt12Offer, paymentHash, destinationPubkey, lnurlInfo, bip353Address, claimTxId, refundTxId, refundTxAmountSat ): return [ "type": "lightning", @@ -4253,6 +4269,7 @@ enum BreezSDKLiquidMapper { "paymentHash": paymentHash == nil ? nil : paymentHash, "destinationPubkey": destinationPubkey == nil ? nil : destinationPubkey, "lnurlInfo": lnurlInfo == nil ? nil : dictionaryOf(lnUrlInfo: lnurlInfo!), + "bip353Address": bip353Address == nil ? nil : bip353Address, "claimTxId": claimTxId == nil ? nil : claimTxId, "refundTxId": refundTxId == nil ? nil : refundTxId, "refundTxAmountSat": refundTxAmountSat == nil ? nil : refundTxAmountSat, @@ -4699,7 +4716,9 @@ enum BreezSDKLiquidMapper { } let _invoice = try asLnInvoice(lnInvoice: invoiceTmp) - return SendDestination.bolt11(invoice: _invoice) + let _bip353Address = sendDestination["bip353Address"] as? String + + return SendDestination.bolt11(invoice: _invoice, bip353Address: _bip353Address) } if type == "bolt12" { guard let offerTmp = sendDestination["offer"] as? [String: Any?] else { @@ -4710,7 +4729,9 @@ enum BreezSDKLiquidMapper { guard let _receiverAmountSat = sendDestination["receiverAmountSat"] as? UInt64 else { throw SdkError.Generic(message: errMissingMandatoryField(fieldName: "receiverAmountSat", typeName: "SendDestination")) } - return SendDestination.bolt12(offer: _offer, receiverAmountSat: _receiverAmountSat) + let _bip353Address = sendDestination["bip353Address"] as? String + + return SendDestination.bolt12(offer: _offer, receiverAmountSat: _receiverAmountSat, bip353Address: _bip353Address) } throw SdkError.Generic(message: "Unexpected type \(type) for enum SendDestination") @@ -4727,20 +4748,22 @@ enum BreezSDKLiquidMapper { ] case let .bolt11( - invoice + invoice, bip353Address ): return [ "type": "bolt11", "invoice": dictionaryOf(lnInvoice: invoice), + "bip353Address": bip353Address == nil ? nil : bip353Address, ] case let .bolt12( - offer, receiverAmountSat + offer, receiverAmountSat, bip353Address ): return [ "type": "bolt12", "offer": dictionaryOf(lnOffer: offer), "receiverAmountSat": receiverAmountSat, + "bip353Address": bip353Address == nil ? nil : bip353Address, ] } } diff --git a/packages/react-native/src/index.ts b/packages/react-native/src/index.ts index a2b8de1..acdf723 100644 --- a/packages/react-native/src/index.ts +++ b/packages/react-native/src/index.ts @@ -336,6 +336,7 @@ export interface PrepareBuyBitcoinResponse { export interface PrepareLnUrlPayRequest { data: LnUrlPayRequestData amount: PayAmount + bip353Address?: string comment?: string validateSuccessActionUrl?: boolean } @@ -560,6 +561,7 @@ export type InputType = { } | { type: InputTypeVariant.BOLT12_OFFER, offer: LnOffer + bip353Address?: string } | { type: InputTypeVariant.NODE_ID, nodeId: string @@ -569,6 +571,7 @@ export type InputType = { } | { type: InputTypeVariant.LN_URL_PAY, data: LnUrlPayRequestData + bip353Address?: string } | { type: InputTypeVariant.LN_URL_WITHDRAW, data: LnUrlWithdrawRequestData @@ -687,6 +690,7 @@ export type PaymentDetails = { paymentHash?: string destinationPubkey?: string lnurlInfo?: LnUrlInfo + bip353Address?: string claimTxId?: string refundTxId?: string refundTxAmountSat?: number @@ -796,10 +800,12 @@ export type SendDestination = { } | { type: SendDestinationVariant.BOLT11, invoice: LnInvoice + bip353Address?: string } | { type: SendDestinationVariant.BOLT12, offer: LnOffer receiverAmountSat: number + bip353Address?: string } export enum SuccessActionVariant {