Skip to content

Commit

Permalink
Integrate sdk-common: re-use parse_invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 committed Jun 12, 2024
1 parent e63d0ee commit 82fb793
Show file tree
Hide file tree
Showing 15 changed files with 999 additions and 440 deletions.
381 changes: 344 additions & 37 deletions cli/Cargo.lock

Large diffs are not rendered by default.

373 changes: 337 additions & 36 deletions lib/Cargo.lock

Large diffs are not rendered by default.

72 changes: 43 additions & 29 deletions lib/bindings/src/breez_liquid_sdk.udl
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
//////////////////////////////////
// BEGIN sdk-common mirror imports
// These are structs defined in sdk-common, which we want to make available in this project's UDL bindings

dictionary LNInvoice {
string bolt11;
Network network;
string payee_pubkey;
string payment_hash;
string? description;
string? description_hash;
u64? amount_msat;
u64 timestamp;
u64 expiry;
sequence<RouteHint> routing_hints;
sequence<u8> payment_secret;
u64 min_final_cltv_expiry_delta;
};

enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};

dictionary RouteHint {
sequence<RouteHintHop> hops;
};

dictionary RouteHintHop {
string src_node_id;
u64 short_channel_id;
u32 fees_base_msat;
u32 fees_proportional_millionths;
u64 cltv_expiry_delta;
u64? htlc_minimum_msat;
u64? htlc_maximum_msat;
};

// END sdk-common mirror imports
////////////////////////////////

[Error]
enum LiquidSdkError {
"AlreadyStarted",
Expand Down Expand Up @@ -87,35 +130,6 @@ dictionary RestoreRequest {
string? backup_path = null;
};

dictionary RouteHint {
sequence<RouteHintHop> hops;
};

dictionary RouteHintHop {
string src_node_id;
u64 short_channel_id;
u32 fees_base_msat;
u32 fees_proportional_millionths;
u64 cltv_expiry_delta;
u64? htlc_minimum_msat;
u64? htlc_maximum_msat;
};

dictionary LNInvoice {
string bolt11;
LiquidSdkNetwork network;
string payee_pubkey;
string payment_hash;
string? description;
string? description_hash;
u64? amount_msat;
u64 timestamp;
u64 expiry;
sequence<RouteHint> routing_hints;
sequence<u8> payment_secret;
u64 min_final_cltv_expiry_delta;
};

dictionary Payment {
string tx_id;
string? swap_id = null;
Expand Down
2 changes: 1 addition & 1 deletion lib/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;

use anyhow::Result;
use breez_liquid_sdk::logger::Logger;
use breez_liquid_sdk::{error::*, model::*, sdk::LiquidSdk};
use breez_liquid_sdk::{error::*, model::*, sdk::LiquidSdk, *};
use log::{Metadata, Record, SetLoggerError};
use once_cell::sync::Lazy;
use tokio::runtime::Runtime;
Expand Down
3 changes: 2 additions & 1 deletion lib/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ lwk_signer = "0.5.1"
# Switch back to published version once this PR is merged and included in release: https://github.com/Blockstream/lwk/pull/34 (ETA in v0.5.2)
lwk_wollet = { git = "https://github.com/Blockstream/lwk", rev = "ffd793d0a1b1122c9bba7de23ccb73033eded98c" }
#lwk_wollet = "0.5.1"
rusqlite = { version = "0.31", features = ["backup", "bundled"] }
rusqlite = { version = "0.29", features = ["backup", "bundled"] } # Same version as used in sdk-common
rusqlite_migration = "1.0"
sdk-common = { git = "https://github.com/breez/breez-sdk", branch = "ok300-extract-commons-lnurl" }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.116"
thiserror = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Result;
use flutter_rust_bridge::frb;
use log::{Level, LevelFilter, Metadata, Record, SetLoggerError};

use crate::{error::*, frb_generated::StreamSink, model::*, sdk::LiquidSdk};
use crate::{error::*, frb_generated::StreamSink, model::*, sdk::LiquidSdk, *};

pub struct BindingEventListener {
pub stream: StreamSink<LiquidSdkEvent>,
Expand Down
26 changes: 13 additions & 13 deletions lib/core/src/frb_generated.io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,30 +285,30 @@ impl CstDecode<Vec<u8>> for *mut wire_cst_list_prim_u_8_strict {
}
}
}
impl CstDecode<Vec<crate::model::RouteHint>> for *mut wire_cst_list_route_hint {
impl CstDecode<Vec<crate::RouteHint>> for *mut wire_cst_list_route_hint {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::model::RouteHint> {
fn cst_decode(self) -> Vec<crate::RouteHint> {
let vec = unsafe {
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(CstDecode::cst_decode).collect()
}
}
impl CstDecode<Vec<crate::model::RouteHintHop>> for *mut wire_cst_list_route_hint_hop {
impl CstDecode<Vec<crate::RouteHintHop>> for *mut wire_cst_list_route_hint_hop {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> Vec<crate::model::RouteHintHop> {
fn cst_decode(self) -> Vec<crate::RouteHintHop> {
let vec = unsafe {
let wrap = flutter_rust_bridge::for_generated::box_from_leak_ptr(self);
flutter_rust_bridge::for_generated::vec_from_leak_ptr(wrap.ptr, wrap.len)
};
vec.into_iter().map(CstDecode::cst_decode).collect()
}
}
impl CstDecode<crate::model::LNInvoice> for wire_cst_ln_invoice {
impl CstDecode<crate::LNInvoice> for wire_cst_ln_invoice {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::LNInvoice {
crate::model::LNInvoice {
fn cst_decode(self) -> crate::LNInvoice {
crate::LNInvoice {
bolt11: self.bolt11.cst_decode(),
network: self.network.cst_decode(),
payee_pubkey: self.payee_pubkey.cst_decode(),
Expand Down Expand Up @@ -463,18 +463,18 @@ impl CstDecode<crate::model::RestoreRequest> for wire_cst_restore_request {
}
}
}
impl CstDecode<crate::model::RouteHint> for wire_cst_route_hint {
impl CstDecode<crate::RouteHint> for wire_cst_route_hint {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::RouteHint {
crate::model::RouteHint {
fn cst_decode(self) -> crate::RouteHint {
crate::RouteHint {
hops: self.hops.cst_decode(),
}
}
}
impl CstDecode<crate::model::RouteHintHop> for wire_cst_route_hint_hop {
impl CstDecode<crate::RouteHintHop> for wire_cst_route_hint_hop {
// Codec=Cst (C-struct based), see doc to use other codecs
fn cst_decode(self) -> crate::model::RouteHintHop {
crate::model::RouteHintHop {
fn cst_decode(self) -> crate::RouteHintHop {
crate::RouteHintHop {
src_node_id: self.src_node_id.cst_decode(),
short_channel_id: self.short_channel_id.cst_decode(),
fees_base_msat: self.fees_base_msat.cst_decode(),
Expand Down
Loading

0 comments on commit 82fb793

Please sign in to comment.