Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,22 @@
`Config::manually_handle_unknown_bolt11_payments` to `true`. Otherwise
matching inbound HTLCs will be failed back instead of emitting
`Event::PaymentClaimable`.
- The funding payment of a channel opened through a `Node::open_channel` variant is now
recorded under the `PaymentId` returned in the `ChannelOpen` result, rather than under an id
derived from the funding transaction's txid. Channels opened before upgrading, and channels
this node opens as an LSPS2 service, keep the txid-derived id. Applications that derived the
payment id from the funding txid should use the returned id instead.
- An outbound channel open that is still in flight at shutdown may be reported through
`Event::ChannelClosed` at the next startup, with the `user_channel_id` of the open and the
`ClosureReason::DisconnectedPeer` reason. Such an event may be emitted more than once for the
same open. Applications should handle a `ChannelClosed` event for a `user_channel_id` they do
not hold a channel for.

## Feature and API updates
- All `Node::open_channel` variants now return a `ChannelOpen` holding the `user_channel_id`
of the channel and the `PaymentId` the funding payment is recorded under. Once a variant
returns `Ok`, the open is tracked across restarts: an open the node loses while shut down is
reported through `Event::ChannelClosed` rather than disappearing silently.
- All `Node::open_channel` variants now take an optional `FeeRate` (after
`push_to_counterparty_msat`) that, when set, is used for the channel's funding transaction instead of the internal fee estimation. For the
`_with_all` variants it also determines the rate at which the maximum funding amount is
Expand Down
14 changes: 8 additions & 6 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@ interface Node {
[Throws=NodeError]
void disconnect(PublicKey node_id);
[Throws=NodeError]
UserChannelId open_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
ChannelOpen open_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
[Throws=NodeError]
UserChannelId open_announced_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
ChannelOpen open_announced_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
[Throws=NodeError]
UserChannelId open_channel_with_all(PublicKey node_id, SocketAddress address, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
ChannelOpen open_channel_with_all(PublicKey node_id, SocketAddress address, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
[Throws=NodeError]
UserChannelId open_announced_channel_with_all(PublicKey node_id, SocketAddress address, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
ChannelOpen open_announced_channel_with_all(PublicKey node_id, SocketAddress address, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
[Throws=NodeError]
UserChannelId open_0reserve_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
ChannelOpen open_0reserve_channel(PublicKey node_id, SocketAddress address, u64 channel_amount_sats, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
[Throws=NodeError]
UserChannelId open_0reserve_channel_with_all(PublicKey node_id, SocketAddress address, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
ChannelOpen open_0reserve_channel_with_all(PublicKey node_id, SocketAddress address, u64? push_to_counterparty_msat, FeeRate? fee_rate, ChannelConfig? channel_config);
[Throws=NodeError]
void splice_in([ByRef]UserChannelId user_channel_id, PublicKey counterparty_node_id, u64 splice_amount_sats, FeeRate? min_fee_rate);
[Throws=NodeError]
Expand Down Expand Up @@ -386,6 +386,8 @@ typedef string ChannelId;
[Custom]
typedef string UserChannelId;

typedef dictionary ChannelOpen;

typedef interface Mnemonic;

[Remote]
Expand Down
16 changes: 14 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use lightning_dns_resolver::OMDomainResolver;
use vss_client::headers::VssHeaderProvider;

use crate::chain::ChainSource;
use crate::channel::{OpenChannelTracker, SpliceTracker};
#[cfg(feature = "chain-bitcoind")]
use crate::config::BitcoindRestClientConfig;
use crate::config::{
Expand Down Expand Up @@ -730,7 +731,7 @@ impl NodeBuilder {
/// previously configured.
///
/// Connects to the PostgreSQL database at the given `connection_string`, e.g.,
/// `"postgres://user:password@localhost/ldk_db"`.
/// `"postgres://<user>:<password>@localhost/ldk_db"`.
///
/// The given `db_name` will be used or default to
/// [`DEFAULT_DB_NAME`](io::postgres_store::DEFAULT_DB_NAME). The `connection_string` must
Expand Down Expand Up @@ -1333,7 +1334,7 @@ impl Builder {
/// previously configured.
///
/// Connects to the PostgreSQL database at the given `connection_string`, e.g.,
/// `"postgres://user:password@localhost/ldk_db"`.
/// `"postgres://<user>:<password>@localhost/ldk_db"`.
///
/// The given `db_name` will be used or default to
/// [`DEFAULT_DB_NAME`](io::postgres_store::DEFAULT_DB_NAME). The `connection_string` must
Expand Down Expand Up @@ -2550,6 +2551,15 @@ fn build_with_store_internal(
})
});

let splice_tracker = Arc::new(SpliceTracker::new(
Arc::clone(&channel_manager),
Arc::clone(&wallet),
Arc::clone(&pending_payment_store),
Arc::clone(&logger),
));
let open_channel_tracker =
Arc::new(OpenChannelTracker::new(Arc::clone(&pending_payment_store), Arc::clone(&logger)));

#[cfg(cycle_tests)]
let mut _leak_checker = crate::LeakChecker(Vec::new());
#[cfg(cycle_tests)]
Expand Down Expand Up @@ -2601,6 +2611,8 @@ fn build_with_store_internal(
payment_store,
forwarding_store,
forwarded_payment_aggregation_retention_secs,
splice_tracker,
open_channel_tracker,
lnurl_auth,
is_running,
node_metrics,
Expand Down
Loading