LDK v0.0.116: Lightning Anchor Channels Support
Lightning Development Kit (LDK) is a library that allows you to build a lightning node without worrying about implementing low-level lightning logic correctly.
- "LDK is based on Rust-Lightning, a full-featured but also incredibly flexible lightning implementation, allowing you to decide how to use it."
- "Learn how to start adding Lightning to your apps at lightningdevkit.org."
What's new
API Updates
- Support for zero-HTLC-fee anchor output channels has been added and is now considered beta (#2367). Users who set
ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_txshould be
prepared to handle the newEvent::BumpTransaction, e.g. via theBumpTransactionEventHandler(#2089). Note that in order to do so you must ensure you always have a reserve of available unspent on-chain funds to use for CPFP. LDK currently makes no attempt to ensure this for you. - Users who set
ChannelHandshakeConfig::negotiate_anchors_zero_fee_htlc_txand wish to accept inbound anchor-based channels must do so manually by settingUserConfig::manually_accept_inbound_channels(#2368). - Support forwarding and accepting HTLCs with a reduced amount has been added, to support LSPs skimming a fee on the penultimate hop (#2319).
- BOLT11 and BOLT12 Invoice and related types have been renamed to include a BOLTNN prefix, ensuring uniqueness in
lightning{,-invoice}crates (#2416). Scorers now have an associated type which represents a parameter passed when calculating penalties. This allows for the sameScorer to be used with different penalty calculation parameters (#2237).DefaultRouteris no longer restrained to aMutex-wrappedScore,
allowing it to be used inno-stdbuilds (#2383).CustomMessageHandler::provided_{node,init}_featuresand various custom feature bit methods on*Featureswere added (#2204).- Keysend/push payments using MPP are now supported when receiving if
UserConfig::accept_mpp_keysendis set and when sending if specified in thePaymentParameters. Note that not all recipients support this (#2156). - A new
ConfirmationTarget::MempoolMinimumhas been added (#2415). SpendableOutputDescriptor::to_psbt_inputwas added (#2286).ChannelManager::update_partial_channel_configwas added (#2330).ChannelDetails::channel_shutdown_statewas added (#2347).- The shutdown script can now be provided at shutdown time via
ChannelManager::close_channel_with_feerate_and_script(#2219). BroadcasterInterfacenow takes multiple transactions at once. While not available today, in the future single calls should be passed to a full node via a single batch/package transaction acceptance API (#2272).Balance::claimable_amount_satoshiswas added (#2333).payment_{hash,preimage}have been added to someBalancevariants (#2217).- The
lightning::chain::keysinterfaceis nowlightning::sign(#2246). - Routing to a blinded path has been implemented, though sending to such a route is not yet supported in
ChannelManager(#2120). OffersMessageHandlerwas added for offers-related onion messages (#2294).- The
CustomMessageHandlerparameter toPeerManagerhas moved toMessageHandlerfromPeerManager::newexplicitly (#2249). - Various P2P messages for dual funding channel establishment have been added, though handling for them is not yet in
ChannelManager(#1794) - Script-fetching methods in
signinterfaces can now return errors, see docs for the implications of failing (#2213). - The
data_loss_protectoption is now required when readingchannel_reestablishmessages, as many others have done (#2253). InFlightHtlcs::add_inflight_htlchas been added (#2042).- The
initmessagenetworksfield is now written and checked (#2329). PeerManagergenerics have been simplified with the introduction of theAPeerManagertrait (#2249).ParitalOrdandOrdare now implemented forInvoice(#2279).ParitalEqandDebugare now implemented forInMemorySigner(#2328).ParitalEqandEqare now implemented forPaymentError(#2316).NetworkGraph::update_channel_from_announcement_no_lookupwas added (#2222).lightning::routing::gossip::verify_{channel,node}_announcementwas added (#2307).
Backwards Compatibility
PaymentParameterswritten with blinded path info using LDK 0.0.115 will not be readable in LDK 0.0.116, and vice versa.- Forwarding less than
Event::HTLCIntercepted::expected_outbound_amount_msatinChannelManager::forward_intercepted_htlcmay prevent theChannelManagerfrom being read by LDK prior to 0.0.116 (#2319) - Setting
ChannelConfig::accept_underpaying_htlcsmay prevent theChannelManagerfrom being read by LDK prior to 0.0.116 and un-setting the parameter between restarts may lead to payment failures (#2319). ChannelManager::create_inbound_payment{,_for_hash}_legacyhas been removed, removing the ability to create inbound payments which are claimable after downgrade to LDK 0.0.103 and prior. In the future handling such payments will also be removed (#2351).- Some fields required by LDK 0.0.103 and earlier are no longer written, thus deserializing objects written by 0.0.116 with 0.0.103 may now fail (#2351).
Bug Fixes
ChannelDetails::next_outbound_htlc_limit_msatwas made substantially more accurate and a correspondingnext_outbound_htlc_minimum_msatwas added.
This resolves issues where unpayable routes were generated due to
overestimation of the amount which is payable over one of our channels as the first hop (#2312).- A rare case where delays in processing
Events generated byChannelMonitors could lead to loss of those events in case of an untimely crash. This could lead to the loss of anEvent::SpendableOutputs(#2369). - Fixed a regression in 0.0.115 which caused
PendingHTLCsForwardableevents to be missed when processing phantom node receives. This caused such payments to be delayed until a further, unrelated HTLC came in (#2395). - Peers which are unresponsive to channel messages for several timer ticks are now disconnected to allow for on-reconnection state machine reset. This works around some issues in LND prior to 16.3 which can cause channels to hang and eventually force-close (#2293).
ChannelManager::newnow requires the current time (either from a recent block header or the system clock), ensuring invoices created immediately after startup aren't already expired (#2372).- Resolved an issue where reading a
ProbabilisticScoreron some platforms (e.g. iOS) can lead to a panic (#2322). ChannelConfig::max_dust_htlc_exposureis now allowed to scale based on current fees, and the default has been updated to do so. This substantially reduces the chance of force-closure due to dust exposure. Note that existing channels will retain their current value and you may wish to update the value on your existing channels on upgrade (#2354).PeerManager::process_eventsno longer blocks in any case. This fixes a bug where reentrancy fromPeerManagerinto user code which eventually callsprocess_eventscould lead to a deadlock (#2280).- The persist timing of network graph and scoring in
lightning-background-processorhas been tweaked to provide more reliable
persistence after updates to either (#2226). - The number of route hints added to BOLT 11 invoices by the
lightning-invoice::utilsbuilders has been reduced to three to ensure invoices can be represented in scan-able QR codes (#2044). - Fixed sending large onion messages, which would previously have resulted in an HMAC error on the second hop (#2277).
- Fixed a memory leak that may occur when a
ChannelManagerorChannelMonitorisdroped (#2233). - A potential deadlock in calling
NetworkGraph::eqwas resolved (#2284). - Fixed an overflow which prevented disconnecting peers in some minor cases with more than 31 peers (#2245).
- Gossip messages with an unknown chain hash are now ignored (#2230).
- Rapid Gossip Sync processing now fails on an unknown chain hash (#2324).
RouteHintHop::htlc_maximum_msatis now enforced. Note that BOLT11 route hints do not have such a field so this code is generally unused (#2305).
Security
0.0.116 fixes a denial-of-service vulnerability which is reachable from
untrusted input from channel counterparties if a 0-conf channel exists with that counterparty.
- A premature
announcement_signaturesmessage from a peer prior to a 0-conf channel's funding transaction receiving any confirmations would panic in any version since 0-conf channels were introduced (#2439).
In total, this release features 142 files changed, 21033 insertions, 11066
deletions in 327 commits from 21 authors, in alphabetical order:
- Alec Chen
- Andrei
- Antoine Riard
- Arik Sosman
- Chad Upjohn
- Daniel Granhão
- Duncan Dean
- Elias Rohrer
- Fred Walker
- Gleb Naumenko
- Jeffrey Czyz
- Martin Habovstiak
- Matt Corallo
- Tony Giorgio
- Valentine Wallace
- Vladimir Fomene
- Willem Van Lint
- Wilmer Paulino
- benthecarman
- ff
- henghonglee