Skip to content

Commit

Permalink
Persist and expose BIP353 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgranhao committed Feb 6, 2025
1 parent d139f36 commit f02fe47
Show file tree
Hide file tree
Showing 26 changed files with 468 additions and 107 deletions.
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.

6 changes: 5 additions & 1 deletion cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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,
})
Expand Down
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 @@ -247,6 +247,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 {
Expand Down Expand Up @@ -315,6 +316,7 @@ typedef struct wire_cst_prepare_ln_url_pay_response {
struct wire_cst_send_destination destination;
uint64_t fees_sat;
struct wire_cst_ln_url_pay_request_data data;
struct wire_cst_list_prim_u_8_strict *bip353_address;
struct wire_cst_list_prim_u_8_strict *comment;
struct wire_cst_success_action *success_action;
} wire_cst_prepare_ln_url_pay_response;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -825,6 +829,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 {
Expand All @@ -837,6 +842,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 6 additions & 4 deletions lib/bindings/src/breez_sdk_liquid.udl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -406,6 +406,7 @@ dictionary CheckMessageResponse {
dictionary PrepareLnUrlPayRequest {
LnUrlPayRequestData data;
PayAmount amount;
string? bip353_address = null;
string? comment = null;
boolean? validate_success_action_url = null;
};
Expand All @@ -414,6 +415,7 @@ dictionary PrepareLnUrlPayResponse {
SendDestination destination;
u64 fees_sat;
LnUrlPayRequestData data;
string? bip353_address = null;
string? comment = null;
SuccessAction? success_action = null;
};
Expand All @@ -431,7 +433,7 @@ dictionary PrepareSendRequest {
interface SendDestination {
LiquidAddress(LiquidAddressData address_data);
Bolt11(LNInvoice invoice);
Bolt12(LNOffer offer, u64 receiver_amount_sat);
Bolt12(LNOffer offer, u64 receiver_amount_sat, string? bip353_address);
};

dictionary PrepareSendResponse {
Expand Down Expand Up @@ -606,7 +608,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);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "5a20b38b4c3b574282e8d6e5a61750bb7f4bebed", features = ["liquid"] }
sdk-common = { git = "https://github.com/breez/breez-sdk", rev = "e6cea9b08c75364ea10fbc6e3cd4f925d1aabaa4", features = ["liquid"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.116"
strum = "0.25"
Expand Down
42 changes: 32 additions & 10 deletions lib/core/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
},
NodeId {
node_id: String,
},
Url {
url: String,
},
LnUrlPay {
data: LnUrlPayRequestData,
bip353_address: Option<String>,
},
LnUrlWithdraw {
data: LnUrlWithdrawRequestData,
},
LnUrlAuth {
data: LnUrlAuthRequestData,
},
LnUrlError {
data: LnUrlErrorData,
},
}

#[frb(mirror(BitcoinAddressData))]
Expand Down
Loading

0 comments on commit f02fe47

Please sign in to comment.