Skip to content

Commit

Permalink
feat: add swap expiry timestamp
Browse files Browse the repository at this point in the history
fix(clippy): use `clone_if_set` for sync destination

fix: revert rebase changes

feat: add `expiration_block` to payment details

feat: add `blockchain_details` to `GetInfoResponse`

fix: rename fields to `<chain>_expiry_blockheight`

fix: update `GetInfoResponse` structure

fix: address review comments

taken from
#622 (review)

fix: use better error handling for get_info

fix: bindings tests

fix: ensure blockchain_info is optional in query
  • Loading branch information
dangeross authored and hydra-yse committed Jan 6, 2025
1 parent 6d06580 commit c74d8f0
Show file tree
Hide file tree
Showing 29 changed files with 1,053 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ typedef struct wire_cst_ln_url_info {
typedef struct wire_cst_PaymentDetails_Lightning {
struct wire_cst_list_prim_u_8_strict *swap_id;
struct wire_cst_list_prim_u_8_strict *description;
uint32_t liquid_expiration_blockheight;
struct wire_cst_list_prim_u_8_strict *preimage;
struct wire_cst_list_prim_u_8_strict *bolt11;
struct wire_cst_list_prim_u_8_strict *bolt12_offer;
Expand All @@ -491,6 +492,8 @@ typedef struct wire_cst_PaymentDetails_Liquid {
typedef struct wire_cst_PaymentDetails_Bitcoin {
struct wire_cst_list_prim_u_8_strict *swap_id;
struct wire_cst_list_prim_u_8_strict *description;
uint32_t *liquid_expiration_blockheight;
uint32_t *bitcoin_expiration_blockheight;
struct wire_cst_list_prim_u_8_strict *refund_tx_id;
uint64_t *refund_tx_amount_sat;
} wire_cst_PaymentDetails_Bitcoin;
Expand Down Expand Up @@ -695,16 +698,26 @@ typedef struct wire_cst_list_refundable_swap {
int32_t len;
} wire_cst_list_refundable_swap;

typedef struct wire_cst_blockchain_info {
uint32_t liquid_tip;
uint32_t bitcoin_tip;
} wire_cst_blockchain_info;

typedef struct wire_cst_check_message_response {
bool is_valid;
} wire_cst_check_message_response;

typedef struct wire_cst_get_info_response {
typedef struct wire_cst_wallet_info {
uint64_t balance_sat;
uint64_t pending_send_sat;
uint64_t pending_receive_sat;
struct wire_cst_list_prim_u_8_strict *fingerprint;
struct wire_cst_list_prim_u_8_strict *pubkey;
} wire_cst_wallet_info;

typedef struct wire_cst_get_info_response {
struct wire_cst_wallet_info wallet_info;
struct wire_cst_blockchain_info blockchain_info;
} wire_cst_get_info_response;

typedef struct wire_cst_InputType_BitcoinAddress {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class SwapUpdatedTask : TaskProtocol {
func getSwapId(details: PaymentDetails?) -> String? {
if let details = details {
switch details {
case let .bitcoin(swapId, _, _, _):
case let .bitcoin(swapId, _, _, _, _, _):
return swapId
case let .lightning(swapId, _, _, _, _, _, _, _, _):
case let .lightning(swapId, _, _, _, _, _, _, _, _, _):
return swapId
default:
break
Expand Down
16 changes: 13 additions & 3 deletions lib/bindings/src/breez_sdk_liquid.udl
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,24 @@ dictionary ConnectWithSignerRequest {
Config config;
};

dictionary GetInfoResponse {
dictionary BlockchainInfo {
u32 liquid_tip;
u32 bitcoin_tip;
};

dictionary WalletInfo {
u64 balance_sat;
u64 pending_send_sat;
u64 pending_receive_sat;
string fingerprint;
string pubkey;
};

dictionary GetInfoResponse {
WalletInfo wallet_info;
BlockchainInfo blockchain_info;
};

dictionary SignMessageRequest {
string message;
};
Expand Down Expand Up @@ -569,9 +579,9 @@ dictionary LnUrlInfo {

[Enum]
interface PaymentDetails {
Lightning(string swap_id, string description, string? preimage, string? bolt11, string? bolt12_offer, string? payment_hash, LnUrlInfo? lnurl_info, string? refund_tx_id, u64? refund_tx_amount_sat);
Lightning(string swap_id, string description, u32 liquid_expiration_blockheight, string? preimage, string? bolt11, string? bolt12_offer, string? payment_hash, LnUrlInfo? lnurl_info, string? refund_tx_id, u64? refund_tx_amount_sat);
Liquid(string destination, string description);
Bitcoin(string swap_id, string description, string? refund_tx_id, u64? refund_tx_amount_sat);
Bitcoin(string swap_id, string description, u32? bitcoin_expiration_blockheight, u32? liquid_expiration_blockheight, string? refund_tx_id, u64? refund_tx_amount_sat);
};

dictionary Payment {
Expand Down
2 changes: 1 addition & 1 deletion lib/bindings/tests/bindings/csharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

GetInfoResponse? info = sdk.GetInfo();

Console.WriteLine(info!.pubkey);
Console.WriteLine(info!.walletInfo.pubkey);
}
catch (Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ func main() {
log.Fatalf("GetInfo failed: %#v", err)
}

log.Print(info.Pubkey)
log.Print(info.WalletInfo.Pubkey)
}
2 changes: 1 addition & 1 deletion lib/bindings/tests/bindings/test_breez_liquid_sdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

GetInfoResponse? info = sdk.GetInfo();

Console.WriteLine(info!.pubkey);
Console.WriteLine(info!.walletInfo.pubkey);
}
catch (Exception e)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/bindings/tests/bindings/test_breez_sdk_liquid.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ try {
sdk.removeEventListener(listenerId)

println("$nodeInfo")
assert(nodeInfo.pubkey.equals("03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494"))
assert(nodeInfo.walletInfo.pubkey.equals("03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494"))
} catch (ex: Exception) {
throw RuntimeException(ex.toString())
}
2 changes: 1 addition & 1 deletion lib/bindings/tests/bindings/test_breez_sdk_liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ def test():
sdk.remove_event_listener(listener_id)

print(node_info)
assert node_info.pubkey == "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494"
assert node_info.wallet_info.pubkey == "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494"

test()
2 changes: 1 addition & 1 deletion lib/bindings/tests/bindings/test_breez_sdk_liquid.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ let nodeInfo = try sdk.getInfo();
try sdk.removeEventListener(id: listenerId);

print(nodeInfo);
assert(nodeInfo.pubkey == "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494", "nodeInfo.pubkey");
assert(nodeInfo.walletInfo.pubkey == "03d902f35f560e0470c63313c7369168d9d7df2d49bf295fd9fb7cb109ccee0494", "nodeInfo.pubkey");
Loading

0 comments on commit c74d8f0

Please sign in to comment.