]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
2 years agoRestrict ChannelInfo::as_directed_from visibility
Jeffrey Czyz [Tue, 29 Mar 2022 15:20:39 +0000 (10:20 -0500)]
Restrict ChannelInfo::as_directed_from visibility

Bindings can't handle references in return types, so reduce the
visibility to pub(crate).

2 years agoSimplify type aliasing somewhat around times
Matt Corallo [Tue, 1 Mar 2022 03:47:28 +0000 (03:47 +0000)]
Simplify type aliasing somewhat around times

.. as the current C bindings generator isn't capable of handling
type aliases in generics in type alias definition currently.

2 years agoMake `as_directed_to` non-public
Matt Corallo [Tue, 1 Mar 2022 03:46:52 +0000 (03:46 +0000)]
Make `as_directed_to` non-public

...as the bindings generation does not currently have the ability
to map a reference to a `NodeId` inside a tuple.

2 years ago(Bindings Only) Concretize LockableScore as MultiThreadedLockableScore
Matt Corallo [Fri, 17 Dec 2021 22:32:24 +0000 (22:32 +0000)]
(Bindings Only) Concretize LockableScore as MultiThreadedLockableScore

We don't really care about more than this in bindings - calling
into a custom `Score` is likely too slow to be practical anyway,
so this is also a performance improvement.

Works around https://github.com/rust-lang/rust/issues/90448

2 years agoMerge pull request #1535 from TheBlueMatt/2022-06-108-ugh v0.0.108
Matt Corallo [Fri, 10 Jun 2022 16:44:11 +0000 (09:44 -0700)]
Merge pull request #1535 from TheBlueMatt/2022-06-108-ugh

Cut 0.0.108

2 years agoUpdate crate versions to 0.0.108/invoice 0.16 2022-06-108-ugh
Matt Corallo [Fri, 10 Jun 2022 10:41:51 +0000 (10:41 +0000)]
Update crate versions to 0.0.108/invoice 0.16

2 years agoUpdate CHANGELOG for 0.0.108
Matt Corallo [Fri, 10 Jun 2022 10:42:15 +0000 (10:42 +0000)]
Update CHANGELOG for 0.0.108

2 years agoMerge pull request #1534 from tnull/2022-06-check-release-build
Matt Corallo [Fri, 10 Jun 2022 14:51:41 +0000 (07:51 -0700)]
Merge pull request #1534 from tnull/2022-06-check-release-build

Check release build in CI

2 years agoCheck release build profile in CI
Elias Rohrer [Fri, 10 Jun 2022 08:45:57 +0000 (10:45 +0200)]
Check release build profile in CI

So far, CI did not check the code in the `release` build profile, which
could result in some things not getting caught. To fix this, we now
implement a new CI job that runs checks in the `release` profile.

Switch to stable toolchain.

2 years agoMerge pull request #1533 from lexe-tech/fix-release
Matt Corallo [Fri, 10 Jun 2022 10:34:09 +0000 (03:34 -0700)]
Merge pull request #1533 from lexe-tech/fix-release

Fix `lightning-background-processor` release build

2 years agoFix lightning-background-processor release build
Max Fang [Fri, 10 Jun 2022 05:58:26 +0000 (22:58 -0700)]
Fix lightning-background-processor release build

2 years agoMerge pull request #1496 from TheBlueMatt/2022-05-macro-function-bonus
Arik Sosman [Thu, 9 Jun 2022 16:10:27 +0000 (12:10 -0400)]
Merge pull request #1496 from TheBlueMatt/2022-05-macro-function-bonus

Make `expect_payment_failed_conditions` a function

2 years agoMake `expect_payment_failed_conditions` a function 2022-05-macro-function-bonus
Matt Corallo [Fri, 20 May 2022 02:56:59 +0000 (02:56 +0000)]
Make `expect_payment_failed_conditions` a function

This reduces macro generated code in tests a good bit, and moves us
one step further away from using macros everywhere when we don't
need to.

2 years agoMerge pull request #1513 from TheBlueMatt/2022-06-fix-fuzz-nonbug
valentinewallace [Thu, 9 Jun 2022 01:32:22 +0000 (18:32 -0700)]
Merge pull request #1513 from TheBlueMatt/2022-06-fix-fuzz-nonbug

Do not panic on early tx broadcasts in fuzzing

2 years agoMerge pull request #1524 from ViktorTigerstrom/2022-06-update-fail-holding-cell-htlcs...
Matt Corallo [Thu, 9 Jun 2022 00:12:20 +0000 (17:12 -0700)]
Merge pull request #1524 from ViktorTigerstrom/2022-06-update-fail-holding-cell-htlcs-args

Pass `counterparty_node_id` to `fail_holding_cell_htlcs`

2 years agoMerge pull request #1525 from jkczyz/2022-05-release-0.0.107 v0.0.107
Matt Corallo [Wed, 8 Jun 2022 23:44:03 +0000 (16:44 -0700)]
Merge pull request #1525 from jkczyz/2022-05-release-0.0.107

Cut 0.0.107

2 years agoBump crate versions to 0.0.107/invoice 0.15
Jeffrey Czyz [Mon, 6 Jun 2022 18:49:29 +0000 (13:49 -0500)]
Bump crate versions to 0.0.107/invoice 0.15

2 years agoUpdate CHANGELOG for 0.0.107
Jeffrey Czyz [Mon, 30 May 2022 18:30:49 +0000 (11:30 -0700)]
Update CHANGELOG for 0.0.107

2 years agoPass `peer_node_id` to `fail_holding_cell_htlcs`
Viktor Tigerström [Mon, 6 Jun 2022 18:38:28 +0000 (20:38 +0200)]
Pass `peer_node_id` to `fail_holding_cell_htlcs`

2 years agoAdd lightning-rapid-gossip-sync to README
Jeffrey Czyz [Wed, 8 Jun 2022 04:50:07 +0000 (23:50 -0500)]
Add lightning-rapid-gossip-sync to README

2 years agoMerge pull request #1517 from jkczyz/2022-06-gossip-sync-enum
Matt Corallo [Tue, 7 Jun 2022 10:17:29 +0000 (03:17 -0700)]
Merge pull request #1517 from jkczyz/2022-06-gossip-sync-enum

Support only one `GossipSync` in `BackgroundProcessor`

2 years agoSupport only one GossipSync in BackgroundProcessor
Jeffrey Czyz [Thu, 2 Jun 2022 21:48:32 +0000 (14:48 -0700)]
Support only one GossipSync in BackgroundProcessor

BackgroundProcessor can take an optional P2PGossipSync and an optional
RapidGossipSync, but doing so may be easy to misuse. Each has a
reference to a NetworkGraph, which could be different between the two,
but only one is actually used.

Instead, allow passing one object wrapped in a GossipSync enum. Also,
fix a bug where the NetworkGraph is not persisted on shutdown if only a
RapidGossipSync is given.

2 years agoImplement EventHandler for NetworkGraph
Jeffrey Czyz [Fri, 3 Jun 2022 05:59:14 +0000 (22:59 -0700)]
Implement EventHandler for NetworkGraph

Instead of implementing EventHandler for P2PGossipSync, implement it on
NetworkGraph. This allows RapidGossipSync to handle events, too, by
delegating to its NetworkGraph.

2 years agoParameterize NetworkGraph with Logger
Jeffrey Czyz [Sat, 4 Jun 2022 04:35:37 +0000 (21:35 -0700)]
Parameterize NetworkGraph with Logger

P2PGossipSync logs before delegating to NetworkGraph in its
EventHandler. In order to share this handling with RapidGossipSync,
NetworkGraph needs to take a logger so that it can implement
EventHandler instead.

2 years agoMerge pull request #1501 from tnull/2022-05-mention-compat-level
Matt Corallo [Sat, 4 Jun 2022 00:14:01 +0000 (17:14 -0700)]
Merge pull request #1501 from tnull/2022-05-mention-compat-level

Mention backwards compatibility in CONTRIBUTING.

2 years agoMove Secp256k1 context to NetworkGraph
Jeffrey Czyz [Fri, 3 Jun 2022 04:37:59 +0000 (21:37 -0700)]
Move Secp256k1 context to NetworkGraph

P2PGossipSync has a Secp256k1 context field, which it only uses to pass
to NetworkGraph methods. Move the field to NetworkGraph so other callers
don't need to pass in a Secp256k1 context.

2 years agoMerge pull request #1159 from jkczyz/2021-11-network-gossip
Matt Corallo [Thu, 2 Jun 2022 23:53:32 +0000 (16:53 -0700)]
Merge pull request #1159 from jkczyz/2021-11-network-gossip

Rename network-related types

2 years agoMove network_graph.rs to gossip.rs
Jeffrey Czyz [Thu, 2 Jun 2022 19:53:34 +0000 (12:53 -0700)]
Move network_graph.rs to gossip.rs

The routing::network_graph module contains a few structs related to p2p
gossip. So renaming the module to 'gossip' seems more appropriate.

2 years agoRename NetGraphMsgHandler to P2PGossipSync
Jeffrey Czyz [Wed, 1 Jun 2022 17:28:34 +0000 (10:28 -0700)]
Rename NetGraphMsgHandler to P2PGossipSync

NetGraphMsgHandler implements RoutingMessageHandler to handle gossip
messages defined in BOLT 7 and maintains a view of the network by
updating NetworkGraph. Rename it to P2PGossipSync, which better
describes its purpose, and to contrast with RapidGossipSync.

2 years agoRename ChannelClosed to ChannelFailure
Jeffrey Czyz [Fri, 5 Nov 2021 17:55:25 +0000 (12:55 -0500)]
Rename ChannelClosed to ChannelFailure

A NetworkUpdate indicating ChannelClosed actually corresponds to a
channel failure as described in BOLT 4:

0x2000 (NODE): node failure (otherwise channel)

Rename the enum variant to ChannelFailure and rename NetworkGraph
methods close_channel_from_update and fail_node to channel_failed and
node_failed, respectively.

2 years agoUpdate missed references to get_route in docs
Jeffrey Czyz [Thu, 4 Nov 2021 14:57:53 +0000 (09:57 -0500)]
Update missed references to get_route in docs

2 years agoFix build warnings
Jeffrey Czyz [Wed, 1 Jun 2022 21:50:40 +0000 (14:50 -0700)]
Fix build warnings

2 years agoMerge pull request #1505 from tnull/2022-05-support-0conf-channeltype
valentinewallace [Thu, 2 Jun 2022 20:02:25 +0000 (13:02 -0700)]
Merge pull request #1505 from tnull/2022-05-support-0conf-channeltype

Support `ZeroConf` channel type.

2 years agoMerge pull request #1433 from arik-so/2022-04-rapid-sync-bg-processor
Jeffrey Czyz [Thu, 2 Jun 2022 19:10:00 +0000 (14:10 -0500)]
Merge pull request #1433 from arik-so/2022-04-rapid-sync-bg-processor

Allow indication to BackgroundProcessor that graph sync is pending

2 years agoCreate separate timer for scorer persistence in background processor
Arik Sosman [Wed, 1 Jun 2022 23:25:30 +0000 (16:25 -0700)]
Create separate timer for scorer persistence in background processor

2 years agoIndicate ongoing rapid sync to background processor.
Arik Sosman [Wed, 1 Jun 2022 22:26:07 +0000 (15:26 -0700)]
Indicate ongoing rapid sync to background processor.

Create a wrapper struct for rapid gossip sync that can be passed to
BackgroundProcessor's start method, allowing it to only start pruning
the network graph upon rapid gossip sync's completion.

2 years agoDo not panic on early tx broadcasts in fuzzing 2022-06-fix-fuzz-nonbug
Matt Corallo [Thu, 2 Jun 2022 03:37:16 +0000 (03:37 +0000)]
Do not panic on early tx broadcasts in fuzzing

If the user broadcasts a funding transaction before the
counterparty provides a `funding_signed` we will panic in
`check_get_channel_ready`. This is expected - the user did
something which may lead to loss of funds, and we *really* need to
let them know.

However, the fuzzer can do this and we shouldn't treat it as a bug,
its a totally expected panic. Thus, we disable the panic in fuzz.

Thanks to Chaincode for providing fuzzing resources which managed
to hit this panic.

2 years agoImplement `ZeroConf` feature.
Elias Rohrer [Thu, 2 Jun 2022 00:05:17 +0000 (17:05 -0700)]
Implement `ZeroConf` feature.

2 years agoMerge pull request #1512 from tnull/2022-05-remove-deprecated-scorer
Jeffrey Czyz [Wed, 1 Jun 2022 23:29:15 +0000 (18:29 -0500)]
Merge pull request #1512 from tnull/2022-05-remove-deprecated-scorer

Remove previously deprecated `Scorer`

2 years agoMerge pull request #1509 from shamardy/main
Matt Corallo [Wed, 1 Jun 2022 22:54:46 +0000 (15:54 -0700)]
Merge pull request #1509 from shamardy/main

Update regex to 1.5.6

2 years agoRemove previously deprecated `Scorer`
Elias Rohrer [Fri, 27 May 2022 01:20:05 +0000 (18:20 -0700)]
Remove previously deprecated `Scorer`

2 years agoMerge pull request #1504 from TheBlueMatt/2022-05-pub-io
Jeffrey Czyz [Wed, 1 Jun 2022 20:57:18 +0000 (15:57 -0500)]
Merge pull request #1504 from TheBlueMatt/2022-05-pub-io

Re-export `core2::io` or `std::io` depending on feature flags

2 years agoMerge pull request #1511 from justinmoon/repository
Jeffrey Czyz [Wed, 1 Jun 2022 20:52:20 +0000 (15:52 -0500)]
Merge pull request #1511 from justinmoon/repository

Add 'repository' to lightning-invoice's Cargo.toml

2 years agoAdd 'repository' to lightning-invoice's Cargo.toml
Justin Moon [Wed, 1 Jun 2022 18:17:16 +0000 (13:17 -0500)]
Add 'repository' to lightning-invoice's Cargo.toml

2 years agoUpdate regex to 1.5.6
shamardy [Wed, 1 Jun 2022 15:25:15 +0000 (17:25 +0200)]
Update regex to 1.5.6

2 years agoMerge pull request #1500 from arik-so/2022-05-network-graph-rapid-sync-timestamp
Arik Sosman [Tue, 31 May 2022 18:57:18 +0000 (11:57 -0700)]
Merge pull request #1500 from arik-so/2022-05-network-graph-rapid-sync-timestamp

Add optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimized differential rapid syncing.

2 years agoMerge pull request #1506 from tnull/2022-05-rename-funding-locked
Matt Corallo [Tue, 31 May 2022 17:48:09 +0000 (10:48 -0700)]
Merge pull request #1506 from tnull/2022-05-rename-funding-locked

Rename `FundingLocked` to `ChannelReady`.

2 years agoAdd optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimiz...
Arik Sosman [Fri, 27 May 2022 00:58:57 +0000 (17:58 -0700)]
Add optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimized differental rapid syncing.

2 years agoRe-export `core2::io` or `std::io` depending on feature flags 2022-05-pub-io
Matt Corallo [Mon, 30 May 2022 17:50:02 +0000 (17:50 +0000)]
Re-export `core2::io` or `std::io` depending on feature flags

This is useful in bindings as the `lightning::io` module is used in
the public interface, but also useful for users who want to refer
to the `io` as used in lightning irrespective of the feature flags.

2 years agoRename `FundingLocked` to `ChannelReady`.
Elias Rohrer [Mon, 30 May 2022 21:39:04 +0000 (14:39 -0700)]
Rename `FundingLocked` to `ChannelReady`.

2 years agoMerge pull request #1434 from TheBlueMatt/2022-04-robust-payment-claims
valentinewallace [Mon, 30 May 2022 17:05:01 +0000 (10:05 -0700)]
Merge pull request #1434 from TheBlueMatt/2022-04-robust-payment-claims

Improve Robustness of Inbound MPP Claims Across Restart

2 years agoChange `Event` `amt` fields to `amount_msat` for clarity 2022-04-robust-payment-claims
Matt Corallo [Sat, 28 May 2022 00:27:14 +0000 (00:27 +0000)]
Change `Event` `amt` fields to `amount_msat` for clarity

2 years agoMention backwards compatibility in CONTRIBUTING.
Elias Rohrer [Fri, 27 May 2022 23:55:27 +0000 (16:55 -0700)]
Mention backwards compatibility in CONTRIBUTING.

2 years agoAdd internal docs for ChannelMonitor::payment_preimages
Matt Corallo [Fri, 22 Apr 2022 17:58:19 +0000 (17:58 +0000)]
Add internal docs for ChannelMonitor::payment_preimages

2 years agoDrop return value from `fail_htlc_backwards`, clarify docs
Matt Corallo [Tue, 19 Apr 2022 22:06:50 +0000 (22:06 +0000)]
Drop return value from `fail_htlc_backwards`, clarify docs

`ChannelManager::fail_htlc_backwards`' bool return value is quite
confusing - just because it returns false doesn't mean the payment
wasn't (already) failed. Worse, in some race cases around shutdown
where a payment was claimed before an unclean shutdown and then
retried on startup, `fail_htlc_backwards` could return true even
though (a duplicate copy of the same payment) was claimed, but the
claim event has not been seen by the user yet.

While its possible to use it correctly, its somewhat confusing to
have a return value at all, and definitely lends itself to misuse.

Instead, we should push users towards a model where they don't care
if `fail_htlc_backwards` succeeds - either they've locally marked
the payment as failed (prior to seeing any `PaymentReceived`
events) and will fail any attempts to pay it, or they have not and
the payment is still receivable until its timeout time is reached.

We can revisit this decision based on user feedback, but will need
to very carefully document the potential failure modes here if we
do.

2 years agoDo additional pre-flight checks before claiming a payment
Matt Corallo [Tue, 19 Apr 2022 21:46:44 +0000 (21:46 +0000)]
Do additional pre-flight checks before claiming a payment

As additional sanity checks, before claiming a payment, we check
that we have the full amount available in `claimable_htlcs` that
the payment should be for. Concretely, this prevents one
somewhat-absurd edge case where a user may receive an MPP payment,
wait many *blocks* before claiming it, allowing us to fail the
pending HTLCs and the sender to retry some subset of the payment
before we go to claim. More generally, this is just good
belt-and-suspenders against any edge cases we may have missed.

2 years agoProvide a redundant `Event::PaymentClaimed` on restart if needed
Matt Corallo [Wed, 4 May 2022 18:12:09 +0000 (18:12 +0000)]
Provide a redundant `Event::PaymentClaimed` on restart if needed

If we crashed during a payment claim and then detected a partial
claim on restart, we should ensure the user is aware that the
payment has been claimed. We do so here by using the new
partial-claim detection logic to create a `PaymentClaimed` event.

2 years agoAdd a `PaymentClaimed` event to indicate a payment was claimed
Matt Corallo [Mon, 18 Apr 2022 20:12:15 +0000 (20:12 +0000)]
Add a `PaymentClaimed` event to indicate a payment was claimed

This replaces the return value of `claim_funds` with an event. It
does not yet change behavior in any material way.

2 years agoMerge pull request #1401 from TheBlueMatt/2022-02-0conf-round-two
Matt Corallo [Fri, 27 May 2022 23:54:52 +0000 (16:54 -0700)]
Merge pull request #1401 from TheBlueMatt/2022-02-0conf-round-two

Zero Conf Channels

2 years agoAdd note about SCID collisions in `PaymentPathFailed` 2022-02-0conf-round-two
Matt Corallo [Wed, 4 May 2022 02:34:10 +0000 (02:34 +0000)]
Add note about SCID collisions in `PaymentPathFailed`

This isn't specific to 0-conf but is useful for users to note as
the network moves towards more SCID aliases.

2 years agoAdd test of 0conf channels getting the funding transaction reorg'd
Matt Corallo [Mon, 2 May 2022 15:23:52 +0000 (15:23 +0000)]
Add test of 0conf channels getting the funding transaction reorg'd

In a previous version of the 0-conf code we did not correctly
handle 0-conf channels getting the funding transaction reorg'd out
(and the real SCID possibly changing on us).

2 years agoCorrectly handle sending announcement sigs on public 0conf channels
Matt Corallo [Fri, 1 Apr 2022 21:29:59 +0000 (21:29 +0000)]
Correctly handle sending announcement sigs on public 0conf channels

2 years agoAdd a new test for 0conf-with-monitor-update-failures
Matt Corallo [Fri, 1 Apr 2022 01:34:38 +0000 (01:34 +0000)]
Add a new test for 0conf-with-monitor-update-failures

This tests a few cases of monitor failure updates that were broken
in earlier versions of the 0conf patchset.

2 years agoExpose outbound SCID alias in `ChannelDetails` and use in routing
Matt Corallo [Fri, 1 Apr 2022 01:36:38 +0000 (01:36 +0000)]
Expose outbound SCID alias in `ChannelDetails` and use in routing

This supports routing outbound over 0-conf channels by utilizing
the outbound SCID alias that we assign to all channels to refer to
the selected channel when routing.

2 years agoSend funding_locked immediately for inbound channels with 0conf
Matt Corallo [Thu, 10 Feb 2022 00:09:42 +0000 (00:09 +0000)]
Send funding_locked immediately for inbound channels with 0conf

2 years agoAdd API and signaling to accept incoming channels at 0conf
Matt Corallo [Wed, 2 Feb 2022 23:01:05 +0000 (23:01 +0000)]
Add API and signaling to accept incoming channels at 0conf

2 years agoLock outbound channels at 0conf if the peer indicates support for it
Matt Corallo [Tue, 1 Feb 2022 21:57:01 +0000 (21:57 +0000)]
Lock outbound channels at 0conf if the peer indicates support for it

If our peer sets a minimum depth of 0, and we're set to trusting
ourselves to not double-spend our own funding transactions, send a
funding_locked message immediately after funding signed.

Note that some special care has to be taken around the
`channel_state` values - `ChannelFunded` no longer implies the
funding transaction is confirmed on-chain. Thus, for example, the
should-we-re-broadcast logic has to now accept `channel_state`
values greater than `ChannelFunded` as indicating we may still need
to re-broadcast our funding tranasction, unless `minimum_depth` is
greater than 0.

Further note that this starts writing `Channel` objects with a
`MIN_SERIALIZATION_VERSION` of 2. Thus, LDK versions prior to
0.0.99 (July 2021) will now refuse to read serialized
Channels/ChannelManagers.

2 years agoDefine a crate-public constant for max fake SCID in blocks offset
Matt Corallo [Fri, 13 May 2022 18:30:12 +0000 (18:30 +0000)]
Define a crate-public constant for max fake SCID in blocks offset

2 years agoHandle cases where a channel is in use w/o an SCID in ChannelManager
Matt Corallo [Fri, 4 Mar 2022 21:24:39 +0000 (21:24 +0000)]
Handle cases where a channel is in use w/o an SCID in ChannelManager

In the next few commits we add support for 0conf channels, allowing
us to have an active channel with HTLC and other updates flying
prior to having an SCID available. This would break several
assumptions made in `ChannelManager`, which we address here by
looking at SCID aliases in addition to SCIDs.

2 years agoMerge pull request #1481 from TheBlueMatt/2022-05-new-chain-tests
valentinewallace [Fri, 27 May 2022 17:38:42 +0000 (10:38 -0700)]
Merge pull request #1481 from TheBlueMatt/2022-05-new-chain-tests

Test coverage for `transaction_unconfirmed`

2 years agoMerge pull request #1499 from tnull/2022-05-fix-unreachable-warning
Matt Corallo [Fri, 27 May 2022 04:51:46 +0000 (21:51 -0700)]
Merge pull request #1499 from tnull/2022-05-fix-unreachable-warning

Fix `rapid-gossip-sync` warning and version number

2 years agoMerge pull request #1491 from tnull/2022-05-build-route-from-pubkeys
Matt Corallo [Fri, 27 May 2022 02:05:52 +0000 (19:05 -0700)]
Merge pull request #1491 from tnull/2022-05-build-route-from-pubkeys

Build route from hop pubkey list.

2 years agoFix `rapid-gossip-sync` warning and version number
Elias Rohrer [Fri, 27 May 2022 00:48:29 +0000 (17:48 -0700)]
Fix `rapid-gossip-sync` warning and version number

2 years agoAllow building of a route from given hops
Elias Rohrer [Wed, 25 May 2022 23:44:22 +0000 (16:44 -0700)]
Allow building of a route from given hops

Implements `build_route_from_hops`, which provides a simple way to build
a route from us (payer) to the target node (payee) via the given hops
(which should exclude the payer, but include the payee). This may be
useful, e.g., for probing the chosen path.

2 years agoMerge pull request #1494 from TheBlueMatt/2022-05-mon-cleanups-renames
Matt Corallo [Thu, 26 May 2022 18:11:08 +0000 (11:11 -0700)]
Merge pull request #1494 from TheBlueMatt/2022-05-mon-cleanups-renames

Correct variable names in `ChannelMonitor` and DRY tests

2 years agoEnsure all HTLCs for a claimed payment are claimed on startup
Matt Corallo [Mon, 18 Apr 2022 15:42:11 +0000 (15:42 +0000)]
Ensure all HTLCs for a claimed payment are claimed on startup

While the HTLC-claim process happens across all MPP parts under one
lock, this doesn't imply that they are claimed fully atomically on
disk. Ultimately, an application can crash after persisting one
`ChannelMonitorUpdate` out of multiple monitor updates needed for
the full claim.

Previously, this would leave us in a very bad state - because of
the all-channels-available check in `claim_funds` we'd refuse to
claim the payment again on restart (even though the
`PaymentReceived` event will be passed to the user again), and we'd
end up having partially claimed the payment!

The fix for the consistency part of this issue is pretty
straightforward - just check for this condition on startup and
complete the claim across all channels/`ChannelMonitor`s if we
detect it.

This still leaves us in a confused state from the perspective of
the user, however - we've actually claimed a payment but when they
call `claim_funds` we return `false` indicating it could not be
claimed.

2 years agoCorrect bogus references to `revocation_point` in `ChannelMonitor` 2022-05-mon-cleanups-renames
Matt Corallo [Tue, 24 May 2022 22:02:15 +0000 (22:02 +0000)]
Correct bogus references to `revocation_point` in `ChannelMonitor`

The `ChannelMonitor` had a field for the counterparty's
`cur_revocation_points`. Somewhat confusingly, this actually stored
the counterparty's *per-commitment* points, not the (derived)
revocation points.

Here we correct this by simply renaming the references as
appropriate. Note the update in `channel.rs` makes the variable
names align correctly.

2 years agoRename HTLC `onchain_value_satoshis` to `htlc_value_satoshis`
Matt Corallo [Thu, 19 May 2022 00:56:16 +0000 (00:56 +0000)]
Rename HTLC `onchain_value_satoshis` to `htlc_value_satoshis`

In `HTLCUpdate` and `OnchainEvent` tracking, we store the HTLC
value (rounded down to whole satoshis). This is somewhat
confusingly referred to as the `onchain_value_satoshis` even though
it refers to the commitment transaction output value, not the value
available on chain (which may have been reduced by an
HTLC-Timeout/HTLC-Success transaction).

2 years agoDRY SpendableOutput tests in `monitor_tests.rs`
Matt Corallo [Fri, 20 May 2022 01:42:06 +0000 (01:42 +0000)]
DRY SpendableOutput tests in `monitor_tests.rs`

2 years agoMerge pull request #1155 from arik-so/graph_sync_crate
Jeffrey Czyz [Wed, 25 May 2022 21:40:00 +0000 (16:40 -0500)]
Merge pull request #1155 from arik-so/graph_sync_crate

Introduce graph sync crate

2 years agoMerge pull request #1478 from mattfaltyn/issue1462
Jeffrey Czyz [Wed, 25 May 2022 21:26:51 +0000 (16:26 -0500)]
Merge pull request #1478 from mattfaltyn/issue1462

Document `lightning` crate features

2 years agoIntroduce graph sync crate for fast-forwarding through gossip data downloaded from...
Arik Sosman [Wed, 3 Nov 2021 17:50:08 +0000 (10:50 -0700)]
Introduce graph sync crate for fast-forwarding through gossip data downloaded from a server.

2 years agoDocument lightning crate features
Mateusz Faltyn [Tue, 24 May 2022 23:21:29 +0000 (16:21 -0700)]
Document lightning crate features

2 years agoRename HTLC `input_idx` fields to `commitment_tx_output_idx`
Matt Corallo [Sun, 24 Apr 2022 20:30:50 +0000 (20:30 +0000)]
Rename HTLC `input_idx` fields to `commitment_tx_output_idx`

Several fields used in tracking on-chain HTLC outputs were
named `input_idx` despite referring to the output index in the
commitment transaction. Here they are all renamed
`commitment_tx_output_idx` for clarity.

2 years agoMerge pull request #1490 from arik-so/rust_beta_doc_fix
Jeffrey Czyz [Mon, 23 May 2022 05:16:04 +0000 (00:16 -0500)]
Merge pull request #1490 from arik-so/rust_beta_doc_fix

Fix rust beta docs for lightning-invoice crate.

2 years agoMerge pull request #1492 from tnull/2022-05-fix-bolts-url
Arik Sosman [Fri, 20 May 2022 18:20:55 +0000 (11:20 -0700)]
Merge pull request #1492 from tnull/2022-05-fix-bolts-url

Docs: Update to 'new' spec repository URL.

2 years agoMerge pull request #1456 from jkczyz/2022-04-effective-capacity
Arik Sosman [Fri, 20 May 2022 17:56:10 +0000 (10:56 -0700)]
Merge pull request #1456 from jkczyz/2022-04-effective-capacity

Use `EffectiveCapacity` in `Score` trait

2 years agoFix rust beta docs lightning-invoice crate.
Arik Sosman [Thu, 19 May 2022 17:07:35 +0000 (10:07 -0700)]
Fix rust beta docs lightning-invoice crate.

2 years agoUse new spec repository URL.
Elias Rohrer [Fri, 20 May 2022 15:17:29 +0000 (17:17 +0200)]
Use new spec repository URL.

2 years agoScore without uncertainty for exact liquidity
Jeffrey Czyz [Wed, 27 Apr 2022 20:55:33 +0000 (15:55 -0500)]
Score without uncertainty for exact liquidity

For direct channels, the channel liquidity is known with certainty. Use
this knowledge in ProbabilisticScorer by either penalizing with the
per-hop penalty or u64::max_value depending on the amount.

2 years agoPass effective capacity to scorer
Jeffrey Czyz [Fri, 22 Apr 2022 13:21:18 +0000 (08:21 -0500)]
Pass effective capacity to scorer

Scorers could benefit from having the channel's EffectiveCapacity rather
than a u64 msat value. For instance, ProbabilisticScorer can give a more
accurate penalty when given the ExactLiquidity variant. Pass a struct
wrapping the effective capacity, the proposed amount, and any in-flight
HTLC value.

2 years agoUse correct penalty and CLTV delta in route hints
Jeffrey Czyz [Tue, 17 May 2022 21:57:55 +0000 (16:57 -0500)]
Use correct penalty and CLTV delta in route hints

For route hints, the aggregate next hops path penalty and CLTV delta
should be computed after considering each hop rather than before.
Otherwise, these aggregate values will include values from the current
hop, too.

2 years agoUse the correct amount when scoring route hints
Jeffrey Czyz [Tue, 17 May 2022 21:43:36 +0000 (16:43 -0500)]
Use the correct amount when scoring route hints

When scoring route hints, the amount passed to the scorer should include
any fees needed for subsequent hops. This worked correctly for single-
hop hints since there are no further hops, but not for multi-hint hops
(except the final one).

2 years agoDistinguish maximum HTLC from effective capacity
Jeffrey Czyz [Sun, 23 Jan 2022 23:25:38 +0000 (17:25 -0600)]
Distinguish maximum HTLC from effective capacity

Using EffectiveCapacity in scoring gives more accurate success
probabilities when the maximum HTLC value is less than the channel
capacity. Change EffectiveCapacity to prefer the channel's capacity
over its maximum HTLC limit, but still use the latter for route finding.

2 years agoStore an `events::PaymentPurpose` with each claimable payment
Matt Corallo [Wed, 4 May 2022 17:49:09 +0000 (17:49 +0000)]
Store an `events::PaymentPurpose` with each claimable payment

In fc77c57c3c6e165d26cb5c1f5d1afee0ecd02589 we stopped using the
`FInalOnionHopData` in `OnionPayload::Invoice` directly and intend
to remove it eventually. However, in the next few commits we need
access to the payment secret when claimaing a payment, as we create
a new `PaymentPurpose` during the claim process for a new event.

In order to get access to a `PaymentPurpose` without having access
to the `FinalOnionHopData` we here change the storage of
`claimable_htlcs` to store a single `PaymentPurpose` explicitly
with each set of claimable HTLCs.

2 years agoEnable removal of `OnionPayload::Invoice::_legacy_hop_data` later
Matt Corallo [Wed, 4 May 2022 16:29:29 +0000 (16:29 +0000)]
Enable removal of `OnionPayload::Invoice::_legacy_hop_data` later

In fc77c57c3c6e165d26cb5c1f5d1afee0ecd02589 we stopped using the
`FinalOnionHopData` in `OnionPayload::Invoice` directly and renamed
it `_legacy_hop_data` with the intent of removing it in a few
versions. However, we continue to check that it was included in the
serialized data, meaning we would not be able to remove it without
breaking ability to serialize full `ChannelManager`s.

This fixes that by making the `_legacy_hop_data` an `Option` which
we will happily handle just fine if its `None`.

2 years agoPathBuildingHop::value_contribution_msat in Debug
Jeffrey Czyz [Thu, 5 May 2022 21:19:40 +0000 (16:19 -0500)]
PathBuildingHop::value_contribution_msat in Debug

2 years agoMerge pull request #1476 from tnull/2022-05-maximum-path-length
Matt Corallo [Wed, 18 May 2022 19:22:42 +0000 (19:22 +0000)]
Merge pull request #1476 from tnull/2022-05-maximum-path-length

Consider maximum path length during path finding.

2 years agoConsider maximum path length during path finding.
Elias Rohrer [Wed, 18 May 2022 16:50:43 +0000 (18:50 +0200)]
Consider maximum path length during path finding.

2 years agoRandomize the `ConnectStyle` during tests 2022-05-new-chain-tests
Matt Corallo [Sun, 15 May 2022 19:13:43 +0000 (19:13 +0000)]
Randomize the `ConnectStyle` during tests

We have a bunch of fancy infrastructure to ensure we can connect
blocks using all our different connection interfaces, but we only
bother to use it in a few select tests.

This expands our use of `ConnectStyle` to most of our tests by
simply randomizing the style in each test. This makes our tests
non-deterministic, but we print the connection style at start so
that it's easy to reproduce a failure deterministically.