Skip to content

Commit 03c4ab0

Browse files
authored
Merge pull request #426 from tnull/2025-01-upgrade-bdk-ldk
Update BDK to 1.0.0 and LDK to 0.1.0
2 parents ec00e5c + c39bfba commit 03c4ab0

20 files changed

+142
-163
lines changed

Cargo.toml

+32-26
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,42 @@ panic = 'abort' # Abort on panic
2828
default = []
2929

3030
[dependencies]
31-
lightning = { version = "0.0.125", features = ["std"] }
32-
lightning-invoice = { version = "0.32.0" }
33-
lightning-net-tokio = { version = "0.0.125" }
34-
lightning-persister = { version = "0.0.125" }
35-
lightning-background-processor = { version = "0.0.125", features = ["futures"] }
36-
lightning-rapid-gossip-sync = { version = "0.0.125" }
37-
lightning-block-sync = { version = "0.0.125", features = ["rpc-client", "tokio"] }
38-
lightning-transaction-sync = { version = "0.0.125", features = ["esplora-async-https", "time"] }
39-
lightning-liquidity = { version = "0.1.0-alpha.6", features = ["std"] }
40-
41-
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] }
42-
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
43-
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
44-
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
45-
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["futures"] }
46-
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
47-
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["esplora-async"] }
48-
#lightning-liquidity = { git = "https://github.com/lightningdevkit/lightning-liquidity", branch="main", features = ["std"] }
31+
lightning = { version = "0.1.0", features = ["std"] }
32+
lightning-types = { version = "0.2.0" }
33+
lightning-invoice = { version = "0.33.0", features = ["std"] }
34+
lightning-net-tokio = { version = "0.1.0" }
35+
lightning-persister = { version = "0.1.0" }
36+
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
37+
lightning-rapid-gossip-sync = { version = "0.1.0" }
38+
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "tokio"] }
39+
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time"] }
40+
lightning-liquidity = { version = "0.1.0", features = ["std"] }
41+
42+
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
43+
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
44+
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
45+
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
46+
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
47+
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["futures"] }
48+
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
49+
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
50+
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "time"] }
51+
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
4952

5053
#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
51-
#lightning-invoice = { path = "../rust-lightning/lightning-invoice" }
54+
#lightning-types = { path = "../rust-lightning/lightning-types" }
55+
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
5256
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
5357
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
5458
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
5559
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
56-
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async"] }
57-
#lightning-liquidity = { path = "../lightning-liquidity", features = ["std"] }
60+
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
61+
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "time"] }
62+
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }
5863

59-
bdk_chain = { version = "=0.19.0", default-features = false, features = ["std"] }
60-
bdk_esplora = { version = "=0.18.0", default-features = false, features = ["async-https-rustls"]}
61-
bdk_wallet = { version = "=1.0.0-beta.4", default-features = false, features = ["std", "keys-bip39"]}
64+
bdk_chain = { version = "0.21.1", default-features = false, features = ["std"] }
65+
bdk_esplora = { version = "0.20.1", default-features = false, features = ["async-https-rustls", "tokio"]}
66+
bdk_wallet = { version = "1.0.0", default-features = false, features = ["std", "keys-bip39"]}
6267

6368
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
6469
rusqlite = { version = "0.31.0", features = ["bundled"] }
@@ -70,7 +75,7 @@ base64 = { version = "0.22.1", default-features = false, features = ["std"] }
7075
rand = "0.8.5"
7176
chrono = { version = "0.4", default-features = false, features = ["clock"] }
7277
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
73-
esplora-client = { version = "0.9", default-features = false }
78+
esplora-client = { version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
7479
libc = "0.2"
7580
uniffi = { version = "0.27.3", features = ["build"], optional = true }
7681
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
@@ -83,8 +88,9 @@ prost = { version = "0.11.6", default-features = false}
8388
winapi = { version = "0.3", features = ["winbase"] }
8489

8590
[dev-dependencies]
86-
lightning = { version = "0.0.125", features = ["std", "_test_utils"] }
91+
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
8792
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
93+
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
8894
electrum-client = { version = "0.21.0", default-features = true }
8995
bitcoincore-rpc = { version = "0.19.0", default-features = false }
9096
proptest = "1.0.0"

bindings/ldk_node.udl

+3-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ interface Event {
280280
PaymentFailed(PaymentId? payment_id, PaymentHash? payment_hash, PaymentFailureReason? reason);
281281
PaymentReceived(PaymentId? payment_id, PaymentHash payment_hash, u64 amount_msat, sequence<CustomTlvRecord> custom_records);
282282
PaymentClaimable(PaymentId payment_id, PaymentHash payment_hash, u64 claimable_amount_msat, u32? claim_deadline, sequence<CustomTlvRecord> custom_records);
283-
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId? prev_user_channel_id, UserChannelId? next_user_channel_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
283+
PaymentForwarded(ChannelId prev_channel_id, ChannelId next_channel_id, UserChannelId?
284+
prev_user_channel_id, UserChannelId? next_user_channel_id, PublicKey? prev_node_id, PublicKey? next_node_id, u64? total_fee_earned_msat, u64? skimmed_fee_msat, boolean claim_from_onchain_tx, u64? outbound_amount_forwarded_msat);
284285
ChannelPending(ChannelId channel_id, UserChannelId user_channel_id, ChannelId former_temporary_channel_id, PublicKey counterparty_node_id, OutPoint funding_txo);
285286
ChannelReady(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id);
286287
ChannelClosed(ChannelId channel_id, UserChannelId user_channel_id, PublicKey? counterparty_node_id, ClosureReason? reason);
@@ -296,6 +297,7 @@ enum PaymentFailureReason {
296297
"UnknownRequiredFeatures",
297298
"InvoiceRequestExpired",
298299
"InvoiceRequestRejected",
300+
"BlindedPathCreationFailed",
299301
};
300302

301303
[Enum]

src/balance.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ use crate::sweep::value_from_descriptor;
1010
use lightning::chain::channelmonitor::Balance as LdkBalance;
1111
use lightning::chain::channelmonitor::BalanceSource;
1212
use lightning::ln::types::ChannelId;
13-
use lightning::ln::{PaymentHash, PaymentPreimage};
1413
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};
1514

15+
use lightning_types::payment::{PaymentHash, PaymentPreimage};
16+
1617
use bitcoin::secp256k1::PublicKey;
1718
use bitcoin::{BlockHash, Txid};
1819

src/builder.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ fn build_with_store_internal(
907907
));
908908

909909
// Read ChannelMonitor state from store
910-
let mut channel_monitors = match read_channel_monitors(
910+
let channel_monitors = match read_channel_monitors(
911911
Arc::clone(&kv_store),
912912
Arc::clone(&keys_manager),
913913
Arc::clone(&keys_manager),
@@ -936,6 +936,9 @@ fn build_with_store_internal(
936936
100;
937937
}
938938

939+
let message_router =
940+
Arc::new(MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager)));
941+
939942
// Initialize the ChannelManager
940943
let channel_manager = {
941944
if let Ok(res) = kv_store.read(
@@ -945,7 +948,7 @@ fn build_with_store_internal(
945948
) {
946949
let mut reader = Cursor::new(res);
947950
let channel_monitor_references =
948-
channel_monitors.iter_mut().map(|(_, chanmon)| chanmon).collect();
951+
channel_monitors.iter().map(|(_, chanmon)| chanmon).collect();
949952
let read_args = ChannelManagerReadArgs::new(
950953
Arc::clone(&keys_manager),
951954
Arc::clone(&keys_manager),
@@ -954,6 +957,7 @@ fn build_with_store_internal(
954957
Arc::clone(&chain_monitor),
955958
Arc::clone(&tx_broadcaster),
956959
Arc::clone(&router),
960+
Arc::clone(&message_router),
957961
Arc::clone(&logger),
958962
user_config,
959963
channel_monitor_references,
@@ -978,6 +982,7 @@ fn build_with_store_internal(
978982
Arc::clone(&chain_monitor),
979983
Arc::clone(&tx_broadcaster),
980984
Arc::clone(&router),
985+
Arc::clone(&message_router),
981986
Arc::clone(&logger),
982987
Arc::clone(&keys_manager),
983988
Arc::clone(&keys_manager),
@@ -1000,18 +1005,17 @@ fn build_with_store_internal(
10001005
})?;
10011006
}
10021007

1003-
let message_router = MessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager));
1004-
10051008
// Initialize the PeerManager
10061009
let onion_messenger: Arc<OnionMessenger> = Arc::new(OnionMessenger::new(
10071010
Arc::clone(&keys_manager),
10081011
Arc::clone(&keys_manager),
10091012
Arc::clone(&logger),
10101013
Arc::clone(&channel_manager),
1011-
Arc::new(message_router),
1014+
message_router,
10121015
Arc::clone(&channel_manager),
10131016
IgnoringMessageHandler {},
10141017
IgnoringMessageHandler {},
1018+
IgnoringMessageHandler {},
10151019
));
10161020
let ephemeral_bytes: [u8; 32] = keys_manager.get_secure_random_bytes();
10171021

@@ -1055,7 +1059,8 @@ fn build_with_store_internal(
10551059
let liquidity_source = liquidity_source_config.as_ref().and_then(|lsc| {
10561060
lsc.lsps2_service.as_ref().map(|(address, node_id, token)| {
10571061
let lsps2_client_config = Some(LSPS2ClientConfig {});
1058-
let liquidity_client_config = Some(LiquidityClientConfig { lsps2_client_config });
1062+
let liquidity_client_config =
1063+
Some(LiquidityClientConfig { lsps1_client_config: None, lsps2_client_config });
10591064
let liquidity_manager = Arc::new(LiquidityManager::new(
10601065
Arc::clone(&keys_manager),
10611066
Arc::clone(&channel_manager),

src/chain/bitcoind_rpc.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ impl BitcoindRpcClient {
3838
let rpc_credentials =
3939
BASE64_STANDARD.encode(format!("{}:{}", rpc_user.clone(), rpc_password.clone()));
4040

41-
let rpc_client = Arc::new(
42-
RpcClient::new(&rpc_credentials, http_endpoint)
43-
.expect("RpcClient::new is actually infallible"),
44-
);
41+
let rpc_client = Arc::new(RpcClient::new(&rpc_credentials, http_endpoint));
4542

4643
let latest_mempool_timestamp = AtomicU64::new(0);
4744

src/chain/mod.rs

+5-11
Original file line numberDiff line numberDiff line change
@@ -787,18 +787,12 @@ impl ChainSource {
787787
for target in confirmation_targets {
788788
let num_blocks = get_num_block_defaults_for_target(target);
789789

790+
// Convert the retrieved fee rate and fall back to 1 sat/vb if we fail or it
791+
// yields less than that. This is mostly necessary to continue on
792+
// `signet`/`regtest` where we might not get estimates (or bogus values).
790793
let converted_estimate_sat_vb =
791-
esplora_client::convert_fee_rate(num_blocks, estimates.clone()).map_err(
792-
|e| {
793-
log_error!(
794-
logger,
795-
"Failed to convert fee rate estimates for {:?}: {}",
796-
target,
797-
e
798-
);
799-
Error::FeerateEstimationUpdateFailed
800-
},
801-
)?;
794+
esplora_client::convert_fee_rate(num_blocks, estimates.clone())
795+
.map_or(1.0, |converted| converted.max(1.0));
802796

803797
let fee_rate =
804798
FeeRate::from_sat_per_kwu((converted_estimate_sat_vb * 250.0) as u64);

src/event.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ use lightning::events::{Event as LdkEvent, PaymentFailureReason};
3232
use lightning::impl_writeable_tlv_based_enum;
3333
use lightning::ln::channelmanager::PaymentId;
3434
use lightning::ln::types::ChannelId;
35-
use lightning::ln::{PaymentHash, PaymentPreimage};
3635
use lightning::routing::gossip::NodeId;
3736
use lightning::util::errors::APIError;
3837
use lightning::util::ser::{Readable, ReadableArgs, Writeable, Writer};
3938

39+
use lightning_types::payment::{PaymentHash, PaymentPreimage};
40+
4041
use lightning_liquidity::lsps2::utils::compute_opening_fee;
4142

4243
use bitcoin::blockdata::locktime::absolute::LockTime;
@@ -120,6 +121,16 @@ pub enum Event {
120121
/// This will be `None` if the payment was settled via an on-chain transaction. See the
121122
/// caveat described for the `total_fee_earned_msat` field.
122123
next_user_channel_id: Option<UserChannelId>,
124+
/// The node id of the previous node.
125+
///
126+
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
127+
/// versions prior to v0.5.
128+
prev_node_id: Option<PublicKey>,
129+
/// The node id of the next node.
130+
///
131+
/// This is only `None` for HTLCs received prior to LDK Node v0.5 or for events serialized by
132+
/// versions prior to v0.5.
133+
next_node_id: Option<PublicKey>,
123134
/// The total fee, in milli-satoshis, which was earned as a result of the payment.
124135
///
125136
/// Note that if we force-closed the channel over which we forwarded an HTLC while the HTLC
@@ -257,7 +268,9 @@ impl_writeable_tlv_based_enum!(Event,
257268
},
258269
(7, PaymentForwarded) => {
259270
(0, prev_channel_id, required),
271+
(1, prev_node_id, option),
260272
(2, next_channel_id, required),
273+
(3, next_node_id, option),
261274
(4, prev_user_channel_id, option),
262275
(6, next_user_channel_id, option),
263276
(8, total_fee_earned_msat, option),
@@ -550,6 +563,7 @@ where
550563
claim_deadline,
551564
onion_fields,
552565
counterparty_skimmed_fee_msat,
566+
payment_id: _,
553567
} => {
554568
let payment_id = PaymentId(payment_hash.0);
555569
if let Some(info) = self.payment_store.get(&payment_id) {
@@ -812,6 +826,7 @@ where
812826
htlcs: _,
813827
sender_intended_total_msat: _,
814828
onion_fields,
829+
payment_id: _,
815830
} => {
816831
let payment_id = PaymentId(payment_hash.0);
817832
log_info!(
@@ -1025,7 +1040,7 @@ where
10251040
counterparty_node_id,
10261041
funding_satoshis,
10271042
channel_type,
1028-
push_msat: _,
1043+
channel_negotiation_type: _,
10291044
is_announced: _,
10301045
params: _,
10311046
} => {
@@ -1139,6 +1154,8 @@ where
11391154
next_channel_id,
11401155
prev_user_channel_id,
11411156
next_user_channel_id,
1157+
prev_node_id,
1158+
next_node_id,
11421159
total_fee_earned_msat,
11431160
skimmed_fee_msat,
11441161
claim_from_onchain_tx,
@@ -1149,6 +1166,8 @@ where
11491166
next_channel_id: next_channel_id.expect("next_channel_id expected for events generated by LDK versions greater than 0.0.107."),
11501167
prev_user_channel_id: prev_user_channel_id.map(UserChannelId),
11511168
next_user_channel_id: next_user_channel_id.map(UserChannelId),
1169+
prev_node_id,
1170+
next_node_id,
11521171
total_fee_earned_msat,
11531172
skimmed_fee_msat,
11541173
claim_from_onchain_tx,

src/io/test_utils.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use lightning::ln::functional_test_utils::{
1111
};
1212
use lightning::util::persist::{read_channel_monitors, KVStore, KVSTORE_NAMESPACE_KEY_MAX_LEN};
1313

14-
use lightning::chain::channelmonitor::CLOSED_CHANNEL_UPDATE_ID;
1514
use lightning::events::ClosureReason;
1615
use lightning::util::test_utils;
1716
use lightning::{check_added_monitors, check_closed_broadcast, check_closed_event};
@@ -186,5 +185,5 @@ pub(crate) fn do_test_store<K: KVStore>(store_0: &K, store_1: &K) {
186185
check_added_monitors!(nodes[1], 1);
187186

188187
// Make sure everything is persisted as expected after close.
189-
check_persisted_data!(CLOSED_CHANNEL_UPDATE_ID);
188+
check_persisted_data!(11);
190189
}

src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub use bip39;
100100
pub use bitcoin;
101101
pub use lightning;
102102
pub use lightning_invoice;
103+
pub use lightning_types;
103104
pub use vss_client;
104105

105106
pub use balance::{BalanceDetails, LightningBalance, PendingSweepBalance};
@@ -823,7 +824,6 @@ impl Node {
823824
Arc::clone(&self.runtime),
824825
Arc::clone(&self.channel_manager),
825826
Arc::clone(&self.connection_manager),
826-
Arc::clone(&self.keys_manager),
827827
self.liquidity_source.clone(),
828828
Arc::clone(&self.payment_store),
829829
Arc::clone(&self.peer_store),
@@ -841,7 +841,6 @@ impl Node {
841841
Arc::clone(&self.runtime),
842842
Arc::clone(&self.channel_manager),
843843
Arc::clone(&self.connection_manager),
844-
Arc::clone(&self.keys_manager),
845844
self.liquidity_source.clone(),
846845
Arc::clone(&self.payment_store),
847846
Arc::clone(&self.peer_store),

0 commit comments

Comments
 (0)