Add PaymentId to PaymentPathFailed event
[rust-lightning] / CHANGELOG.md
1 # 0.0.102 - 2021-10-18
2
3 ## API Updates
4  * `get_route` now takes a `Score` as an argument. `Score` is queried during
5    the route-finding process, returning the absolute amounts which you are
6    willing to pay to avoid routing over a given channel. As a default, a
7    `Scorer` is provided which returns a constant amount, with a suggested
8    default of 500 msat. This translates to a willingness to pay up to 500 msat
9    in additional fees per hop in order to avoid additional hops (#1124).
10  * `Event::PaymentPathFailed` now contains a `short_channel_id` field which may
11    be filled in with a channel that can be "blamed" for the payment failure.
12    Payment retries should likely avoid the given channel for some time (#1077).
13  * `PublicKey`s in `NetworkGraph` have been replaced with a `NodeId` struct
14    which contains only a simple `[u8; 33]`, substantially improving
15    `NetworkGraph` deserialization performance (#1107).
16  * `ChainMonitor`'s `HashMap` of `ChannelMonitor`s is now private, exposed via
17    `Chainmonitor::get_monitor` and `ChainMonitor::list_monitors` instead
18    (#1112).
19  * When an outbound channel is closed prior to the broadcasting of its funding
20    transaction, but after you call
21    `ChannelManager::funding_transaction_generated`, a new event type,
22    `Event::DiscardFunding`, is generated, informing you the transaction was not
23    broadcasted and that you can spend the same inputs again elsewhere (#1098).
24  * `ChannelManager::create_channel` now returns the temporary channel ID which
25    may later appear in `Event::ChannelClosed` or `ChannelDetails` prior to the
26    channel being funded (#1121).
27  * `Event::PaymentSent` now contains the payment hash as well as the payment
28    preimage (#1062).
29  * `ReadOnlyNetworkGraph::get_addresses` now returns owned `NetAddress` rather
30    than references. As a side-effect this method is now exposed in foreign
31    language bindings (#1115).
32  * The `Persist` and `ChannelMonitorUpdateErr` types have moved to the
33    `lightning::chain::chainmonitor` and `lightning::chain` modules,
34    respectively (#1112).
35  * `ChannelManager::send_payment` now returns a `PaymentId` which identifies a
36    payment (whether MPP or not) and can be used to retry the full payment or
37    MPP parts through `retry_payment` (#1096). Note that doing so is currently
38    *not* crash safe, and you may find yourself sending twice. It is recommended
39    that you *not* use the `retry_payment` API until the next release.
40
41 ## Bug Fixes
42  * Due to an earlier fix for the Lightning dust inflation vulnerability tracked
43    in CVE-2021-41591/CVE-2021-41592/CVE-2021-41593 in 0.0.100, we required
44    counterparties to accept a dust limit slightly lower than the dust limit now
45    required by other implementations. This appeared as, at least, latest lnd
46    always refusing to accept channels opened by LDK clients (#1065).
47  * If there are multiple channels available to the same counterparty,
48    `get_route` would only consider the channel listed last as available for
49    sending (#1100).
50  * `Persist` implementations returning
51    `ChannelMonitorUpdateErr::TemporaryFailure` from `watch_channel` previously
52    resulted in the `ChannelMonitor` not being stored at all, resulting in a
53    panic after monitor updating is complete (#1112).
54  * If payments are pending awaiting forwarding at startup, an
55    `Event::PendingHTLCsForwardable` event will always be provided. This ensures
56    user code calls `ChannelManager::process_pending_htlc_fowards` even if it
57    shut down while awaiting the batching timer during the previous run (#1076).
58  * If a call to `ChannelManager::send_payment` failed due to lack of
59    availability of funds locally, LDK would store the payment as pending
60    forever, with no ability to retry or fail it, leaking memory (#1109).
61
62 ## Serialization Compatibility
63  * All above new Events/fields are ignored by prior clients. All above new
64    Events/fields, except for `Event::PaymentSent::payment_hash` are not present
65    when reading objects serialized by prior versions of the library.
66
67 In total, this release features 32 files changed, 2248 insertions, and 1483
68 deletions in 51 commits from 7 authors, in alphabetical order:
69
70  * 1nF0rmed
71  * Duncan Dean
72  * Elias Rohrer
73  * Galder Zamarreño
74  * Jeffrey Czyz
75  * Matt Corallo
76  * Valentine Wallace
77
78
79 # 0.0.101 - 2021-09-23
80
81 ## API Updates
82  * Custom message types are now supported directly in the `PeerManager`,
83    allowing you to send and receive messages of any type that is not natively
84    understood by LDK. This requires a new type bound on `PeerManager`, a
85    `CustomMessageHandler`. `IgnoringMessageHandler` provides a simple default
86    for this new bound for ignoring unknown messages (#1031, #1074).
87  * Route graph updates as a result of failed payments are no longer provided as
88    `MessageSendEvent::PaymentFailureNetworkUpdate` but instead included in a
89    new field in the `Event::PaymentFailed` events. Generally, this means route
90    graph updates are no longer handled as a part of the `PeerManager` but
91    instead through the new `EventHandler` implementation for
92    `NetGraphMsgHandler`. To make this easy, a new parameter to
93    `lightning-background-processor::BackgroundProcessor::start` is added, which
94    contains an `Option`al `NetGraphmsgHandler`. If provided as `Some`, relevant
95    events will be processed by the `NetGraphMsgHandler` prior to normal event
96    handling (#1043).
97  * `NetworkGraph` is now, itself, thread-safe. Accordingly, most functions now
98    take `&self` instead of `&mut self` and the graph data can be accessed
99    through `NetworkGraph.read_only` (#1043).
100  * The balances available on-chain to claim after a channel has been closed are
101    now exposed via `ChannelMonitor::get_claimable_balances` and
102    `ChainMonitor::get_claimable_balances`. The second can be used to get
103    information about all closed channels which still have on-chain balances
104    associated with them. See enum variants of `ln::channelmonitor::Balance` and
105    method documentation for the above methods for more information on the types
106    of balances exposed (#1034).
107  * When one HTLC of a multi-path payment fails, the new field `all_paths_failed`
108    in `Event::PaymentFailed` is set to `false`. This implies that the payment
109    has not failed, but only one part. Payment resolution is only indicated by an
110    `Event::PaymentSent` event or an `Event::PaymentFailed` with
111    `all_paths_failed` set to `true`, which is also set for the last remaining
112    part of a multi-path payment (#1053).
113  * To better capture the context described above, `Event::PaymentFailed` has
114    been renamed to `Event::PaymentPathFailed` (#1084).
115  * A new event, `ChannelClosed`, is provided by `ChannelManager` when a channel
116    is closed, including a reason and error message (if relevant, #997).
117  * `lightning-invoice` now considers invoices with sub-millisatoshi precision
118    to be invalid, and requires millisatoshi values during construction (thus
119    you must call `amount_milli_satoshis` instead of `amount_pico_btc`, #1057).
120  * The `BaseSign` interface now includes two new hooks which provide additional
121    information about commitment transaction signatures and revocation secrets
122    provided by our counterparty, allowing additional verification (#1039).
123  * The `BaseSign` interface now includes additional information for cooperative
124    close transactions, making it easier for a signer to verify requests (#1064).
125  * `Route` has two additional helper methods to get fees and amounts (#1063).
126  * `Txid` and `Transaction` objects can now be deserialized from responses when
127    using the HTTP client in the `lightning-block-sync` crate (#1037, #1061).
128
129 ## Bug Fixes
130  * Fix a panic when reading a lightning invoice with a non-recoverable
131    signature. Further, restrict lightning invoice parsing to require payment
132    secrets and better handle a few edge cases as required by BOLT 11 (#1057).
133  * Fix a panic when receiving multiple messages (such as HTLC fulfill messages)
134    after a call to `chain::Watch::update_channel` returned
135    `Err(ChannelMonitorUpdateErr::TemporaryFailure)` with no
136    `ChannelManager::channel_monitor_updated` call in between (#1066).
137  * For multi-path payments, `Event::PaymentSent` is no longer generated
138    multiple times, once for each independent part (#1053).
139  * Multi-hop route hints in invoices are now considered in the default router
140    provided via `get_route` (#1040).
141  * The time peers have to respond to pings has been increased when building
142    with debug assertions enabled. This avoids peer disconnections on slow hosts
143    when running in debug mode (#1051).
144  * The timeout for the first byte of a response for requests from the
145    `lightning-block-sync` crate has been increased to 300 seconds to better
146    handle the long hangs in Bitcoin Core when it syncs to disk (#1090).
147
148 ## Serialization Compatibility
149  * Due to a bug in 0.0.100, `Event`s written by 0.0.101 which are of a type not
150    understood by 0.0.100 may lead to `Err(DecodeError::InvalidValue)` or corrupt
151    deserialized objects in 0.100. Such `Event`s will lead to an
152    `Err(DecodeError::InvalidValue)` in versions prior to 0.0.100. The only such
153    new event written by 0.0.101 is `Event::ChannelClosed` (#1087).
154  * Payments that were initiated in versions prior to 0.0.101 may still
155    generate duplicate `PaymentSent` `Event`s or may have spurious values for
156    `Event::PaymentPathFailed::all_paths_failed` (#1053).
157  * The return values of `ChannelMonitor::get_claimable_balances` (and, thus,
158    `ChainMonitor::get_claimable_balances`) may be spurious for channels where
159    the spend of the funding transaction appeared on chain while running a
160    version prior to 0.0.101. `Balance` information should only be relied upon
161    for channels that were closed while running 0.0.101+ (#1034).
162  * Payments failed while running versions prior to 0.0.101 will never have a
163    `Some` for the `network_update` field (#1043).
164
165 In total, this release features 67 files changed, 4980 insertions, 1888
166 deletions in 89 commits from 12 authors, in alphabetical order:
167  * Antoine Riard
168  * Devrandom
169  * Galder Zamarreño
170  * Giles Cope
171  * Jeffrey Czyz
172  * Joseph Goulden
173  * Matt Corallo
174  * Sergi Delgado Segura
175  * Tibo-lg
176  * Valentine Wallace
177  * abhik-99
178  * vss96
179
180
181 # 0.0.100 - 2021-08-17
182
183 ## API Updates
184  * The `lightning` crate can now be built in no_std mode, making it easy to
185    target embedded hardware for rust users. Note that mutexes are replaced with
186    no-ops for such builds (#1008, #1028).
187  * LDK now supports sending and receiving "keysend" payments. This includes
188    modifications to `lightning::util::events::Event::PaymentReceived` to
189    indicate the type of payment (#967).
190  * A new variant, `lightning::util::events::Event::PaymentForwarded` has been
191    added which indicates a forwarded payment has been successfully claimed and
192    we've received a forwarding fee (#1004).
193  * `lightning::chain::keysinterface::KeysInterface::get_shutdown_pubkey` has
194    been renamed to `get_shutdown_scriptpubkey`, returns a script, and is now
195    called on channel open only if
196    `lightning::util::config::ChannelConfig::commit_upfront_shutdown_pubkey` is
197    set (#1019).
198  * Closing-signed negotiation is now more configurable, with an explicit
199    `lightning::util::config::ChannelConfig::force_close_avoidance_max_fee_satoshis`
200    field allowing you to select the maximum amount you are willing to pay to
201    avoid a force-closure. Further, we are now less restrictive on the fee
202    placed on the closing transaction when we are not the party paying it. To
203    control the feerate paid on a channel at close-time, use
204    `ChannelManager::close_channel_with_target_feerate` instead of
205    `close_channel` (#1011).
206  * `lightning_background_processor::BackgroundProcessor` now stops the
207    background thread when dropped (#1007). It is marked `#[must_use]` so that
208    Rust users will receive a compile-time warning when it is immediately
209    dropped after construction (#1029).
210  * Total potential funds burn on force-close due to dust outputs is now limited
211    to `lightning::util::config::ChannelConfig::max_dust_htlc_exposure_msat` per
212    channel (#1009).
213  * The interval on which
214    `lightning::ln::peer_handler::PeerManager::timer_tick_occurred` should be
215    called has been reduced to once every five seconds (#1035) and
216    `lightning::ln::channelmanager::ChannelManager::timer_tick_occurred` should
217    now be called on startup in addition to once per minute (#985).
218  * The rust-bitcoin and bech32 dependencies have been updated to their
219    respective latest versions (0.27 and 0.8, #1012).
220
221 ## Bug Fixes
222  * Fix panic when reading invoices generated by some versions of c-lightning
223    (#1002 and #1003).
224  * Fix panic when attempting to validate a signed message of incorrect length
225    (#1010).
226  * Do not ignore the route hints in invoices when the invoice is over 250k
227    sats (#986).
228  * Fees are automatically updated on outbound channels to ensure commitment
229    transactions are always broadcastable (#985).
230  * Fixes a rare case where a `lightning::util::events::Event::SpendableOutputs`
231    event is not generated after a counterparty commitment transaction is
232    confirmed in a reorg when a conflicting local commitment transaction is
233    removed in the same reorg (#1022).
234  * Fixes a remotely-triggerable force-closure of an origin channel after an
235    HTLC was forwarded over a next-hop channel and the next-hop channel was
236    force-closed by our counterparty (#1025).
237  * Fixes a rare force-closure case when sending a payment as a channel fundee
238    when overdrawing our remaining balance. Instead the send will fail (#998).
239  * Fixes a rare force-closure case when a payment was claimed prior to a
240    peer disconnection or restart, and later failed (#977).
241
242 ## Serialization Compatibility
243  * Pending inbound keysend payments which have neither been failed nor claimed
244    when serialized will result in a `ChannelManager` which is not readable on
245    pre-0.0.100 clients (#967).
246  * Because
247    `lightning::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey`
248    has been updated to return a script instead of only a `PublicKey`,
249    `ChannelManager`s constructed with custom `KeysInterface` implementations on
250    0.0.100 and later versions will not be readable on previous versions.
251    `ChannelManager`s created with 0.0.99 and prior versions will remain readable
252    even after the a serialization roundtrip on 0.0.100, as long as no new
253    channels are opened. Further, users using a
254    `lightning::chain::keysinterface::KeysManager` as their `KeysInterface` will
255    have `ChannelManager`s which are readable on prior versions as well (#1019).
256  * `ChannelMonitorUpdate`s created by 0.0.100 and later for channels when
257    `lightning::util::config::ChannelConfig::commit_upfront_shutdown_pubkey` is
258    not set may not be readable by versions prior to 0.0.100 (#1019).
259  * HTLCs which were in the process of being claimed on-chain when a pre-0.0.100
260    `ChannelMonitor` was serialized may generate `PaymentForwarded` events with
261    spurious `fee_earned_msat` values. This only applies to payments which were
262    unresolved at the time of the upgrade (#1004).
263  * 0.0.100 clients with pending `Event::PaymentForwarded` events at
264    serialization-time will generate serialized `ChannelManager` objects which
265    0.0.99 and earlier clients cannot read. The likelihood of this can be reduced
266    by ensuring you process all pending events immediately before serialization
267    (as is done by the `lightning-background-processor` crate, #1004).
268
269
270 In total, this release features 59 files changed, 5861 insertions, and 2082
271 deletions in 95 commits from 6 authors.
272
273
274 # 0.0.99 - 2021-07-09
275
276 ## API Updates
277
278  * `lightning_block_sync::poll::Validate` is now public, allowing you to
279    implement the `lightning_block_sync::poll::Poll` trait without
280    `lightning_block_sync::poll::ChainPoller` (#956).
281  * `lightning::ln::peer_handler::PeerManager` no longer requires that no calls
282    are made to referencing the same `SocketDescriptor` after
283    `disconnect_socket` returns. This makes the API significantly less
284    deadlock-prone and simplifies `SocketDescriptor` implementations
285    significantly. The relevant changes have been made to `lightning_net_tokio`
286    and `PeerManager` documentation has been substantially rewritten (#957).
287  * `lightning::util::message_signing`'s `sign` and `verify` methods now take
288    secret and public keys by reference instead of value (#974).
289  * Substantially more information is now exposed about channels in
290    `ChannelDetails`. See documentation for more info (#984 and #988).
291  * The latest best block seen is now exposed in
292    `ChannelManager::current_best_block` and
293    `ChannelMonitor::current_best_block` (#984).
294  * Feerates charged when forwarding payments over channels is now set in
295    `ChannelConfig::fee_base_msat` when the channel is opened. For existing
296    channels, the value is set to the value provided in
297    `ChannelManagerReadArgs::default_config::channel_options` the first time the
298    `ChannelManager` is loaded in 0.0.99 (#975).
299  * We now reject HTLCs which are received to be forwarded over private channels
300    unless `UserConfig::accept_forwards_to_priv_channels` is set. Note that
301    `UserConfig` is never serialized and must be provided via
302    `ChannelManagerReadArgs::default_config` at each start (#975).
303
304 ## Bug Fixes
305
306  * We now forward gossip messages to peers instead of only relaying
307    locally-generated gossip or sending gossip messages during initial sync
308    (#948).
309  * Correctly send `channel_update` messages to direct peers on private channels
310    (#949). Without this, a private node connected to an LDK node over a private
311    channel cannot receive funds as it does not know which fees the LDK node
312    will charge.
313  * `lightning::ln::channelmanager::ChannelManager` no longer expects to be
314    persisted spuriously after we receive a `channel_update` message about any
315    channel in the routing gossip (#972).
316  * Asynchronous `ChannelMonitor` updates (using the
317    `ChannelMonitorUpdateErr::TemporaryFailure` return variant) no longer cause
318    spurious HTLC forwarding failures (#954).
319  * Transaction provided via `ChannelMonitor::transactions_confirmed`
320    after `ChannelMonitor::best_block_updated` was called for a much later
321    block now trigger all relevant actions as of the later block. Previously
322    some transaction broadcasts or other responses required an additional
323    block be provided via `ChannelMonitor::best_block_updated` (#970).
324  * We no longer panic in rare cases when an invoice contained last-hop route
325    hints which were unusable (#958).
326
327 ## Node Compatibility
328
329  * We now accept spurious `funding_locked` messages sent prior to
330    `channel_reestablish` messages after reconnect. This is a
331    [known, long-standing bug in lnd](https://github.com/lightningnetwork/lnd/issues/4006)
332    (#966).
333  * We now set the `first_blocknum` and `number_of_blocks` fields in
334    `reply_channel_range` messages to values which c-lightning versions prior to
335    0.10 accepted. This avoids spurious force-closes from such nodes (#961).
336
337 ## Serialization Compatibility
338
339  * Due to a bug discovered in 0.0.98, if a `ChannelManager` is serialized on
340    version 0.0.98 while an `Event::PaymentSent` is pending processing, the
341    `ChannelManager` will fail to deserialize both on version 0.0.98 and later
342    versions. If you have such a `ChannelManager` available, a simple patch will
343    allow it to deserialize. Please file an issue if you need assistance (#973).
344
345 # 0.0.98 - 2021-06-11
346
347 0.0.98 should be considered a release candidate to the first alpha release of
348 Rust-Lightning and the broader LDK. It represents several years of work
349 designing and fine-tuning a flexible API for integrating lightning into any
350 application. LDK should make it easy to build a lightning node or client which
351 meets specific requirements that other lightning node software cannot. As
352 lightning continues to evolve, and new use-cases for lightning develop, the API
353 of LDK will continue to change and expand. However, starting with version 0.1,
354 objects serialized with prior versions will be readable with the latest LDK.
355 While Rust-Lightning is approaching the 0.1 milestone, language bindings
356 components of LDK available at https://github.com/lightningdevkit are still of
357 varying quality. Some are also approaching an 0.1 release, while others are
358 still much more experimental. Please note that, at 0.0.98, using Rust-Lightning
359 on mainnet is *strongly* discouraged.