Skip to content

Commit 393731d

Browse files
committed
Update ldk-node dependencies
Align ldk-node and the companion Lightning dependencies so shared API types remain compatible. Adapt storage pagination, chain sync settings, and payment metadata to the updated interfaces.
1 parent a283d74 commit 393731d

10 files changed

Lines changed: 77 additions & 19 deletions

File tree

‎Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ codegen-units = 1 # Reduce number of codegen units to increase optimizations.
1616
panic = 'abort' # Abort on panic
1717

1818
[workspace.dependencies]
19-
bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment-instructions", rev = "ff09ce9401afa448549a8f101172700bcd14d7bb" }
20-
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3dfcc4cca1866c5e5d4d4eaf3b82e09584e2ce5c" }
21-
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "3dfcc4cca1866c5e5d4d4eaf3b82e09584e2ce5c" }
19+
bitcoin-payment-instructions = { git = "https://github.com/tnull/bitcoin-payment-instructions", rev = "0e430be98c09540624a68a68022ee0551e86d1be" }
20+
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "506cb91f2e0fb87906188b79777bcf42595d3623" }
21+
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "506cb91f2e0fb87906188b79777bcf42595d3623" }
2222

2323
[profile.release]
2424
panic = "abort"

‎orange-sdk/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ _cashu-tests = ["_test-utils", "cdk-ldk-node", "cdk/mint", "cdk-sqlite", "cdk-ax
2323
[dependencies]
2424
graduated-rebalancer = { path = "../graduated-rebalancer", version = "0.1.0" }
2525

26-
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "8a5426044bdcae6369d7a847697c6143676e2df5" }
26+
ldk-node = { git = "https://github.com/lightningdevkit/ldk-node", rev = "0cea34122767f0b86ebaf29c03f49eb38a85fc00" }
2727
lightning-macros = "0.2.0"
2828
bitcoin-payment-instructions = { workspace = true, features = ["http"] }
2929
chrono = { version = "0.4", default-features = false }

‎orange-sdk/src/dyn_store.rs‎

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
//! Object-safe wrapper around ldk-node's async `KVStore` trait.
1+
//! Object-safe wrapper around ldk-node's async `PaginatedKVStore` trait.
22
//!
33
//! `lightning`'s `KVStore` returns `impl Future` from its methods, which makes the trait not
44
//! object-safe — orange-sdk can't share a backend across components as `Arc<dyn KVStore>`.
55
//!
66
//! This module defines `DynStore`, an object-safe trait covering the kv methods (returning
7-
//! boxed futures), with a blanket impl over any concrete type that implements `KVStore`. The
8-
//! whole crate stores backends as `Arc<dyn DynStore>`; conversion to a value ldk-node accepts
9-
//! happens at the call site through a thin newtype that delegates back to `DynStore`.
7+
//! boxed futures), with a blanket impl over any concrete type that implements
8+
//! `PaginatedKVStore`. The whole crate stores backends as `Arc<dyn DynStore>`; conversion to a
9+
//! value ldk-node accepts happens at the call site through a thin newtype that delegates back to
10+
//! `DynStore`.
1011
1112
use std::future::Future;
1213
use std::pin::Pin;
1314
use std::sync::Arc;
1415

1516
use ldk_node::lightning::io;
16-
use ldk_node::lightning::util::persist::KVStore;
17+
use ldk_node::lightning::util::persist::{
18+
KVStore, PageToken, PaginatedKVStore, PaginatedListResponse,
19+
};
1720
use tokio::task::JoinSet;
1821

1922
/// Matches the connection capacity used by the VSS HTTP client. Keeping the
@@ -38,11 +41,15 @@ pub(crate) trait DynStore: Send + Sync + 'static {
3841
fn list_async(
3942
&self, primary_namespace: &str, secondary_namespace: &str,
4043
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, io::Error>> + Send + 'static>>;
44+
45+
fn list_paginated_async(
46+
&self, primary_namespace: &str, secondary_namespace: &str, page_token: Option<PageToken>,
47+
) -> Pin<Box<dyn Future<Output = Result<PaginatedListResponse, io::Error>> + Send + 'static>>;
4148
}
4249

4350
impl<T> DynStore for T
4451
where
45-
T: KVStore + Send + Sync + 'static,
52+
T: PaginatedKVStore + Send + Sync + 'static,
4653
{
4754
fn read_async(
4855
&self, p: &str, s: &str, k: &str,
@@ -67,6 +74,12 @@ where
6774
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, io::Error>> + Send + 'static>> {
6875
Box::pin(<T as KVStore>::list(self, p, s))
6976
}
77+
78+
fn list_paginated_async(
79+
&self, p: &str, s: &str, page_token: Option<PageToken>,
80+
) -> Pin<Box<dyn Future<Output = Result<PaginatedListResponse, io::Error>> + Send + 'static>> {
81+
Box::pin(<T as PaginatedKVStore>::list_paginated(self, p, s, page_token))
82+
}
7083
}
7184

7285
// Make `dyn DynStore` itself implement `KVStore` so the same handle orange-sdk shares
@@ -96,8 +109,16 @@ impl KVStore for dyn DynStore {
96109
}
97110
}
98111

112+
impl PaginatedKVStore for dyn DynStore {
113+
fn list_paginated(
114+
&self, p: &str, s: &str, page_token: Option<PageToken>,
115+
) -> impl Future<Output = Result<PaginatedListResponse, io::Error>> + Send + 'static {
116+
self.list_paginated_async(p, s, page_token)
117+
}
118+
}
119+
99120
/// Cloneable handle wrapping `Arc<dyn DynStore>` that satisfies ldk-node's
100-
/// `KVStore + Send + Sync + 'static` bound on `build_with_store`. The trait impl just
121+
/// `PaginatedKVStore + Send + Sync + 'static` bound on `build_with_store`. The trait impl just
101122
/// forwards to the underlying `dyn DynStore`.
102123
#[derive(Clone)]
103124
pub(crate) struct LdkNodeStore(pub(crate) Arc<dyn DynStore>);
@@ -125,6 +146,14 @@ impl KVStore for LdkNodeStore {
125146
}
126147
}
127148

149+
impl PaginatedKVStore for LdkNodeStore {
150+
fn list_paginated(
151+
&self, p: &str, s: &str, page_token: Option<PageToken>,
152+
) -> impl Future<Output = Result<PaginatedListResponse, io::Error>> + Send + 'static {
153+
self.0.list_paginated_async(p, s, page_token)
154+
}
155+
}
156+
128157
/// Reads a set of keys concurrently while preserving the input order.
129158
///
130159
/// Storage formats expose record collections as a list followed by individual
@@ -242,6 +271,15 @@ mod tests {
242271
}
243272
}
244273

274+
impl PaginatedKVStore for ControlledStore {
275+
fn list_paginated(
276+
&self, _primary_namespace: &str, _secondary_namespace: &str,
277+
_page_token: Option<PageToken>,
278+
) -> impl Future<Output = Result<PaginatedListResponse, io::Error>> + Send + 'static {
279+
ready(Ok(PaginatedListResponse { keys: Vec::new(), next_page_token: None }))
280+
}
281+
}
282+
245283
#[tokio::test]
246284
async fn bounded_reads_limit_concurrency_and_preserve_order() {
247285
let (entered, mut entered_rx) = mpsc::unbounded_channel();

‎orange-sdk/src/event.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ impl LdkEventHandler {
648648
.add_event(Event::ChannelClosed {
649649
channel_id,
650650
user_channel_id,
651-
counterparty_node_id: counterparty_node_id.unwrap(), // safe
651+
counterparty_node_id,
652652
reason,
653653
})
654654
.await

‎orange-sdk/src/lib.rs‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,7 @@ mod tests {
17771777
let kind = PaymentKind::Onchain {
17781778
txid: Txid::from_byte_array([42; 32]),
17791779
status: ConfirmationStatus::Unconfirmed,
1780+
tx_type: None,
17801781
};
17811782

17821783
assert!(should_surface_lightning_payment_without_metadata(TxStatus::Pending, &kind));
@@ -1787,7 +1788,11 @@ mod tests {
17871788
let txid = Txid::from_byte_array([42; 32]);
17881789
let payment = PaymentDetails {
17891790
id: LightningPaymentId([24; 32]),
1790-
kind: PaymentKind::Onchain { txid, status: ConfirmationStatus::Unconfirmed },
1791+
kind: PaymentKind::Onchain {
1792+
txid,
1793+
status: ConfirmationStatus::Unconfirmed,
1794+
tx_type: None,
1795+
},
17911796
amount_msat: Some(123_000),
17921797
fee_paid_msat: None,
17931798
direction: PaymentDirection::Inbound,

‎orange-sdk/src/lightning_wallet.rs‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ impl LightningWallet {
6767
trusted_peers_no_reserve: vec![config.lsp.1],
6868
..Default::default()
6969
};
70-
let ldk_node_config = ldk_node::config::Config {
71-
anchor_channels_config: Some(anchor_channels_config),
72-
..Default::default()
73-
};
70+
let ldk_node_config =
71+
ldk_node::config::Config { anchor_channels_config, ..Default::default() };
7472
let mut builder = ldk_node::Builder::from_config(ldk_node_config);
7573
builder.set_network(config.network);
7674
let node_entropy = config.seed.to_node_entropy();
@@ -113,6 +111,7 @@ impl LightningWallet {
113111
fee_rate_cache_update_interval_secs: 30,
114112
}),
115113
timeouts_config: SyncTimeoutsConfig::default(),
114+
..Default::default()
116115
}
117116
} else {
118117
ldk_node::config::EsploraSyncConfig::default()
@@ -151,14 +150,15 @@ impl LightningWallet {
151150
lightning_wallet_sync_interval_secs: 2,
152151
fee_rate_cache_update_interval_secs: 30,
153152
}),
153+
..Default::default()
154154
})
155155
} else {
156156
None
157157
};
158158
builder.set_chain_source_electrum(url, sync_config)
159159
},
160160
ChainSource::BitcoindRPC { host, port, user, password } => {
161-
builder.set_chain_source_bitcoind_rpc(host, port, user, password)
161+
builder.set_chain_source_bitcoind_rpc(host, port, user, password, None)
162162
},
163163
};
164164

@@ -353,6 +353,7 @@ impl LightningWallet {
353353
kind: PaymentKind::Onchain {
354354
txid: funding_txo.txid,
355355
status: ConfirmationStatus::Unconfirmed, // todo how do we update this?
356+
tx_type: None,
356357
},
357358
amount_msat: Some(amount_sats * 1_000),
358359
fee_paid_msat: Some(69), // todo get real fee

‎orange-sdk/src/rebalancer.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ impl RebalanceTrigger for OrangeTrigger {
176176
for payment in new_recvs {
177177
let payment_id = PaymentId::SelfCustodial(payment.id.0);
178178
let (txid, status) = match payment.kind {
179-
PaymentKind::Onchain { txid, status } => (txid, status),
179+
PaymentKind::Onchain { txid, status, .. } => (txid, status),
180180
_ => continue,
181181
};
182182
let event = Event::OnchainPaymentReceived {

‎orange-sdk/src/trusted_wallet/cashu/cashu_store.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ mod tests {
12921292
use cdk::Amount;
12931293
use cdk::nuts::Proof;
12941294
use cdk::secret::Secret;
1295+
use ldk_node::lightning::util::persist::{PageToken, PaginatedKVStore, PaginatedListResponse};
12951296
use std::future::ready;
12961297
use std::sync::Mutex as StdMutex;
12971298
use std::sync::atomic::{AtomicBool, Ordering};
@@ -1364,6 +1365,16 @@ mod tests {
13641365
}
13651366
}
13661367

1368+
impl PaginatedKVStore for ProofTestStore {
1369+
fn list_paginated(
1370+
&self, _primary_namespace: &str, _secondary_namespace: &str,
1371+
_page_token: Option<PageToken>,
1372+
) -> impl std::future::Future<Output = Result<PaginatedListResponse, io::Error>> + Send + 'static
1373+
{
1374+
ready(Ok(PaginatedListResponse { keys: Vec::new(), next_page_token: None }))
1375+
}
1376+
}
1377+
13671378
fn proof_info(secret: &str, amount: u64) -> ProofInfo {
13681379
let proof = Proof::new(
13691380
Amount::from(amount),

‎orange-sdk/src/trusted_wallet/dummy.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl DummyTrustedWallet {
6565
bitcoind.params.rpc_socket.port(),
6666
cookie.user,
6767
cookie.password,
68+
None,
6869
);
6970

7071
let tmp = temp_dir().join(format!("orange-test-{uuid}/dummy-ldk"));

‎orange-sdk/tests/test_utils.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ fn create_lsp(uuid: Uuid, bitcoind: &Bitcoind) -> Arc<Node> {
155155
bitcoind.params.rpc_socket.port(),
156156
cookie.user,
157157
cookie.password,
158+
None,
158159
);
159160

160161
let tmp = temp_dir().join(format!("orange-test-{uuid}/lsp"));
@@ -213,6 +214,7 @@ fn create_third_party(uuid: Uuid, bitcoind: &Bitcoind) -> Arc<Node> {
213214
bitcoind.params.rpc_socket.port(),
214215
cookie.user,
215216
cookie.password,
217+
None,
216218
);
217219

218220
let tmp = temp_dir().join(format!("orange-test-{uuid}/payer"));

0 commit comments

Comments
 (0)