Skip to content

Upgrade to LDK 0.2 #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
5560b65
Stop migrating spendable outputs from pre-v0.3 format
tnull Jul 31, 2025
6ffcc0f
WIP: Upgrade to LDK 0.2
tnull Feb 6, 2025
98573a3
f Add `lightning-macros` to alt `Cargo.toml` sources
tnull Jun 12, 2025
e775463
f Account for renamed `lightning-liquidity` types
tnull May 16, 2025
8267b83
f Move `uniffi` LSPS1PaymentInfo types next to the pre-existing ones
tnull May 16, 2025
3a15c2f
f Account for `ChannelMonitors` being tracked by `ChannelId`
tnull May 16, 2025
031f2ca
f Account for `HTLCHandlingFailureType`
tnull May 16, 2025
f474976
f Account for signer changes
tnull May 16, 2025
171a51b
f Account for `PaymentClaimable` API changes
tnull May 16, 2025
21e79c3
f Account for `get_counterparty_node_id` returning `PublicKey`
tnull May 21, 2025
4166c2d
f Account for BP taking Sweeper and LiqMan as arguments now
tnull May 21, 2025
7f1ffb4
f Account for `accept_inbound_channel` allowing override params
tnull May 21, 2025
2b95505
f Account for `CMH` using `LengthLimitedRead`
tnull May 21, 2025
1aa0190
f Account for `get_current_default_config` changes
tnull May 21, 2025
154c392
f Account for BOLT12 methods taking `RouteParamsConfig` arg
tnull May 21, 2025
5afc34e
f Account for `async`'ified `ChangeDestinationSource`
tnull May 21, 2025
0041c80
f Account for `PeerStorage` changes
tnull Jun 12, 2025
20dbf4d
f Account for Async bumping changes
tnull Jun 12, 2025
789ac5f
f Reuse the same esplora-client again
tnull Jun 12, 2025
b6bb4f5
f Reuse `electrum-client`
tnull Jun 12, 2025
f5c1422
f Account for changes in BOLT11 interface
tnull May 21, 2025
b3987cc
f Account for `CurrencyCode` changes
tnull Jun 23, 2025
bc78ceb
f Account for `lightning::util::string` re-exports being dropped
tnull Jul 9, 2025
1ed9dc5
f Account for `force_close_without_broadcasting` being dropped
tnull Jul 18, 2025
0fe1f3b
f Rename KVStore to KVStoreSync
joostjager Jul 10, 2025
b47ba08
f Account for async `KVStore` and async background persistence
joostjager Jul 10, 2025
1562784
f Account for additional `NodeSigner` methods
tnull Jul 31, 2025
6238f26
f Account for `lightning-liquidity` changes post-LSPS5 merge
tnull Jul 31, 2025
f92de06
f Account for `PendingHTLCsForwardable` being dropped
tnull Jul 31, 2025
7ea2c21
f Account for `create_offer_builder` not taking an expiry arg
tnull Jul 31, 2025
992e342
f Account for `KVStore::write` taking `buf` by value
tnull Aug 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 31 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,53 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.1.0", features = ["std"] }
lightning-types = { version = "0.2.0" }
lightning-invoice = { version = "0.33.0", features = ["std"] }
lightning-net-tokio = { version = "0.1.0" }
lightning-persister = { version = "0.1.0" }
lightning-background-processor = { version = "0.1.0", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.1.0" }
lightning-block-sync = { version = "0.1.0", features = ["rpc-client", "rest-client", "tokio"] }
lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
lightning-liquidity = { version = "0.1.0", features = ["std"] }
#lightning = { version = "0.1.0", features = ["std"] }
#lightning-types = { version = "0.2.0" }
#lightning-invoice = { version = "0.33.0", features = ["std"] }
#lightning-net-tokio = { version = "0.1.0" }
#lightning-persister = { version = "0.1.0" }
#lightning-background-processor = { version = "0.1.0" }
#lightning-rapid-gossip-sync = { version = "0.1.0" }
#lightning-block-sync = { version = "0.1.0", features = ["rest-client", "rpc-client", "tokio"] }
#lightning-transaction-sync = { version = "0.1.0", features = ["esplora-async-https", "time", "electrum"] }
#lightning-liquidity = { version = "0.1.0", features = ["std"] }
#lightning-macros = { version = "0.1.0" }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["std"] }
#lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["futures"] }
#lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rpc-client", "tokio"] }
#lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["rest-client", "rpc-client", "tokio"] }
#lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "electrum", "time"] }
#lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }
#lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main" }

lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412", features = ["esplora-async-https", "electrum", "time"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412" }

#lightning = { path = "../rust-lightning/lightning", features = ["std"] }
#lightning-types = { path = "../rust-lightning/lightning-types" }
#lightning-invoice = { path = "../rust-lightning/lightning-invoice", features = ["std"] }
#lightning-net-tokio = { path = "../rust-lightning/lightning-net-tokio" }
#lightning-persister = { path = "../rust-lightning/lightning-persister" }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor", features = ["futures"] }
#lightning-background-processor = { path = "../rust-lightning/lightning-background-processor" }
#lightning-rapid-gossip-sync = { path = "../rust-lightning/lightning-rapid-gossip-sync" }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rpc-client", "tokio"] }
#lightning-block-sync = { path = "../rust-lightning/lightning-block-sync", features = ["rest-client", "rpc-client", "tokio"] }
#lightning-transaction-sync = { path = "../rust-lightning/lightning-transaction-sync", features = ["esplora-async-https", "electrum", "time"] }
#lightning-liquidity = { path = "../rust-lightning/lightning-liquidity", features = ["std"] }
#lightning-macros = { path = "../rust-lightning/lightning-macros" }

bdk_chain = { version = "0.23.0", default-features = false, features = ["std"] }
bdk_esplora = { version = "0.22.0", default-features = false, features = ["async-https-rustls", "tokio"]}
Expand All @@ -77,11 +92,6 @@ rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync", "macros" ] }
esplora-client = { version = "0.12", default-features = false, features = ["tokio", "async-https-rustls"] }

# FIXME: This was introduced to decouple the `bdk_esplora` and
# `lightning-transaction-sync` APIs. We should drop it as part of the upgrade
# to LDK 0.2.
esplora-client_0_11 = { package = "esplora-client", version = "0.11", default-features = false, features = ["tokio", "async-https-rustls"] }
electrum-client = { version = "0.23.1", default-features = true }
libc = "0.2"
uniffi = { version = "0.28.3", features = ["build"], optional = true }
Expand All @@ -96,8 +106,9 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { version = "0.1.0", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "61e581976e0868ab3cf54b19dd1575b19d8ed412", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down
78 changes: 36 additions & 42 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dictionary Config {
sequence<PublicKey> trusted_peers_0conf;
u64 probing_liquidity_limit_multiplier;
AnchorChannelsConfig? anchor_channels_config;
SendingParameters? sending_parameters;
RouteParametersConfig? route_parameters;
};

dictionary AnchorChannelsConfig {
Expand Down Expand Up @@ -161,19 +161,19 @@ interface Node {

[Enum]
interface Bolt11InvoiceDescription {
Hash(string hash);
Direct(string description);
Hash(string hash);
Direct(string description);
};

interface Bolt11Payment {
[Throws=NodeError]
PaymentId send([ByRef]Bolt11Invoice invoice, SendingParameters? sending_parameters);
PaymentId send([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
[Throws=NodeError]
PaymentId send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, SendingParameters? sending_parameters);
PaymentId send_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
[Throws=NodeError]
void send_probes([ByRef]Bolt11Invoice invoice);
void send_probes([ByRef]Bolt11Invoice invoice, RouteParametersConfig? route_parameters);
[Throws=NodeError]
void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
void send_probes_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat, RouteParametersConfig? route_parameters);
[Throws=NodeError]
void claim_for_hash(PaymentHash payment_hash, u64 claimable_amount_msat, PaymentPreimage preimage);
[Throws=NodeError]
Expand Down Expand Up @@ -209,9 +209,9 @@ interface Bolt12Payment {

interface SpontaneousPayment {
[Throws=NodeError]
PaymentId send(u64 amount_msat, PublicKey node_id, SendingParameters? sending_parameters);
PaymentId send(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters);
[Throws=NodeError]
PaymentId send_with_custom_tlvs(u64 amount_msat, PublicKey node_id, SendingParameters? sending_parameters, sequence<CustomTlvRecord> custom_tlvs);
PaymentId send_with_custom_tlvs(u64 amount_msat, PublicKey node_id, RouteParametersConfig? route_parameters, sequence<CustomTlvRecord> custom_tlvs);
[Throws=NodeError]
void send_probes(u64 amount_msat, PublicKey node_id);
};
Expand Down Expand Up @@ -246,7 +246,7 @@ interface LSPS1Liquidity {
[Throws=NodeError]
LSPS1OrderStatus request_channel(u64 lsp_balance_sat, u64 client_balance_sat, u32 channel_expiry_blocks, boolean announce_channel);
[Throws=NodeError]
LSPS1OrderStatus check_order_status(OrderId order_id);
LSPS1OrderStatus check_order_status(LSPS1OrderId order_id);
};

[Error]
Expand Down Expand Up @@ -383,7 +383,7 @@ enum PaymentFailureReason {
[Enum]
interface ClosureReason {
CounterpartyForceClosed(UntrustedString peer_msg);
HolderForceClosed(boolean? broadcasted_latest_txn);
HolderForceClosed(boolean? broadcasted_latest_txn, string message);
LegacyCooperativeClosure();
CounterpartyInitiatedCooperativeClosure();
LocallyInitiatedCooperativeClosure();
Expand Down Expand Up @@ -447,11 +447,11 @@ dictionary PaymentDetails {
u64 latest_update_timestamp;
};

dictionary SendingParameters {
MaxTotalRoutingFeeLimit? max_total_routing_fee_msat;
u32? max_total_cltv_expiry_delta;
u8? max_path_count;
u8? max_channel_saturation_power_of_half;
dictionary RouteParametersConfig {
u64? max_total_routing_fee_msat;
u32 max_total_cltv_expiry_delta;
u8 max_path_count;
u8 max_channel_saturation_power_of_half;
};

dictionary CustomTlvRecord {
Expand All @@ -460,13 +460,13 @@ dictionary CustomTlvRecord {
};

dictionary LSPS1OrderStatus {
OrderId order_id;
OrderParameters order_params;
PaymentInfo payment_options;
ChannelOrderInfo? channel_state;
LSPS1OrderId order_id;
LSPS1OrderParams order_params;
LSPS1PaymentInfo payment_options;
LSPS1ChannelInfo? channel_state;
};

dictionary OrderParameters {
dictionary LSPS1OrderParams {
u64 lsp_balance_sat;
u64 client_balance_sat;
u16 required_channel_confirmations;
Expand All @@ -476,22 +476,22 @@ dictionary OrderParameters {
boolean announce_channel;
};

dictionary PaymentInfo {
Bolt11PaymentInfo? bolt11;
OnchainPaymentInfo? onchain;
dictionary LSPS1PaymentInfo {
LSPS1Bolt11PaymentInfo? bolt11;
LSPS1OnchainPaymentInfo? onchain;
};

dictionary Bolt11PaymentInfo {
PaymentState state;
DateTime expires_at;
dictionary LSPS1Bolt11PaymentInfo {
LSPS1PaymentState state;
LSPSDateTime expires_at;
u64 fee_total_sat;
u64 order_total_sat;
Bolt11Invoice invoice;
};

dictionary OnchainPaymentInfo {
PaymentState state;
DateTime expires_at;
dictionary LSPS1OnchainPaymentInfo {
LSPS1PaymentState state;
LSPSDateTime expires_at;
u64 fee_total_sat;
u64 order_total_sat;
Address address;
Expand All @@ -500,24 +500,18 @@ dictionary OnchainPaymentInfo {
Address? refund_onchain_address;
};

dictionary ChannelOrderInfo {
DateTime funded_at;
dictionary LSPS1ChannelInfo {
LSPSDateTime funded_at;
OutPoint funding_outpoint;
DateTime expires_at;
LSPSDateTime expires_at;
};

enum PaymentState {
enum LSPS1PaymentState {
"ExpectPayment",
"Paid",
"Refunded",
};

[Enum]
interface MaxTotalRoutingFeeLimit {
None ();
Some ( u64 amount_msat );
};

[NonExhaustive]
enum Network {
"Bitcoin",
Expand Down Expand Up @@ -852,7 +846,7 @@ typedef string UntrustedString;
typedef string NodeAlias;

[Custom]
typedef string OrderId;
typedef string LSPS1OrderId;

[Custom]
typedef string DateTime;
typedef string LSPSDateTime;
13 changes: 10 additions & 3 deletions src/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
// http://opensource.org/licenses/MIT>, at your option. You may not use this file except in
// accordance with one or both of these licenses.

use crate::sweep::value_from_descriptor;

use lightning::chain::channelmonitor::Balance as LdkBalance;
use lightning::chain::channelmonitor::BalanceSource;
use lightning::ln::types::ChannelId;
use lightning::sign::SpendableOutputDescriptor;
use lightning::util::sweep::{OutputSpendStatus, TrackedSpendableOutput};

use lightning_types::payment::{PaymentHash, PaymentPreimage};

use bitcoin::secp256k1::PublicKey;
use bitcoin::{BlockHash, Txid};
use bitcoin::{Amount, BlockHash, Txid};

/// Details of the known available balances returned by [`Node::list_balances`].
///
Expand Down Expand Up @@ -385,3 +384,11 @@ impl PendingSweepBalance {
}
}
}

fn value_from_descriptor(descriptor: &SpendableOutputDescriptor) -> Amount {
match &descriptor {
SpendableOutputDescriptor::StaticOutput { output, .. } => output.value,
SpendableOutputDescriptor::DelayedPaymentOutput(output) => output.output.value,
SpendableOutputDescriptor::StaticPaymentOutput(output) => output.output.value,
}
}
Loading
Loading