Commit Graph

4189 Commits

Author SHA1 Message Date
Matt Corallo
a6609d6d6a
Merge pull request #1753 from wpaulino/avoid-redundant-claims-after-initial-conf
Avoid generating redundant claims after initial confirmation
2022-11-02 19:23:15 +00:00
Wilmer Paulino
a0891368ee
Avoid generating redundant claims after initial confirmation
These claims will never be valid as a previous claim has already
confirmed. If a previous claim is reorged out of the chain, a new claim
will be generated bypassing the new behavior.

While this doesn't change much for our existing transaction-based
claims, as broadcasting an already confirmed transaction acts as a NOP,
it prevents us from yielding redundant event-based claims, which will be
introduced as part of the anchors patchset.
2022-11-02 10:07:45 -07:00
Gleb Naumenko
080c70f98f Track the time a stale channel was pruned 2022-11-02 09:45:21 +02:00
Matt Corallo
0df712aaed Add a pending changelog entry for the past few commits 2022-11-02 01:09:07 +00:00
Matt Corallo
b5f1da6034 Allow users to specify the PaymentId used in InvoicePayer
In order to allow users to pass a custom idempotency key to the
`send*` methods in `InvoicePayer`, we have to pipe the `PaymentId`
through to the `Payer` methods, which we do here.

By default, existing `InvoicePayer` methods use the `PaymentHash`
as the `PaymentId`, however we also add duplicate `send*_with_id`
methods which allow users to pass a custom `PaymentId`.

Finally, appropriate documentation updates are made to clarify
idempotency guarantees.
2022-11-02 01:09:07 +00:00
Matt Corallo
0ae45a2578 Test that PaymentIds are idempotency keys until abandon_payment 2022-11-02 01:09:07 +00:00
Matt Corallo
548f3f8416 Stop timing out payments automatically, requiring abandon_payment
When the `abandon_payment` flow was added there was some concern
that upgrading users may not migrate to the new flow, causing
memory leaks in the pending-payment tracking.

While this is true, now that we're relying on the
pending_outbound_payments map for `send_payment` idempotency, the
risk of removing a payment prematurely goes up from "spurious
retry failure" to "sending a duplicative payment", which is much
worse.

Thus, we simply remove the automated payment timeout here,
explicitly requiring that users call `abandon_payment` when they
give up retrying a payment.
2022-11-02 01:09:07 +00:00
Matt Corallo
166e0c88e4 Delay removal of fulfilled outbound payments for a few timer ticks
Previously, once a fulfilled outbound payment completed and all
associated HTLCs were resolved, we'd immediately remove the payment
entry from the `pending_outbound_payments` map.

Now that we're using the `pending_outbound_payments` map for send
idempotency, this presents a race condition - if the user makes a
redundant `send_payment` call at the same time that the original
payment's last HTLC is resolved, the user would reasonably expect
the `send_payment` call to fail due to our idempotency guarantees.

However, because the `pending_outbound_payments` entry is being
removed, if it completes first the `send_payment` call will
succeed even though the user has not had a chance to see the
corresponding `Event::PaymentSent`.

Instead, here, we delay removal of `Fulfilled`
`pending_outbound_payments` entries until several timer ticks have
passed without any corresponding event or HTLC pending.
2022-11-02 01:09:07 +00:00
Matt Corallo
a10223d1ff Allow users to specify the PaymentId for new outbound payments
In c986e52ce8, an `MppId` was added
to `HTLCSource` objects as a way of correlating HTLCs which belong
to the same payment when the `ChannelManager` sees an HTLC
succeed/fail. This allows it to have awareness of the state of all
HTLCs in a payment when it generates the ultimate user-facing
payment success/failure events. This was used in the same PR to
avoid generating duplicative success/failure events for a single
payment.

Because the field was only used as an internal token to correlate
HTLCs, and retries were not supported, it was generated randomly by
calling the `KeysInterface`'s 32-byte random-fetching function.
This also provided a backwards-compatibility story as the existing
HTLC randomization key was re-used for older clients.

In 28eea12bbe `MppId` was renamed to
the current `PaymentId` which was then used expose the
`retry_payment` interface, allowing users to send new HTLCs which
are considered a part of an existing payment.

At no point has the payment-sending API seriously considered
idempotency, a major drawback which leaves the API unsafe in most
deployments. Luckily, there is a simple solution - because the
`PaymentId` must be unique, and because payment information for a
given payment is held for several blocks after a payment
completes/fails, it represents an obvious idempotency token.

Here we simply require the user provide the `PaymentId` directly in
`send_payment`, allowing them to use whatever token they may
already have for a payment's idempotency token.
2022-11-02 01:09:07 +00:00
Matt Corallo
6ca49948c1
Merge pull request #1791 from valentinewallace/2022-10-we-are-intro-node
Onion messages: fix edge case where we are the intro node
2022-11-01 21:12:30 +00:00
Gleb Naumenko
a39d9bfa03 Prune channels if *either* not updated 2022-11-01 16:51:08 +02:00
Gleb Naumenko
494e3aad9f Non-mandatory "fix" enabling future tests 2022-11-01 16:51:08 +02:00
valentinewallace
ad7ff0b23d
Merge pull request #1815 from TheBlueMatt/2022-10-dead-gossip-code
Require directional updates for a DirectionalChannelInfo
2022-10-31 20:02:52 -04:00
Matt Corallo
0f8c8d6695
Merge pull request #1818 from TheBlueMatt/2022-10-stable-bench
Use rustc stable for benchmark CI run to fix current breakage
2022-10-31 21:28:53 +00:00
Matt Corallo
2ef3d18906 Use rustc stable for benchmark CI run to fix current breakage 2022-10-31 18:46:31 +00:00
Valentine Wallace
7af02d0174
OMs: fix panic sending to a two-hop blinded route where we are the intro node 2022-10-31 12:40:09 -04:00
Valentine Wallace
a4e242ba5f
Onion messages: fix edge case where we are the introduction node
If we're sending straight to a blinded route with no unblinded intermediate
hops, and we are the introduction node, we need to advance the blinded route by
one hop so that the second hop is the new introduction node.
2022-10-31 12:38:31 -04:00
Matt Corallo
4df0ff74f5 Make htlc_maximum_msat in EffectiveCapacity non-Optional
Because we now never generate an `EffectiveCapacity` with an
`htlc_maximum_msat` set to `None`, making it non-`Option`al
effectively removes dead code, which we do here.
2022-10-29 20:38:59 +00:00
Matt Corallo
81afc2f172 Require directional updates for a DirectionalChannelInfo
We currently construct `DirectedChannelInfo`s for routing before
checking if the given direction has its directional info filled in.
We then always check for directional info before actually deciding
to route over a channel, as otherwise we assume the channel is not
online.

This makes for somewhat redundant checks, and `DirectedCHannelInfo`
isn't, by itself, a very useful API. Because fetching the HTLC-max
or effective channel capacity gives spurious data if no directional
info is available, there's little reason to have that data
available, and so we here check for directional info first. This
effectively merges `DirectionalChannelInfo` and
`DirectionalChannelInfoWithUpdate`.
2022-10-29 20:38:54 +00:00
Valentine Wallace
dc7f65f703
Remove unused payment_hash param from Router::find_route
This helps prepare for moving the Router trait into ChannelManager, which will
help allow ChannelManager to retrieve routes for trampoline
2022-10-27 18:02:12 -04:00
Valentine Wallace
59e24bd176
Fix inaccurate comment in InvoicePayer 2022-10-27 18:02:12 -04:00
Matt Corallo
6957fb63f9
Merge pull request #1809 from valentinewallace/2022-10-custom-om-self
Give us a self when reading a custom onion message
2022-10-27 21:34:45 +00:00
Matt Corallo
150c87a089
Give us a self when reading a custom onion message
+ remove MaybeReadableArgs trait as it is now unused
+ remove onion_utils::DecodeInput as it would've now needed to be parameterized
by the CustomOnionMessageHandler trait, and we'd like to avoid either
implementing DecodeInput in messenger or having onion_utils depend on
onion_message::*

Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
2022-10-27 15:58:33 -04:00
Matt Corallo
4ec4e89eec
Merge pull request #1805 from TheBlueMatt/2022-10-remote-useless-mut
Drop useless `mut` in `KeysInterface::sign_holder_anchor_input`
2022-10-27 16:11:28 +00:00
Matt Corallo
962d0966bf
Merge pull request #1807 from TheBlueMatt/2022-10-errorkind-bindings
Export io::ErrorKind in bindings
2022-10-27 16:11:14 +00:00
Matt Corallo
2c69e05d5c Export io::ErrorKind in bindings
The bindings have exported `io::Error` as, basically,
`io::ErrorKind`, for quite some time, so there's little reason to
not just export `io::ErrorKind` as well.
2022-10-27 01:29:05 +00:00
Matt Corallo
f63df167a1 Drop useless mut in KeysInterface::sign_holder_anchor_input
The `Transaction` is not modified so there's no reason to make the
reference `mut`
2022-10-26 20:46:34 +00:00
valentinewallace
2e343e78ca
Merge pull request #1797 from arik-so/2022-10-channel-manager-deparameterization
Deparametrize `ChannelManager` to infer `Signer` from its `KeysInterface`.
2022-10-26 13:32:09 -04:00
Matt Corallo
3b2f694c29
Merge pull request #1802 from TheBlueMatt/2022-10-112
Add release date and release name to CHANGELOG for 0.0.112
2022-10-25 21:33:34 +00:00
Matt Corallo
979d147cf8 Refer to lnd as LND in CHANGELOG
for consistency since its an abbreviation for "lightning network
daemon".
2022-10-25 18:59:41 +00:00
Matt Corallo
16f1efefb9 Add release date and release name to CHANGELOG for 0.0.112 2022-10-25 18:58:54 +00:00
Matt Corallo
ccbf3302a7
Merge pull request #1798 from TheBlueMatt/2022-10-112
Cut 0.0.112
2022-10-25 18:57:01 +00:00
Arik Sosman
22c367b13b
Deparametrize ChannelManager to infer Signer from its KeysInterface. 2022-10-25 10:02:28 -07:00
Matt Corallo
9b77a8a78b Add release notes for 0.0.112 2022-10-24 19:40:37 +00:00
Valentine Wallace
20eecd5a76
Remove outdated allow(unused) 2022-10-24 15:00:03 -04:00
Matt Corallo
35154a15c3 Bump crate versions to 0.0.112/invoice 0.20 2022-10-24 18:53:58 +00:00
Matt Corallo
a834a04e5c Do not export new anchors structs in events.rs without anchors
This avoids adding unused, effectively-dummy public structs in
`events.rs`.
2022-10-24 18:53:58 +00:00
Matt Corallo
a257906743
Merge pull request #1779 from valentinewallace/2022-10-node-pk-keysinterface
Add `KeysInterface::get_node_id` method
2022-10-24 17:37:25 +00:00
Valentine Wallace
7082d6cd2a
KeysInterface docs: note that Recipient type must be supported by impl 2022-10-24 11:38:30 -04:00
Matt Corallo
fc9a4c22d1
Merge pull request #1780 from wpaulino/rust-edition-2018 2022-10-22 01:05:26 +00:00
Wilmer Paulino
f4f1093edc
Bump workspace to rust edition 2018
Mostly motivated by the need of async/await.
2022-10-21 14:47:34 -07:00
Valentine Wallace
17c0fc82a4
Add KeysInterface::get_node_id method
Useful since we're working on getting rid of KeysInterface::get_node_secret to
complete support for remote signing.

Will be used in upcoming work to check whether an outbound onion message
blinded path has our node id as the introduction node id
2022-10-21 15:54:03 -04:00
valentinewallace
ad82c9ea5b
Merge pull request #1770 from jkczyz/2022-10-debug-route-hints
Add logging in route hint filtering
2022-10-21 13:04:45 -04:00
valentinewallace
fbacbc08b2
Merge pull request #1788 from TheBlueMatt/2022-10-mtlc-writer
Add `WriteableScore` bindings impl for `MultiThreadedLockableScore`
2022-10-21 11:28:15 -04:00
Matt Corallo
6ec9b5357f Add WriteableScore bindings impl for MultiThreadedLockableScore
In 56b07e52aa we made
`MultiThreadedLockableScore` fully bindings-compatible. However, it
did not add a `WriteableScore` implementation for it. This was an
oversight as it is a `WriteableScore` in Rust and needs to be for
use in other parts of the API.

Here we add the required impl in a way that the bindings generator
is able to handle it and add conversion utilities.
2022-10-21 01:08:30 +00:00
Jeffrey Czyz
90c976394c
Add logging in route hint filtering
Knowing why a channel was not included as an invoice route hint can be
valuable. Add logging on the decisions made when filtering channels.
2022-10-20 15:18:08 -05:00
Jeffrey Czyz
d6321e6e11
Merge pull request #1748 from valentinewallace/2022-10-custom-oms
Support custom onion messages
2022-10-19 17:15:33 -05:00
Valentine Wallace
4905268b65
Disallow sending invalid custom OM TLVs
Onion message data TLV types must be >= 64, enforce this on send
2022-10-19 16:07:01 -04:00
Valentine Wallace
7664957bc9
Implement sending and receiving custom onion messages
This uses the work done in the preceding commits to implement encoding a user's
custom TLV in outbound onion messages, and decoding custom TLVs in inbound
onion messages, to be provided to the new CustomOnionMessageHandler.
2022-10-19 16:06:58 -04:00
Matt Corallo
89747dc085
Merge pull request #1678 from TheBlueMatt/2022-08-funding-locked-mon-persist-fail
Handle async initial ChannelMonitor persistence failing on restart
2022-10-19 16:55:01 +00:00