rust-lightning
18 months agoAdd a pending changelog entry for the past few commits 2022-10-user-idempotency-token
Matt Corallo [Sat, 8 Oct 2022 21:25:44 +0000 (21:25 +0000)]
Add a pending changelog entry for the past few commits

18 months agoAllow users to specify the `PaymentId` used in `InvoicePayer`
Matt Corallo [Wed, 2 Nov 2022 01:06:39 +0000 (01:06 +0000)]
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.

18 months agoTest that PaymentIds are idempotency keys until `abandon_payment`
Matt Corallo [Sun, 30 Oct 2022 00:20:52 +0000 (00:20 +0000)]
Test that PaymentIds are idempotency keys until `abandon_payment`

18 months agoStop timing out payments automatically, requiring abandon_payment
Matt Corallo [Sat, 8 Oct 2022 19:54:43 +0000 (19:54 +0000)]
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.

18 months agoDelay removal of fulfilled outbound payments for a few timer ticks
Matt Corallo [Sat, 8 Oct 2022 23:26:18 +0000 (23:26 +0000)]
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.

18 months agoAllow users to specify the `PaymentId` for new outbound payments
Matt Corallo [Thu, 6 Oct 2022 21:31:02 +0000 (21:31 +0000)]
Allow users to specify the `PaymentId` for new outbound payments

In c986e52ce83e9aeaa9447abebc5f6600470337cf, 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 28eea12bbe0d78d256f79ec725cf02366dce4e36 `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.

18 months agoMerge pull request #1791 from valentinewallace/2022-10-we-are-intro-node
Matt Corallo [Tue, 1 Nov 2022 21:12:30 +0000 (21:12 +0000)]
Merge pull request #1791 from valentinewallace/2022-10-we-are-intro-node

Onion messages: fix edge case where we are the intro node

18 months agoPrune channels if *either* not updated
Gleb Naumenko [Thu, 27 Oct 2022 09:30:44 +0000 (12:30 +0300)]
Prune channels if *either* not updated

18 months agoNon-mandatory "fix" enabling future tests
Gleb Naumenko [Tue, 1 Nov 2022 08:10:49 +0000 (10:10 +0200)]
Non-mandatory "fix" enabling future tests

18 months agoMerge pull request #1815 from TheBlueMatt/2022-10-dead-gossip-code
valentinewallace [Tue, 1 Nov 2022 00:02:52 +0000 (20:02 -0400)]
Merge pull request #1815 from TheBlueMatt/2022-10-dead-gossip-code

Require directional updates for a DirectionalChannelInfo

18 months agoMerge pull request #1818 from TheBlueMatt/2022-10-stable-bench
Matt Corallo [Mon, 31 Oct 2022 21:28:53 +0000 (21:28 +0000)]
Merge pull request #1818 from TheBlueMatt/2022-10-stable-bench

Use rustc stable for benchmark CI run to fix current breakage

18 months agoUse rustc stable for benchmark CI run to fix current breakage 2022-10-stable-bench
Matt Corallo [Mon, 31 Oct 2022 18:46:31 +0000 (18:46 +0000)]
Use rustc stable for benchmark CI run to fix current breakage

18 months agoOMs: fix panic sending to a two-hop blinded route where we are the intro node
Valentine Wallace [Mon, 31 Oct 2022 16:40:06 +0000 (12:40 -0400)]
OMs: fix panic sending to a two-hop blinded route where we are the intro node

18 months agoOnion messages: fix edge case where we are the introduction node
Valentine Wallace [Fri, 21 Oct 2022 19:09:03 +0000 (15:09 -0400)]
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.

18 months agoMake `htlc_maximum_msat` in `EffectiveCapacity` non-`Option`al 2022-10-dead-gossip-code
Matt Corallo [Sat, 29 Oct 2022 18:30:37 +0000 (18:30 +0000)]
Make `htlc_maximum_msat` in `EffectiveCapacity` non-`Option`al

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.

18 months agoRequire directional updates for a `DirectionalChannelInfo`
Matt Corallo [Sat, 29 Oct 2022 18:24:36 +0000 (18:24 +0000)]
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`.

18 months agoRemove unused payment_hash param from Router::find_route
Valentine Wallace [Tue, 25 Oct 2022 00:17:03 +0000 (20:17 -0400)]
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

18 months agoFix inaccurate comment in InvoicePayer
Valentine Wallace [Thu, 27 Oct 2022 20:58:30 +0000 (16:58 -0400)]
Fix inaccurate comment in InvoicePayer

18 months agoMerge pull request #1809 from valentinewallace/2022-10-custom-om-self
Matt Corallo [Thu, 27 Oct 2022 21:34:45 +0000 (21:34 +0000)]
Merge pull request #1809 from valentinewallace/2022-10-custom-om-self

Give us a self when reading a custom onion message

18 months agoGive us a self when reading a custom onion message
Matt Corallo [Wed, 26 Oct 2022 19:23:10 +0000 (19:23 +0000)]
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>
18 months agoMerge pull request #1805 from TheBlueMatt/2022-10-remote-useless-mut
Matt Corallo [Thu, 27 Oct 2022 16:11:28 +0000 (16:11 +0000)]
Merge pull request #1805 from TheBlueMatt/2022-10-remote-useless-mut

Drop useless `mut` in `KeysInterface::sign_holder_anchor_input`

18 months agoMerge pull request #1807 from TheBlueMatt/2022-10-errorkind-bindings
Matt Corallo [Thu, 27 Oct 2022 16:11:14 +0000 (16:11 +0000)]
Merge pull request #1807 from TheBlueMatt/2022-10-errorkind-bindings

Export io::ErrorKind in bindings

18 months agoExport io::ErrorKind in bindings 2022-10-errorkind-bindings
Matt Corallo [Wed, 26 Oct 2022 21:55:23 +0000 (21:55 +0000)]
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.

18 months agoDrop useless `mut` in `KeysInterface::sign_holder_anchor_input` 2022-10-remote-useless-mut
Matt Corallo [Wed, 26 Oct 2022 20:46:34 +0000 (20:46 +0000)]
Drop useless `mut` in `KeysInterface::sign_holder_anchor_input`

The `Transaction` is not modified so there's no reason to make the
reference `mut`

18 months agoMerge pull request #1797 from arik-so/2022-10-channel-manager-deparameterization
valentinewallace [Wed, 26 Oct 2022 17:32:09 +0000 (13:32 -0400)]
Merge pull request #1797 from arik-so/2022-10-channel-manager-deparameterization

Deparametrize `ChannelManager` to infer `Signer` from its `KeysInterface`.

18 months agoMerge pull request #1802 from TheBlueMatt/2022-10-112 v0.0.112
Matt Corallo [Tue, 25 Oct 2022 21:33:34 +0000 (21:33 +0000)]
Merge pull request #1802 from TheBlueMatt/2022-10-112

Add release date and release name to CHANGELOG for 0.0.112

18 months agoRefer to `lnd` as `LND` in CHANGELOG 2022-10-112
Matt Corallo [Tue, 25 Oct 2022 18:59:41 +0000 (18:59 +0000)]
Refer to `lnd` as `LND` in CHANGELOG

for consistency since its an abbreviation for "lightning network
daemon".

18 months agoAdd release date and release name to CHANGELOG for 0.0.112
Matt Corallo [Tue, 25 Oct 2022 18:58:54 +0000 (18:58 +0000)]
Add release date and release name to CHANGELOG for 0.0.112

18 months agoMerge pull request #1798 from TheBlueMatt/2022-10-112
Matt Corallo [Tue, 25 Oct 2022 18:57:01 +0000 (18:57 +0000)]
Merge pull request #1798 from TheBlueMatt/2022-10-112

Cut 0.0.112

18 months agoDeparametrize `ChannelManager` to infer `Signer` from its `KeysInterface`.
Arik Sosman [Mon, 24 Oct 2022 19:11:12 +0000 (12:11 -0700)]
Deparametrize `ChannelManager` to infer `Signer` from its `KeysInterface`.

18 months agoOnly create BOLT4 tlv payload format onions
Viktor Tigerström [Tue, 5 Apr 2022 22:49:08 +0000 (00:49 +0200)]
Only create BOLT4 tlv payload format onions

18 months agoAdd release notes for 0.0.112
Matt Corallo [Mon, 24 Oct 2022 18:50:47 +0000 (18:50 +0000)]
Add release notes for 0.0.112

18 months agoRemove outdated allow(unused)
Valentine Wallace [Fri, 21 Oct 2022 19:08:04 +0000 (15:08 -0400)]
Remove outdated allow(unused)

18 months agoBump crate versions to 0.0.112/invoice 0.20
Matt Corallo [Mon, 24 Oct 2022 17:13:56 +0000 (17:13 +0000)]
Bump crate versions to 0.0.112/invoice 0.20

18 months agoDo not export new anchors structs in `events.rs` without anchors
Matt Corallo [Mon, 24 Oct 2022 18:12:30 +0000 (18:12 +0000)]
Do not export new anchors structs in `events.rs` without anchors

This avoids adding unused, effectively-dummy public structs in
`events.rs`.

18 months agoMerge pull request #1779 from valentinewallace/2022-10-node-pk-keysinterface
Matt Corallo [Mon, 24 Oct 2022 17:37:25 +0000 (17:37 +0000)]
Merge pull request #1779 from valentinewallace/2022-10-node-pk-keysinterface

Add `KeysInterface::get_node_id` method

18 months agoKeysInterface docs: note that Recipient type must be supported by impl
Valentine Wallace [Sat, 22 Oct 2022 00:30:49 +0000 (20:30 -0400)]
KeysInterface docs: note that Recipient type must be supported by impl

18 months agoMerge pull request #1780 from wpaulino/rust-edition-2018
Matt Corallo [Sat, 22 Oct 2022 01:05:26 +0000 (01:05 +0000)]
Merge pull request #1780 from wpaulino/rust-edition-2018

18 months agoBump workspace to rust edition 2018
Wilmer Paulino [Thu, 13 Oct 2022 06:35:48 +0000 (02:35 -0400)]
Bump workspace to rust edition 2018

Mostly motivated by the need of async/await.

18 months agoAdd KeysInterface::get_node_id method
Valentine Wallace [Tue, 18 Oct 2022 19:28:18 +0000 (15:28 -0400)]
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

18 months agoMerge pull request #1770 from jkczyz/2022-10-debug-route-hints
valentinewallace [Fri, 21 Oct 2022 17:04:45 +0000 (13:04 -0400)]
Merge pull request #1770 from jkczyz/2022-10-debug-route-hints

Add logging in route hint filtering

18 months agoMerge pull request #1788 from TheBlueMatt/2022-10-mtlc-writer
valentinewallace [Fri, 21 Oct 2022 15:28:15 +0000 (11:28 -0400)]
Merge pull request #1788 from TheBlueMatt/2022-10-mtlc-writer

Add `WriteableScore` bindings impl for `MultiThreadedLockableScore`

18 months agoAdd `WriteableScore` bindings impl for `MultiThreadedLockableScore` 2022-10-mtlc-writer
Matt Corallo [Thu, 29 Sep 2022 15:22:47 +0000 (15:22 +0000)]
Add `WriteableScore` bindings impl for `MultiThreadedLockableScore`

In 56b07e52aabdaca521987e765f1fa864966a5d49 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.

18 months agoAdd logging in route hint filtering
Jeffrey Czyz [Fri, 14 Oct 2022 14:31:36 +0000 (10:31 -0400)]
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.

18 months agoMerge pull request #1748 from valentinewallace/2022-10-custom-oms
Jeffrey Czyz [Wed, 19 Oct 2022 22:15:33 +0000 (17:15 -0500)]
Merge pull request #1748 from valentinewallace/2022-10-custom-oms

Support custom onion messages

18 months agoDisallow sending invalid custom OM TLVs
Valentine Wallace [Tue, 18 Oct 2022 17:33:45 +0000 (13:33 -0400)]
Disallow sending invalid custom OM TLVs

Onion message data TLV types must be >= 64, enforce this on send

18 months agoImplement sending and receiving custom onion messages
Valentine Wallace [Tue, 18 Oct 2022 17:29:43 +0000 (13:29 -0400)]
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.

18 months agoMerge pull request #1678 from TheBlueMatt/2022-08-funding-locked-mon-persist-fail
Matt Corallo [Wed, 19 Oct 2022 16:55:01 +0000 (16:55 +0000)]
Merge pull request #1678 from TheBlueMatt/2022-08-funding-locked-mon-persist-fail

Handle async initial ChannelMonitor persistence failing on restart

18 months agoRename `ChannelState::MonitorUpdateFailed` `MonitorUpdateInProgress` 2022-08-funding-locked-mon-persist-fail
Matt Corallo [Wed, 5 Oct 2022 00:34:38 +0000 (00:34 +0000)]
Rename `ChannelState::MonitorUpdateFailed` `MonitorUpdateInProgress`

As we're moving towards monitor update async being a supported
use-case, we shouldn't call an async monitor update "failed", but
rather "in progress". This simply updates the internal channel.rs
enum name to reflect the new thinking.

18 months agoHandle async initial ChannelMonitor persistence failing on restart
Matt Corallo [Sat, 20 Aug 2022 01:03:27 +0000 (01:03 +0000)]
Handle async initial ChannelMonitor persistence failing on restart

If the initial ChannelMonitor persistence is done asynchronously
but does not complete before the node restarts (with a
ChannelManager persistence), we'll start back up with a channel
present but no corresponding ChannelMonitor.

Because the Channel is pending-monitor-update and has not yet
broadcasted its initial funding transaction or sent channel_ready,
this is not a violation of our API contract nor a safety violation.
However, the previous code would refuse to deserialize the
ChannelManager treating it as an API contract violation.

The solution is to test for this case explicitly and drop the
channel entirely as if the peer disconnected before we received
the funding_signed for outbound channels or before sending the
channel_ready for inbound channels.

18 months agoMerge pull request #1769 from TheBlueMatt/2022-10-disconnected-hints
valentinewallace [Wed, 19 Oct 2022 14:22:07 +0000 (10:22 -0400)]
Merge pull request #1769 from TheBlueMatt/2022-10-disconnected-hints

Include all channel route hints if no connected channels exist

18 months agoMerge pull request #1764 from G8XSU/rgs-ignore-error
Jeffrey Czyz [Wed, 19 Oct 2022 13:50:09 +0000 (08:50 -0500)]
Merge pull request #1764 from G8XSU/rgs-ignore-error

Ignore Duplicate Gossip Error while updating networkGraph from RGS

18 months agoMerge pull request #1777 from lexe-tech/max/best-block-header-best-block
Jeffrey Czyz [Wed, 19 Oct 2022 13:46:07 +0000 (08:46 -0500)]
Merge pull request #1777 from lexe-tech/max/best-block-header-best-block

Add `.to_best_block()` method to `ValidatedBlockHeader`

19 months agoMerge pull request #1689 from wpaulino/anchors-bump-channel-close-event
Matt Corallo [Wed, 19 Oct 2022 00:29:57 +0000 (00:29 +0000)]
Merge pull request #1689 from wpaulino/anchors-bump-channel-close-event

19 months agoClean up private channel route hint filtering
Jeffrey Czyz [Thu, 13 Oct 2022 20:49:58 +0000 (16:49 -0400)]
Clean up private channel route hint filtering

19 months agoAdd `ValidatedBlockHeader::to_best_block`
Max Fang [Tue, 18 Oct 2022 01:38:26 +0000 (18:38 -0700)]
Add `ValidatedBlockHeader::to_best_block`

19 months agoInclude all channel route hints if no connected channels exist 2022-10-disconnected-hints
Matt Corallo [Thu, 13 Oct 2022 21:57:09 +0000 (21:57 +0000)]
Include all channel route hints if no connected channels exist

Mobile clients often take a second or two before they reconnect to
their peers as its not always clear immediately that connections
have been killed (especially on iOS). This can cause us to
spuriously fail to include route hints in our invoices if we're on
mobile.

The fix is simple, if we're selecting channels to include in route
hints and we're not not connected to the peer for any of our
channels, we should simply include the hints for all channels, even
though we're disconencted.

Fixes #1768.

19 months agoAdd public helper to build anchor input witnesses
Wilmer Paulino [Tue, 11 Oct 2022 18:46:24 +0000 (14:46 -0400)]
Add public helper to build anchor input witnesses

19 months agoAdd holder anchor signing support to BaseSign
Wilmer Paulino [Wed, 13 Jul 2022 17:39:40 +0000 (10:39 -0700)]
Add holder anchor signing support to BaseSign

19 months agoDocument expected call frequency of ChainMonitor::process_pending_events
Wilmer Paulino [Tue, 11 Oct 2022 18:39:32 +0000 (14:39 -0400)]
Document expected call frequency of ChainMonitor::process_pending_events

19 months agoYield channel close bump events
Wilmer Paulino [Wed, 31 Aug 2022 18:39:47 +0000 (11:39 -0700)]
Yield channel close bump events

19 months agoGenerate ClaimEvent for HolderFundingOutput inputs from anchor channels
Wilmer Paulino [Wed, 31 Aug 2022 18:35:55 +0000 (11:35 -0700)]
Generate ClaimEvent for HolderFundingOutput inputs from anchor channels

19 months agoRefactor generate_claim_tx to return OnchainClaim enum
Wilmer Paulino [Wed, 27 Jul 2022 22:15:34 +0000 (15:15 -0700)]
Refactor generate_claim_tx to return OnchainClaim enum

19 months agoSplit finalize_package into separate methods per malleability
Wilmer Paulino [Wed, 31 Aug 2022 18:07:45 +0000 (11:07 -0700)]
Split finalize_package into separate methods per malleability

19 months agoTrack funding amount in HolderFundingOutput
Wilmer Paulino [Wed, 27 Jul 2022 21:58:43 +0000 (14:58 -0700)]
Track funding amount in HolderFundingOutput

This will be useful later on when determining the appropriate fee rate
to use on the anchor transaction to bump its commitment transaction.

19 months agoTrack whether HolderFundingOutput originated from an anchor channel
Wilmer Paulino [Wed, 14 Sep 2022 23:18:33 +0000 (16:18 -0700)]
Track whether HolderFundingOutput originated from an anchor channel

19 months agoStore anchors option for supported output types
Wilmer Paulino [Wed, 14 Sep 2022 19:35:26 +0000 (12:35 -0700)]
Store anchors option for supported output types

As we integrate the support of anchor outputs, we'll want to know if
each input we're working with came from an anchor outputs channel.
Instead of threading through a `opt_anchors` boolean across several
methods on `PackageSolvingData` and `PackageTemplate`, we decide to
store a reference in each `PackageSolvingData` variant instead that
features a change in behavior between channels with and without anchor
outputs.

19 months agoDedupe gossip msgs while updating networkGraph from RGS
Gursharan Singh [Tue, 11 Oct 2022 19:20:33 +0000 (15:20 -0400)]
Dedupe gossip msgs while updating networkGraph from RGS

While applying gossip info from RGS-server, number of harmless
errors might arise which should be ignored. E.g. client should not
fail if there is a duplicate gossip for same channel or duplicate
update.

19 months agoUpdate send_onion_message API to take new OnionMessageContents enum
Valentine Wallace [Tue, 18 Oct 2022 17:22:12 +0000 (13:22 -0400)]
Update send_onion_message API to take new OnionMessageContents enum

OnionMessageContents specifies the data TLV that the sender wants in the onion
message. This enum only has one variant for now, Custom. When offers are added,
additional variants for invoice, invoice_request, and invoice_error will be
added.

This commit does not actually implement sending the custom OM contents, just
the API change.

19 months agoFix accidental newline in OnionMessenger docs
Valentine Wallace [Tue, 18 Oct 2022 17:14:35 +0000 (13:14 -0400)]
Fix accidental newline in OnionMessenger docs

19 months agoTweak OnionMessenger log on inbound onion message receipt
Valentine Wallace [Tue, 18 Oct 2022 16:14:15 +0000 (12:14 -0400)]
Tweak OnionMessenger log on inbound onion message receipt

19 months agoParameterize OnionMessenger by new CustomOnionMessageHandler trait
Valentine Wallace [Mon, 17 Oct 2022 20:32:17 +0000 (16:32 -0400)]
Parameterize OnionMessenger by new CustomOnionMessageHandler trait

OnionMessenger::new will now take a custom onion message handler trait
implementation. This handler will be used in upcoming commit(s) to handle
inbound custom onion messages.

The new trait also specifies what custom messages are supported via its
associated type, CustomMessage. This associated type must implement a new
CustomOnionMessagesContents trait, which requires custom messages to support
being written, being read, and supplying their TLV type.

19 months agoOptionally parameterize decode_tlv_stream with custom decode closure
Valentine Wallace [Mon, 17 Oct 2022 20:07:40 +0000 (16:07 -0400)]
Optionally parameterize decode_tlv_stream with custom decode closure

Useful for decoding custom or user-provided TLVs. See macro docs for more info.

Used in upcoming commit(s) to support custom onion message TLVs

19 months agoser: Add MaybeReadableArgs trait
Valentine Wallace [Mon, 17 Oct 2022 20:05:32 +0000 (16:05 -0400)]
ser: Add MaybeReadableArgs trait

Useful in decoding a custom message, so (a) the message type can be provided to
the handler and (b) None can be returned if the message type is unknown.

Used in upcoming commit(s) to support custom onion messages.

19 months agoMerge pull request #1763 from gcomte/feature/derive-eq
Matt Corallo [Mon, 17 Oct 2022 16:03:23 +0000 (16:03 +0000)]
Merge pull request #1763 from gcomte/feature/derive-eq

Derive Eq for all structs that derive PartialEq

19 months agoMerge pull request #1774 from futurepaul/disable-rustfmt
Matt Corallo [Mon, 17 Oct 2022 14:51:22 +0000 (14:51 +0000)]
Merge pull request #1774 from futurepaul/disable-rustfmt

disable automatic formatting

19 months agodisable all formatting
Paul Miller [Sat, 15 Oct 2022 21:46:06 +0000 (17:46 -0400)]
disable all formatting

19 months agoDerive Eq for all structs that derive PartialEq
Gabriel Comte [Fri, 14 Oct 2022 11:24:02 +0000 (13:24 +0200)]
Derive Eq for all structs that derive PartialEq

19 months agoMerge pull request #1765 from gcomte/refactor/remove-redundant-field-names
valentinewallace [Wed, 12 Oct 2022 14:46:36 +0000 (10:46 -0400)]
Merge pull request #1765 from gcomte/refactor/remove-redundant-field-names

Remove redundant field names

19 months agoRemove redundant field names
Gabriel Comte [Tue, 11 Oct 2022 22:14:01 +0000 (00:14 +0200)]
Remove redundant field names

19 months agoMerge pull request #1754 from TheBlueMatt/2022-10-better-liq-halflife-docs
Matt Corallo [Tue, 11 Oct 2022 21:54:48 +0000 (21:54 +0000)]
Merge pull request #1754 from TheBlueMatt/2022-10-better-liq-halflife-docs

Rewrite some documentation on `ProbabilisticScorer` and increase half-life to 6 hours.

19 months agoIncrease the default `liquidity_offset_half_life` to six hours 2022-10-better-liq-halflife-docs
Matt Corallo [Wed, 5 Oct 2022 19:23:56 +0000 (19:23 +0000)]
Increase the default `liquidity_offset_half_life` to six hours

Even at relatively high payment volumes, decaying knowledge of each
individual channel every hour causes aggressive retrying of
channels as we quickly forget the state of a channel. Even with the
historical tracker, this isn't fully remedied, as we'll track the
history bounds with the decayed value.

Instead, we decay every six hours here, reducing how often we'll
retry a channel due to decay.

In addition to this, the decay likely needs to be substantially
more linear, as tracked in #1752.

19 months agoRewrite documentation some on `ProbabilisticScorer`
Matt Corallo [Wed, 5 Oct 2022 19:10:06 +0000 (19:10 +0000)]
Rewrite documentation some on `ProbabilisticScorer`

We had some user confusion on how the probabilistic scorer works,
especially in reference to the half-life parameter. This attempts
to clarify how the bounds work, and how they are decayed.

19 months agoMerge pull request #1744 from tnull/2022-09-fix-bp-futures-doc
Matt Corallo [Mon, 10 Oct 2022 20:29:11 +0000 (20:29 +0000)]
Merge pull request #1744 from tnull/2022-09-fix-bp-futures-doc

Fix `background-processor` doc build for `futures`

19 months agoAdd `futures` CI check
Elias Rohrer [Mon, 10 Oct 2022 18:47:18 +0000 (14:47 -0400)]
Add `futures` CI check

This adds testing of the `futures` feature to CI. In order to avoid
introducing a dependency on `std`, we switch to using the `futures-util`
crate directly enabling only a subset of features. To this end, we also
switch to using the `select_biased!` macro, which is equivalent to
`select!` except that it doesn't choose ready futures pseudo-randomly
at runtime.

19 months agoFix `background-processor` doc build for `futures`
Elias Rohrer [Mon, 26 Sep 2022 12:41:59 +0000 (14:41 +0200)]
Fix `background-processor` doc build for `futures`

19 months agoMerge pull request #1756 from TheBlueMatt/2022-10-rgs-no-std
valentinewallace [Fri, 7 Oct 2022 21:01:10 +0000 (17:01 -0400)]
Merge pull request #1756 from TheBlueMatt/2022-10-rgs-no-std

Fix `rapid-gossip-sync` `no-std` and properly test no-std in CI

19 months agoSpecify full import path in decode_tlv macro
Valentine Wallace [Fri, 7 Oct 2022 19:22:00 +0000 (15:22 -0400)]
Specify full import path in decode_tlv macro

Prevents unresolved import error

19 months agoMerge pull request #1649 from dunxen/2022-08-implementnodefailure
Matt Corallo [Fri, 7 Oct 2022 18:41:19 +0000 (18:41 +0000)]
Merge pull request #1649 from dunxen/2022-08-implementnodefailure

Implement permanent node failure handling

19 months agoMerge pull request #1693 from valentinewallace/2022-09-readme-updates
Jeffrey Czyz [Fri, 7 Oct 2022 17:44:52 +0000 (12:44 -0500)]
Merge pull request #1693 from valentinewallace/2022-09-readme-updates

Fix outdated README sections

19 months agoMerge pull request #1758 from TheBlueMatt/2022-10-fix-pre-notified-future
Matt Corallo [Fri, 7 Oct 2022 17:38:50 +0000 (17:38 +0000)]
Merge pull request #1758 from TheBlueMatt/2022-10-fix-pre-notified-future

Fix (and test) `Future` creation after a `Notifier` was notified

19 months agoTest a full `no-std` build in the `no-std-check` crate in CI 2022-10-rgs-no-std
Matt Corallo [Thu, 6 Oct 2022 15:44:03 +0000 (15:44 +0000)]
Test a full `no-std` build in the `no-std-check` crate in CI

Rust is incredibly forgiving in attempts to access `std`, making it
rather difficult to test `no-std` properly. In practice, the only
decent way to do so is to actually build for a platform that does
not have `std`, which we do here by building the `no-std-check`
crate for `arm-thumbv7m-none-eabi`.

19 months agoMerge pull request #1625 from TheBlueMatt/2022-07-history-tracking
Matt Corallo [Fri, 7 Oct 2022 16:32:10 +0000 (16:32 +0000)]
Merge pull request #1625 from TheBlueMatt/2022-07-history-tracking

19 months agoMerge pull request #1751 from TheBlueMatt/2022-10-fix-score-log-direction
valentinewallace [Fri, 7 Oct 2022 16:28:23 +0000 (12:28 -0400)]
Merge pull request #1751 from TheBlueMatt/2022-10-fix-score-log-direction

Correct the directionality of liquidity non-update messages

19 months agoMerge pull request #1760 from TheBlueMatt/2022-10-invoice-builder-round
Matt Corallo [Fri, 7 Oct 2022 16:25:25 +0000 (16:25 +0000)]
Merge pull request #1760 from TheBlueMatt/2022-10-invoice-builder-round

19 months agoFix outdated README sections
Valentine Wallace [Fri, 2 Sep 2022 21:55:53 +0000 (17:55 -0400)]
Fix outdated README sections

19 months agoRemove and track perm failed nodes & channels
Duncan Dean [Fri, 26 Aug 2022 10:54:16 +0000 (12:54 +0200)]
Remove and track perm failed nodes & channels

We never had the `NetworkGraph::node_failed` method implemented. The
scorer now handles non-permanent failures by downgrading nodes, so we
don't want that implemented.

The method is renamed to `node_failed_permanent` to explicitly indicate
that this is the only case it handles. We also add tracking in the form
of two maps as fields of `NetworkGraph`, namely, `removed_nodes` and
`removed_channels`. We track these removed graph entries to ensure we
don't just resync them right away from gossip soon after removing them.
We stop tracking these removed nodes whenever `remove_stale_channels_and_tracking()`
is called and the entries have been tracked for longer than
`REMOVED_ENTRIES_TRACKING_AGE_LIMIT_SECS` which is currently set to one
week.

19 months agoDrop the subsecond part of timestamps when constructing invoices 2022-10-invoice-builder-round
Matt Corallo [Fri, 7 Oct 2022 01:38:56 +0000 (01:38 +0000)]
Drop the subsecond part of timestamps when constructing invoices

We had a user who was confused why an invoice failed to round-trip
(i.e. was not `PartialEq` with itself after write/read) when a
subsecond creation time was used (e.g. via the `from_system_time`
constructor).

This commit should address this confusion by dropping subsecond
parts in easily-accessible constructors when creating BOLT 11
invoices.

Fixes #1759.

19 months agoSupport platforms with only 32-bit atomics
Matt Corallo [Thu, 6 Oct 2022 16:48:14 +0000 (16:48 +0000)]
Support platforms with only 32-bit atomics

Given there is only one instance in our code of `AtomicU64` its
simplest to just remove it rather than try to add some kind of
wrapper.

19 months agoTest `rapid-gossip-sync` in `no-std` in CI
Matt Corallo [Thu, 6 Oct 2022 15:41:58 +0000 (15:41 +0000)]
Test `rapid-gossip-sync` in `no-std` in CI