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 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1b0f312
Stop migrating spendable outputs from pre-v0.3 format
tnull Jul 31, 2025
95a1ee0
WIP: Upgrade to LDK 0.2
tnull Feb 6, 2025
003cc83
f Add `lightning-macros` to alt `Cargo.toml` sources
tnull Jun 12, 2025
3292d2e
f Account for renamed `lightning-liquidity` types
tnull May 16, 2025
08f0205
f Move `uniffi` LSPS1PaymentInfo types next to the pre-existing ones
tnull May 16, 2025
122c855
f Account for `ChannelMonitors` being tracked by `ChannelId`
tnull May 16, 2025
8a0fc55
f Account for `HTLCHandlingFailureType`
tnull May 16, 2025
e149d5e
f Account for signer changes
tnull May 16, 2025
b02cb9f
f Account for `PaymentClaimable` API changes
tnull May 16, 2025
b09e590
f Account for `get_counterparty_node_id` returning `PublicKey`
tnull May 21, 2025
fa48d81
f Account for BP taking Sweeper and LiqMan as arguments now
tnull May 21, 2025
d2c6e97
f Account for `accept_inbound_channel` allowing override params
tnull May 21, 2025
3b71ce3
f Account for `CMH` using `LengthLimitedRead`
tnull May 21, 2025
9f43dea
f Account for `get_current_default_config` changes
tnull May 21, 2025
7785b95
f Account for BOLT12 methods taking `RouteParamsConfig` arg
tnull May 21, 2025
c646600
f Account for `async`'ified `ChangeDestinationSource`
tnull May 21, 2025
955074d
f Account for `PeerStorage` changes
tnull Jun 12, 2025
ad7ce83
f Account for Async bumping changes
tnull Jun 12, 2025
cd7de02
f Reuse the same esplora-client again
tnull Jun 12, 2025
6167f59
f Reuse `electrum-client`
tnull Jun 12, 2025
1f900b0
f Account for changes in BOLT11 interface
tnull May 21, 2025
40ac4ed
f Account for `CurrencyCode` changes
tnull Jun 23, 2025
4bd76f5
f Account for `lightning::util::string` re-exports being dropped
tnull Jul 9, 2025
203e0a6
f Account for `force_close_without_broadcasting` being dropped
tnull Jul 18, 2025
b1f891d
f Rename KVStore to KVStoreSync
joostjager Jul 10, 2025
fad42c0
f Account for async `KVStore` and async background persistence
joostjager Jul 10, 2025
aacdb63
f Account for additional `NodeSigner` methods
tnull Jul 31, 2025
f4b8c24
f Account for `lightning-liquidity` changes post-LSPS5 merge
tnull Jul 31, 2025
e51c2ca
f Account for `PendingHTLCsForwardable` being dropped
tnull Jul 31, 2025
ded7ba1
f Account for `create_offer_builder` not taking an expiry arg
tnull Jul 31, 2025
fc46fba
f Account for `KVStore::write` taking `buf` by value
tnull Aug 4, 2025
096e4b9
f Account for new event types
tnull Aug 19, 2025
82806c2
f Account for changes in `ClosureReason`
tnull Aug 19, 2025
3b0c641
Switch to use `rustls-ring` everywhere
tnull Aug 15, 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
3 changes: 0 additions & 3 deletions .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ jobs:
- name: Generate Kotlin JVM
run: ./scripts/uniffi_bindgen_generate_kotlin.sh

- name: Install `bindgen-cli`
run: cargo install --force bindgen-cli

- name: Generate Kotlin Android
run: ./scripts/uniffi_bindgen_generate_kotlin_android.sh

Expand Down
57 changes: 34 additions & 23 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,57 @@ 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-rustls-ring"] }
#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-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "main", features = ["esplora-async-https", "electrum", "time"] }
#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-rustls-ring", "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 = "e1a31e1b6a55056a039c693246a5636957ed7a54", features = ["std"] }
lightning-types = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }
lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54", features = ["std"] }
lightning-net-tokio = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }
lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }
lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }
lightning-rapid-gossip-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }
lightning-block-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54", features = ["rest-client", "rpc-client", "tokio"] }
lightning-transaction-sync = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54", features = ["esplora-async-https", "electrum-rustls-ring", "time"] }
lightning-liquidity = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }
lightning-macros = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "e1a31e1b6a55056a039c693246a5636957ed7a54" }

#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"]}
bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls"]}
bdk_electrum = { version = "0.23.0", default-features = false, features = ["use-rustls-ring"]}
bdk_wallet = { version = "2.0.0", default-features = false, features = ["std", "keys-bip39"]}

reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
Expand All @@ -78,12 +93,7 @@ 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.24.0", default-features = true }
electrum-client = { version = "0.24.0", default-features = false, features = ["proxy", "use-rustls-ring"] }
libc = "0.2"
uniffi = { version = "0.28.3", features = ["build"], optional = true }
serde = { version = "1.0.210", default-features = false, features = ["std", "derive"] }
Expand All @@ -97,8 +107,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 = "e1a31e1b6a55056a039c693246a5636957ed7a54", features = ["std", "_test_utils"] }
#lightning = { path = "../rust-lightning/lightning", features = ["std", "_test_utils"] }
proptest = "1.0.0"
regex = "1.5.6"
Expand Down
81 changes: 38 additions & 43 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 @@ -167,13 +167,13 @@ interface Bolt11InvoiceDescription {

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 @@ -213,13 +213,13 @@ 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]
PaymentId send_with_preimage(u64 amount_msat, PublicKey node_id, PaymentPreimage preimage, SendingParameters? sending_parameters);
PaymentId send_with_preimage(u64 amount_msat, PublicKey node_id, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
[Throws=NodeError]
PaymentId send_with_preimage_and_custom_tlvs(u64 amount_msat, PublicKey node_id, sequence<CustomTlvRecord> custom_tlvs, PaymentPreimage preimage, SendingParameters? sending_parameters);
PaymentId send_with_preimage_and_custom_tlvs(u64 amount_msat, PublicKey node_id, sequence<CustomTlvRecord> custom_tlvs, PaymentPreimage preimage, RouteParametersConfig? route_parameters);
[Throws=NodeError]
void send_probes(u64 amount_msat, PublicKey node_id);
};
Expand Down Expand Up @@ -254,7 +254,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 @@ -392,7 +392,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 All @@ -402,8 +402,9 @@ interface ClosureReason {
DisconnectedPeer();
OutdatedChannelManager();
CounterpartyCoopClosedUnfundedChannel();
LocallyCoopClosedUnfundedChannel();
FundingBatchClosure();
HTLCsTimedOut();
HTLCsTimedOut( PaymentHash? payment_hash );
PeerFeerateTooLow(u32 peer_feerate_sat_per_kw, u32 required_feerate_sat_per_kw);
};

Expand Down Expand Up @@ -456,11 +457,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 @@ -469,13 +470,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 @@ -485,22 +486,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 @@ -509,24 +510,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 @@ -861,7 +856,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