rust-lightning
2 years agoSkip `channel_update` signature checks if we have a newer state 2022-03-skip-redundant-sig-checks
Matt Corallo [Wed, 23 Mar 2022 22:10:15 +0000 (22:10 +0000)]
Skip `channel_update` signature checks if we have a newer state

`channel_update` messages already have their signatures checked
with the network graph write lock held, so there's no reason to
check the signatures before doing other quicker checks first,
including checking if we're already aware of a newer update for the
channel.

This reduces common-case CPU usage as `channel_update`s are sent
rather liberally over the p2p network to gossip them.

2 years agoMerge pull request #1360 from tnull/2022-03-loopless-random-walks
Matt Corallo [Wed, 23 Mar 2022 21:40:25 +0000 (21:40 +0000)]
Merge pull request #1360 from tnull/2022-03-loopless-random-walks

Avoid looping CLTV shadow routes.

2 years agoMerge pull request #1326 from Psycho-Pirate/peers
Matt Corallo [Wed, 23 Mar 2022 21:02:17 +0000 (21:02 +0000)]
Merge pull request #1326 from Psycho-Pirate/peers

Added option to send remote IP to peers

2 years agoAvoid looping CLTV shadow routes.
Elias Rohrer [Wed, 23 Mar 2022 15:30:59 +0000 (09:30 -0600)]
Avoid looping CLTV shadow routes.

2 years agoMerge pull request #1374 from TheBlueMatt/2022-03-bindings-cleanups
Matt Corallo [Wed, 23 Mar 2022 00:46:31 +0000 (00:46 +0000)]
Merge pull request #1374 from TheBlueMatt/2022-03-bindings-cleanups

Trivial Bindings Cleanups

2 years agoArgument added in lightning-net-tokio/src/lib.rs and comments updated
psycho-pirate [Tue, 15 Mar 2022 22:33:09 +0000 (04:03 +0530)]
Argument added in lightning-net-tokio/src/lib.rs and comments updated

2 years agoadded network address in methods, filter_address function with tests and updated...
psycho-pirate [Sat, 12 Mar 2022 19:10:35 +0000 (00:40 +0530)]
added network address in methods, filter_address function with tests and updated documentation

2 years agoMerge pull request #1353 from dunxen/2022-03-mpp-receive-timeout
valentinewallace [Tue, 22 Mar 2022 21:15:18 +0000 (17:15 -0400)]
Merge pull request #1353 from dunxen/2022-03-mpp-receive-timeout

Add MPP receive timeout handling

2 years agoMerge pull request #1373 from lightningdevkit/dependabot/github_actions/actions/cache-3
valentinewallace [Tue, 22 Mar 2022 20:39:57 +0000 (16:39 -0400)]
Merge pull request #1373 from lightningdevkit/dependabot/github_actions/actions/cache-3

Bump actions/cache from 2 to 3

2 years agoMerge pull request #1368 from TheBlueMatt/2022-03-fix-post-start-sync
Matt Corallo [Tue, 22 Mar 2022 19:23:51 +0000 (19:23 +0000)]
Merge pull request #1368 from TheBlueMatt/2022-03-fix-post-start-sync

Send a gossip_timestamp_filter on connect to enable gossip sync

2 years agoAdd MPP receive timeout handling
Duncan Dean [Thu, 3 Mar 2022 19:06:40 +0000 (21:06 +0200)]
Add MPP receive timeout handling

2 years agoMerge pull request #1352 from TheBlueMatt/2022-03-debug-rwlock
Matt Corallo [Tue, 22 Mar 2022 04:19:12 +0000 (04:19 +0000)]
Merge pull request #1352 from TheBlueMatt/2022-03-debug-rwlock

Implement lockorder checking on RwLocks in debug_sync

2 years agoUse `impl<bounds>` instead of a `where` clause to help bindings 2022-03-bindings-cleanups
Matt Corallo [Mon, 21 Mar 2022 20:08:37 +0000 (20:08 +0000)]
Use `impl<bounds>` instead of a `where` clause to help bindings

2 years agoTag some type aliases with `(C-not exported)`
Matt Corallo [Fri, 18 Mar 2022 03:28:25 +0000 (03:28 +0000)]
Tag some type aliases with `(C-not exported)`

Type aliases are now more robustly being exported in the C bindings
generator, which requires ensuring we don't include some type
aliases which make no sense in bindings.

2 years agoBump actions/cache from 2 to 3
dependabot[bot] [Mon, 21 Mar 2022 17:38:00 +0000 (17:38 +0000)]
Bump actions/cache from 2 to 3

Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoMerge pull request #1361 from luizParreira/rust-lightning/issues/1280
Matt Corallo [Fri, 18 Mar 2022 20:29:23 +0000 (20:29 +0000)]
Merge pull request #1361 from luizParreira/rust-lightning/issues/1280

Create normal/phantom invoice with description hash

2 years agoUse the term "lock" for `Mutex`/`RwLock` instead of "mutex" 2022-03-debug-rwlock
Matt Corallo [Wed, 9 Mar 2022 19:10:59 +0000 (19:10 +0000)]
Use the term "lock" for `Mutex`/`RwLock` instead of "mutex"

2 years agoImplement lockorder checking on RwLocks in debug_sync
Matt Corallo [Wed, 9 Mar 2022 06:24:06 +0000 (06:24 +0000)]
Implement lockorder checking on RwLocks in debug_sync

2 years agoCreate normal/phantom invoice with description hash
Luiz Parreira [Sun, 13 Mar 2022 15:15:00 +0000 (12:15 -0300)]
Create normal/phantom invoice with description hash

2 years agoMerge pull request #1363 from TheBlueMatt/2022-03-tx-conf-ordering-lock-delay
Matt Corallo [Fri, 18 Mar 2022 17:20:53 +0000 (17:20 +0000)]
Merge pull request #1363 from TheBlueMatt/2022-03-tx-conf-ordering-lock-delay

Generate a funding_locked on relevant transactions_confirmed calls

2 years agoSend a `gossip_timestamp_filter` on connect to enable gossip sync 2022-03-fix-post-start-sync
Matt Corallo [Thu, 17 Mar 2022 22:14:43 +0000 (22:14 +0000)]
Send a `gossip_timestamp_filter` on connect to enable gossip sync

On connection, if our peer supports gossip queries, and we never
send a `gossip_timestamp_filter`, our peer is supposed to never
send us gossip outside of explicit queries. Thus, we'll end up
always having stale gossip information after the first few
connections we make to peers.

The solution is to send a dummy `gossip_timestamp_filter`
immediately after connecting to peers.

2 years agoRename `RoutingMessageHandler::sync_routing_table` `peer_connected`
Matt Corallo [Thu, 17 Mar 2022 22:04:48 +0000 (22:04 +0000)]
Rename `RoutingMessageHandler::sync_routing_table` `peer_connected`

Its somewhat strange to have a trait method which is named after
the intended action, rather than the action that occurred, leaving
it up to the implementor what action they want to take.

2 years agoMerge pull request #1358 from TheBlueMatt/2022-03-max-cltv
Matt Corallo [Thu, 17 Mar 2022 05:13:56 +0000 (05:13 +0000)]
Merge pull request #1358 from TheBlueMatt/2022-03-max-cltv

Make `max_total_cltv_expiry_delta` include the final CLTV

2 years agoMake `max_total_cltv_expiry_delta` include the final CLTV 2022-03-max-cltv
Matt Corallo [Wed, 9 Mar 2022 23:04:15 +0000 (23:04 +0000)]
Make `max_total_cltv_expiry_delta` include the final CLTV

This fixes an integer underflow found by the `router` fuzz target
in CI.

2 years agoMake routing benchmark robust against path changes
Matt Corallo [Thu, 10 Mar 2022 21:07:37 +0000 (21:07 +0000)]
Make routing benchmark robust against path changes

If the scoring in the routing benchmark causes us to take a
different path from the original scan, we may end up deciding that
the only path to a node has a too-high total CLTV delta, causing us
to panic in the benchmarking phase.

Here we simply check for that possibility and remove paths that
fail post-scoring.

2 years agoMerge pull request #1325 from ViktorTigerstrom/2022-02-filter-route-hints
Matt Corallo [Wed, 16 Mar 2022 17:32:40 +0000 (17:32 +0000)]
Merge pull request #1325 from ViktorTigerstrom/2022-02-filter-route-hints

Filter route hints when creating invoices

2 years agoAdd phantom invoice route hints filtering tests
Viktor Tigerström [Mon, 21 Feb 2022 20:22:26 +0000 (21:22 +0100)]
Add phantom invoice route hints filtering tests

2 years agoFilter route hints for phantom invoices
Viktor Tigerström [Mon, 21 Feb 2022 20:18:45 +0000 (21:18 +0100)]
Filter route hints for phantom invoices

Filter the route hints in `create_phantom_invoice` based on the
following criteria:

* Only one channel for every counterparty node per phantom
payment-receiving node in the invoice
* Always select the channel with the highest inbound capacity
* For each payment-receiving node, filter out channels with a lower
inbound capacity than the invoice amount, if any channel exists with
enough capacity to cover the invoice amount
* If any public channels exists for a payment-receiving node, push a
single RouteHintHop with the phantom route and let the sender find the
path to the payment-receiving node through the public channels.

2 years agoAdd tests for create invoice route hints filtering
Viktor Tigerström [Mon, 21 Feb 2022 01:31:21 +0000 (02:31 +0100)]
Add tests for create invoice route hints filtering

2 years agoFilter route hints for create invoice
Viktor Tigerström [Mon, 21 Feb 2022 01:31:21 +0000 (02:31 +0100)]
Filter route hints for create invoice

Filter the route hints in `create_invoice_from_channelmanager` based on
the following criteria:

* Only one channel per counterparty node
* Always select the channel with the highest inbound capacity
* Filter out channels with a lower inbound capacity than the invoice
amount, if any channel exists with enough capacity to cover the invoice
amount
* If any public channel exists, the invoice route_hints should be empty,
and the sender will need to find the path to the payment-receiving node
by looking at the public channels instead

2 years agoGenerate a funding_locked on relevant transactions_confirmed calls 2022-03-tx-conf-ordering-lock-delay
Matt Corallo [Sun, 13 Mar 2022 21:35:46 +0000 (21:35 +0000)]
Generate a funding_locked on relevant transactions_confirmed calls

Previously, if we were offline when a funding transaction was
locked in, and then we came back online, calling
`best_block_updated` once followed by `transactions_confirmed`,
we'd not generate a funding_locked until the next
`best_block_updated`.

We address this by re-calling `best_block_updated` in
`transactions_confirmed`, similar to how `ChannelMonitor` works.

2 years agoMerge pull request #1331 from TheBlueMatt/2022-02-no-copy-invoice-fields
Jeffrey Czyz [Fri, 11 Mar 2022 20:26:02 +0000 (14:26 -0600)]
Merge pull request #1331 from TheBlueMatt/2022-02-no-copy-invoice-fields

Use &mut self in invoice updaters, not take-self-return-Self

2 years agoMerge pull request #1311 from TheBlueMatt/2022-02-0conf-part-1
Matt Corallo [Thu, 10 Mar 2022 00:47:23 +0000 (00:47 +0000)]
Merge pull request #1311 from TheBlueMatt/2022-02-0conf-part-1

Support for SCID Aliases

2 years agoMerge pull request #1341 from jkczyz/2022-03-expiry-time-panic
valentinewallace [Wed, 9 Mar 2022 23:19:22 +0000 (18:19 -0500)]
Merge pull request #1341 from jkczyz/2022-03-expiry-time-panic

Correct docs about invoice_expiry_delta_secs panic

2 years agoMerge pull request #1349 from TheBlueMatt/2022-03-listen-send-sync
Jeffrey Czyz [Wed, 9 Mar 2022 22:41:40 +0000 (16:41 -0600)]
Merge pull request #1349 from TheBlueMatt/2022-03-listen-send-sync

Require `chain::Listen` impls in block sync be `Send + Sync`

2 years agoMerge pull request #1348 from TheBlueMatt/2022-03-timer-tick-count
Matt Corallo [Wed, 9 Mar 2022 21:28:05 +0000 (21:28 +0000)]
Merge pull request #1348 from TheBlueMatt/2022-03-timer-tick-count

Reduce the number of timer ticks a peer is allowed to take

2 years agoMerge pull request #1355 from lightningdevkit/dependabot/cargo/lightning/regex-0...
Matt Corallo [Wed, 9 Mar 2022 21:27:50 +0000 (21:27 +0000)]
Merge pull request #1355 from lightningdevkit/dependabot/cargo/lightning/regex-0.2.11

Update regex requirement from 0.1.80 to 0.2.11 in /lightning

2 years agoCorrect docs about invoice_expiry_delta_secs panic
Jeffrey Czyz [Wed, 2 Mar 2022 00:44:30 +0000 (16:44 -0800)]
Correct docs about invoice_expiry_delta_secs panic

2 years agoSupport receiving multiple funding_locked messages 2022-02-0conf-part-1
Matt Corallo [Tue, 1 Feb 2022 17:37:28 +0000 (17:37 +0000)]
Support receiving multiple funding_locked messages

As a part of adding SCID aliases to channels, we now have to accept
otherwise-redundant funding_locked messages which serve only to
update the SCID alias. Previously, we'd failt he channel as such
an update used to be bogus.

2 years agoProvide our peers with SCID aliases and forward payments with them
Matt Corallo [Tue, 15 Feb 2022 23:27:07 +0000 (23:27 +0000)]
Provide our peers with SCID aliases and forward payments with them

This creates an SCID alias for all of our outbound channels, which
we send to our counterparties as a part of the `funding_locked`
message and then recognize in any HTLC forwarding instructions.

Note that we generate an SCID alias for all channels, including
already open ones, even though we currently have no way of
communicating to our peers the SCID alias for already-open
channels.

2 years agoHandle `short_to_id` state updates on channel closure via macros
Matt Corallo [Tue, 8 Feb 2022 21:43:14 +0000 (21:43 +0000)]
Handle `short_to_id` state updates on channel closure via macros

This avoids needing to update channel closure code in many places
as we add multiple SCIDs for each channel and have to track them.

2 years agoTrack SCID aliases from our counterparty and use them in invoices
Matt Corallo [Tue, 1 Feb 2022 17:37:16 +0000 (17:37 +0000)]
Track SCID aliases from our counterparty and use them in invoices

New `funding_locked` messages can include SCID aliases which our
counterparty will recognize as "ours" for the purposes of relaying
transactions to us. This avoids telling the world about our
on-chain transactions every time we want to receive a payment, and
will allow for receiving payments before the funding transaction
appears on-chain.

Here we store the new SCID aliases and use them in invoices instead
of he "standard" SCIDs.

2 years agoAdd support for deserializing the new SCID alias in funding_locked
Matt Corallo [Fri, 4 Feb 2022 21:35:41 +0000 (21:35 +0000)]
Add support for deserializing the new SCID alias in funding_locked

2 years agoClean up the `handle_monitor_err!()` macro argument forms somewhat
Matt Corallo [Tue, 1 Feb 2022 23:42:05 +0000 (23:42 +0000)]
Clean up the `handle_monitor_err!()` macro argument forms somewhat

`handle_monitor_err!()` has a number of different forms depending
on which messages and actions were outstanding when the monitor
updating first failed. Instead of matching by argument count, its
much more readable to put an explicit string in the arguments to
make it easy to scan for the called form.

2 years agoMerge pull request #1286 from tnull/add_random_cltv_offsets
Jeffrey Czyz [Wed, 9 Mar 2022 19:08:57 +0000 (13:08 -0600)]
Merge pull request #1286 from tnull/add_random_cltv_offsets

Add random 'shadow route' CLTV delta offsets to improve privacy

2 years agoMake lightning-block-sync's init module slightly more generic 2022-03-listen-send-sync
Matt Corallo [Wed, 9 Mar 2022 18:15:30 +0000 (18:15 +0000)]
Make lightning-block-sync's init module slightly more generic

Users who want to use lightning-block-sync's init module would
be reasonable in wanting to use it in a multithreaded environment,
however because it takes a list of listeners as dyn chain::Listen
without any Send or Sync bound they fail in doing so.

Here we make the type bounds on `chain::Listen` generic across
`chain::Listen + ?Sized`, which the existing bound of `&dyn
chain::Listen` satisfies. Thus, this is strictly less restrictive
and allows for the use of `&dyn chain::Listen + Send + Sync`.

2 years agoUpdate regex requirement from 0.1.80 to 0.2.11 in /lightning
dependabot[bot] [Wed, 9 Mar 2022 17:38:53 +0000 (17:38 +0000)]
Update regex requirement from 0.1.80 to 0.2.11 in /lightning

Updates the requirements on [regex](https://github.com/rust-lang/regex) to permit the latest version.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/0.1.80...0.2.11)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoAdd a random per-path CLTV offset for privacy.
Elias Rohrer [Wed, 9 Mar 2022 17:13:47 +0000 (11:13 -0600)]
Add a random per-path CLTV offset for privacy.

2 years agoMerge pull request #1347 from jkczyz/2022-03-log-approximation
Jeffrey Czyz [Wed, 9 Mar 2022 16:19:25 +0000 (10:19 -0600)]
Merge pull request #1347 from jkczyz/2022-03-log-approximation

Use log approximation in ProbabilisticScorer

2 years agoRefactor debug sync methods into helper functions
Matt Corallo [Wed, 9 Mar 2022 06:23:39 +0000 (06:23 +0000)]
Refactor debug sync methods into helper functions

2 years agoCheck for no-std compatibility across dependencies
Jeffrey Czyz [Fri, 4 Mar 2022 07:59:44 +0000 (23:59 -0800)]
Check for no-std compatibility across dependencies

To ensure no-std is honored across dependencies, add a crate depending
on lightning crates supporting no-std. This should ensure any
regressions are caught. Otherwise, cargo doesn't seem to catch some
incompatibilities (e.g., f64::log10 unavailable in core) and seemingly
across other dependencies as describe here:

https://blog.dbrgn.ch/2019/12/24/testing-for-no-std-compatibility/

2 years agoFix compilation warnings with --features=no-std
Jeffrey Czyz [Thu, 3 Mar 2022 23:41:44 +0000 (15:41 -0800)]
Fix compilation warnings with --features=no-std

2 years agoUse log approximation in ProbabilisticScorer
Jeffrey Czyz [Thu, 3 Mar 2022 19:52:39 +0000 (11:52 -0800)]
Use log approximation in ProbabilisticScorer

Since f64::log10 exists in std but not core, unconditionally use log
approximation so --feature=no-std will compile.

2 years agoMove private channel and short-conf tests to new module
Matt Corallo [Wed, 16 Feb 2022 00:19:50 +0000 (00:19 +0000)]
Move private channel and short-conf tests to new module

2 years agoAdd a new functional test utility to open an unannounced channel
Matt Corallo [Tue, 15 Feb 2022 21:05:20 +0000 (21:05 +0000)]
Add a new functional test utility to open an unannounced channel

2 years agoGive `ChannelManager`s `channel_udpate`s for pub chans in test
Matt Corallo [Tue, 8 Mar 2022 19:14:49 +0000 (19:14 +0000)]
Give `ChannelManager`s `channel_udpate`s for pub chans in test

This makes tests slightly more realistic by delivering
`channel_update`s to `ChannelManager`s, ensuring we have
forwarding data stored locally for all channels, including public
ones.

2 years agoReduce the number of timer ticks a peer is allowed to take 2022-03-timer-tick-count
Matt Corallo [Mon, 7 Mar 2022 19:02:15 +0000 (19:02 +0000)]
Reduce the number of timer ticks a peer is allowed to take

In 2d3a2108979adca6b7632e2d59c10e4b131e8bf4, we increased the
default ping timer in `lightning-background-processor` to ten
seconds from five. However, we didn't change the timer count at
which we disconnect peers if they're not responding, which we
likely should have done. We do so here, as well as update the
documentation for `PeerManager::timer_tick_occurred` to suggest
always ticking the timer every ten seconds instead of five.

2 years agoMerge pull request #1317 from TheBlueMatt/2022-02-fix-bunk-test
Matt Corallo [Sat, 5 Mar 2022 20:54:57 +0000 (20:54 +0000)]
Merge pull request #1317 from TheBlueMatt/2022-02-fix-bunk-test

Fix what `bolt2_open_channel_sending_node_checks_part1` tests

2 years agoClean up `TestKeysInterface` random bytes override interface 2022-02-fix-bunk-test
Matt Corallo [Fri, 4 Mar 2022 21:31:55 +0000 (21:31 +0000)]
Clean up `TestKeysInterface` random bytes override interface

Its very confusing to have multiple fields that do the same thing,
one of which isn't even used for its stated purpose anymore after
the previous few commits.

2 years agoFix what `bolt2_open_channel_sending_node_checks_part1` tests
Matt Corallo [Wed, 16 Feb 2022 05:36:54 +0000 (05:36 +0000)]
Fix what `bolt2_open_channel_sending_node_checks_part1` tests

There are currently two issues with
`bolt2_open_channel_sending_node_checks_part1` which counteract
each other and hide that the test isn't testing what it should be.

First of all, the final `create_channel` call actually fails
because we try to open a channel with ourselves, instead of
panicing as the test is supposed to check for.

However, when we fix the create_channel call to panic, when we
drop `nodes[1]` after `create_channel` panics, we fail the
no-pending-messages test as it as an expeted `accept_channel` in
its outbound buffer. This causes a double-panic.

Previously, these two offset each other - instead of panicing in
`create_channel` we'd panic in the Node drop checks.

This fixes both by fetching the `accept_channel` before we go into
the panic'ing `create_channel` call (who's arguments were
corrected).

2 years agoMerge pull request #1343 from lightningdevkit/dependabot/github_actions/actions/check...
valentinewallace [Thu, 3 Mar 2022 19:35:01 +0000 (14:35 -0500)]
Merge pull request #1343 from lightningdevkit/dependabot/github_actions/actions/checkout-3

Bump actions/checkout from 2 to 3

2 years agoMerge pull request #1346 from TheBlueMatt/2022-03-clones
valentinewallace [Thu, 3 Mar 2022 19:34:07 +0000 (14:34 -0500)]
Merge pull request #1346 from TheBlueMatt/2022-03-clones

Add Clone to a few structs which contain only a few fields

2 years agoAdd Clone to a few structs which contain only a few fields 2022-03-clones
Matt Corallo [Thu, 3 Mar 2022 18:09:46 +0000 (18:09 +0000)]
Add Clone to a few structs which contain only a few fields

Specifically, `PhantomRouteHints`, `FixedPenaltyScorer`, and
`ScoringParamters`.

2 years agoMerge pull request #1310 from TheBlueMatt/2022-02-bump-msrv
Matt Corallo [Wed, 2 Mar 2022 19:09:14 +0000 (19:09 +0000)]
Merge pull request #1310 from TheBlueMatt/2022-02-bump-msrv

Bump MSRV to 1.41.1.

2 years agoBump actions/checkout from 2 to 3
dependabot[bot] [Wed, 2 Mar 2022 17:35:18 +0000 (17:35 +0000)]
Bump actions/checkout from 2 to 3

Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agoMerge pull request #1339 from TheBlueMatt/2022-02-0.0.105-sec v0.0.105
Matt Corallo [Tue, 1 Mar 2022 04:13:19 +0000 (04:13 +0000)]
Merge pull request #1339 from TheBlueMatt/2022-02-0.0.105-sec

0.0.105 Security Fixes

2 years agoUpdate CHANGELOG with security info for 0.0.105 2022-02-0.0.105-sec
Matt Corallo [Mon, 28 Feb 2022 22:53:16 +0000 (22:53 +0000)]
Update CHANGELOG with security info for 0.0.105

2 years agoMerge branch '2022-02-bal-panic' into 2022-02-0.0.105-sec
Matt Corallo [Tue, 1 Mar 2022 02:23:14 +0000 (02:23 +0000)]
Merge branch '2022-02-bal-panic' into 2022-02-0.0.105-sec

2 years agoMerge branch '2022-02-fix-multi-hop-hint-panic' into 2022-02-0.0.105-sec
Matt Corallo [Tue, 1 Mar 2022 02:23:07 +0000 (02:23 +0000)]
Merge branch '2022-02-fix-multi-hop-hint-panic' into 2022-02-0.0.105-sec

2 years agoMerge pull request #1322 from TheBlueMatt/2022-02-0.0.105
Matt Corallo [Tue, 1 Mar 2022 02:22:00 +0000 (02:22 +0000)]
Merge pull request #1322 from TheBlueMatt/2022-02-0.0.105

Cut 0.0.105

2 years agoEnsure `get_claimable_balances` never panicks in tests
Matt Corallo [Fri, 25 Feb 2022 05:18:29 +0000 (05:18 +0000)]
Ensure `get_claimable_balances` never panicks in tests

... by calling it both before and after every chain event in
testing and fuzzing.

This requires fixing some blockchain inconsistencies in
`do_test_onchain_htlc_reorg`, `do_retry_with_no_persist`, and
`do_test_dup_htlc_onchain_fails_on_reload` where we'd connect
conflicting transactions in the same chain.

2 years agoFix HTLC tx balance calculation on local commitment transactions
Matt Corallo [Fri, 25 Feb 2022 05:14:00 +0000 (05:14 +0000)]
Fix HTLC tx balance calculation on local commitment transactions

When handling the broadcast of a local commitment transactions
(with associated CSV delays prior to spendability), we incorrectly
handled the CSV delays on HTLC transactions. This caused us to miss
spendable outputs for HTLCs which were awaiting a CSV delay.

Further, because of this, we could hit an assertion as
`get_claimable_balances` asserted that HTLCs were resolved after
the funding spend was resolved, which was not true if the HTLC did
not have a CSV delay attached (due to the above bug or due to it
being an HTLC claim by our counterparty).

This fixes both bugs, also converting some assertions to
`debug_assert`s to avoid future issues as balance mis-calculation
is not currently an indication of potential funds loss.

Thanks to Cash App for reporting this bug.

2 years agoBump crate versions to 0.0.105/invoice 0.13 2022-02-0.0.105
Matt Corallo [Fri, 18 Feb 2022 22:13:21 +0000 (22:13 +0000)]
Bump crate versions to 0.0.105/invoice 0.13

2 years agoFill out CHANGELOG for 0.0.105
Matt Corallo [Fri, 18 Feb 2022 22:12:14 +0000 (22:12 +0000)]
Fill out CHANGELOG for 0.0.105

2 years agoCorrect default value for A* heuristic for non-public nodes
Matt Corallo [Thu, 10 Feb 2022 21:33:26 +0000 (21:33 +0000)]
Correct default value for A* heuristic for non-public nodes

This doesn't (appear) to change behavior, however if we have a
non-public node, we assign an A* heuristic of max-u32 fees, which
may result in us de-prioritizing the path in some rare cases around
multi-hop route hints which compete with public nodes.

2 years agoFix panic when routing through multiple private last-hops
Matt Corallo [Thu, 10 Feb 2022 21:29:43 +0000 (21:29 +0000)]
Fix panic when routing through multiple private last-hops

When we added support for routing through a multi-hop invoice hint
we failed to remove an assertion that we always are able to fill
in features for each hop except the last one. However, when a
multi-hop invoice hint is used, we will not have features for any
of the hinted hops, causing us to panic.

2 years agoMerge pull request #1327 from TheBlueMatt/2022-02-log-before-panic
Arik Sosman [Mon, 28 Feb 2022 22:03:03 +0000 (14:03 -0800)]
Merge pull request #1327 from TheBlueMatt/2022-02-log-before-panic

2 years agoMerge pull request #1303 from jkczyz/2022-02-docs-with-features
Matt Corallo [Mon, 28 Feb 2022 21:00:05 +0000 (21:00 +0000)]
Merge pull request #1303 from jkczyz/2022-02-docs-with-features

Generate docs with features for docs.rs

2 years agoMerge pull request #1335 from TheBlueMatt/2022-02-fix-honggfuzz-regression
valentinewallace [Mon, 28 Feb 2022 18:50:03 +0000 (13:50 -0500)]
Merge pull request #1335 from TheBlueMatt/2022-02-fix-honggfuzz-regression

Pin rustc in fuzzing to 1.58 due to honggfuzz-rs regression

2 years agoMerge pull request #1324 from valentinewallace/2022-02-phantom-followup
Matt Corallo [Mon, 28 Feb 2022 18:16:21 +0000 (18:16 +0000)]
Merge pull request #1324 from valentinewallace/2022-02-phantom-followup

#1199 Followup

2 years agoMerge pull request #1332 from TheBlueMatt/2022-02-persister-ignore-tmp
Matt Corallo [Sat, 26 Feb 2022 01:30:29 +0000 (01:30 +0000)]
Merge pull request #1332 from TheBlueMatt/2022-02-persister-ignore-tmp

Ignore .tmp files when loading ChannelMonitors in persister

2 years agoPin rustc in fuzzing to 1.58 due to honggfuzz-rs regression 2022-02-fix-honggfuzz-regression
Matt Corallo [Fri, 25 Feb 2022 22:09:30 +0000 (22:09 +0000)]
Pin rustc in fuzzing to 1.58 due to honggfuzz-rs regression

2 years agoFix bug where we encode flags field into all updates on htlc fail
Valentine Wallace [Thu, 24 Feb 2022 03:20:43 +0000 (22:20 -0500)]
Fix bug where we encode flags field into all updates on htlc fail

Failing an HTLC with onion error channel_disabled requires encoding a 'flags' field into the failure
packet. However, we were encoding this 'flags' field for all failures packets that were failing on
update_add_htlc with an update (error 0x1000 UPDATE).

Discovered in the course of adding phantom payment failure tests, which also added testing for this bug

2 years agoCorrectly wrap phantom onion errors
Valentine Wallace [Fri, 25 Feb 2022 03:28:58 +0000 (22:28 -0500)]
Correctly wrap phantom onion errors

In any place where fail_htlc_backwards_internal was called for a phantom payment
failure, we weren't encoding the onion failure as if the phantom were the one
failing. Instead, we were encoding the failure as if it were coming from the
second-to-last hop. This caused our failures to not be parsed properly on the
payer's side.

Places we were encoding failures incorrectly include:
* on failure of a call to inbound_payment::verify
* on a user call to fail_htlc_backwards

Also drop some unnecessary panics when reading OnionHopData objects. This also
enables one of the phantom failure tests because we can construct OnionHopDatas
with invalid amounts.

Lastly, remove a bogus comment

2 years agoFix phantom malformed onion error packet
Valentine Wallace [Fri, 25 Feb 2022 03:19:20 +0000 (22:19 -0500)]
Fix phantom malformed onion error packet

Ensure we fail back phantom malformed payments with an update_fail_htlc s.t.
the error contains the sha256 of the onion, per LN protocol.

2 years agoAdd phantom shared secret to HTLCPreviousHopData
Valentine Wallace [Fri, 25 Feb 2022 03:14:02 +0000 (22:14 -0500)]
Add phantom shared secret to HTLCPreviousHopData

This also fixes a bug where we were failing back phantom payments with the
wrong scid, causing them to never actually be failed backwards (L3022 in
channelmanager.rs)

This new field will be used in upcoming commit(s) to encrypt phantom payment failure
packets.

2 years agoAdd phantom shared secret to PendingHTLCRouting::Receive
Valentine Wallace [Fri, 25 Feb 2022 02:18:48 +0000 (21:18 -0500)]
Add phantom shared secret to PendingHTLCRouting::Receive

This will be used in upcoming commit(s) to encrypt phantom payment failure packets.

2 years agoMerge pull request #1318 from jurvis/jurvis/2022-02-log-router-penalty-data-4
Matt Corallo [Thu, 24 Feb 2022 19:50:51 +0000 (19:50 +0000)]
Merge pull request #1318 from jurvis/jurvis/2022-02-log-router-penalty-data-4

Implement custom debug for PathBuildingHop

2 years agoIgnore .tmp files when loading ChannelMonitors in persister 2022-02-persister-ignore-tmp
Matt Corallo [Wed, 23 Feb 2022 22:06:33 +0000 (22:06 +0000)]
Ignore .tmp files when loading ChannelMonitors in persister

If we are in the middle of persisting an update to a
`ChannelMonitor` when we shutdown (or crash), we'll start up with
a .tmp file lying around. We should ignore it, as failure to
return from the update call should have prevented the
`ChannelManager` from taking any irrevocable action based on the
update.

We're somewhat protected from any filesystem inconsistency behavior
as the `ChannelManager` will refuse to load if we're outright
missing `ChannelMonitor`s.

Fixes #1330.

2 years agoImplement custom debug for PathBuildingHop
Jurvis Tan [Sat, 12 Feb 2022 04:38:13 +0000 (20:38 -0800)]
Implement custom debug for PathBuildingHop

Add other fields to log for PathBuildingHop

Use DebugStruct to print PathBuildingHop

Fix PathBuildingHop visibility

Add more useful fee print-outs

Remove Features<NodeContext> from hop print-out

Remove logging fields we don’t need

Add fields to log back to PathBuildingHop

2 years agoUse &mut self in invoice updaters, not take-self-return-Self 2022-02-no-copy-invoice-fields
Matt Corallo [Wed, 23 Feb 2022 18:31:41 +0000 (18:31 +0000)]
Use &mut self in invoice updaters, not take-self-return-Self

The take-self-return-Self idiom in Rust is substantially less
usable than it is in Java, where its more common. Because we have
to take self by move, it prevents using the update methods to
actually update features, something we occasionally want to do.

See, eg, the change in lightning-invoice where we previously had
to copy and re-create an entire vec of fields just to update the
features field, which is nuts.

There are a few places where this makes things a little less clean,
but the tradeoff to enable more effecient and broader uses of the
update methods seems worth it.

2 years agoMerge pull request #1309 from TheBlueMatt/2022-02-first-hop-log
valentinewallace [Tue, 22 Feb 2022 17:23:32 +0000 (12:23 -0500)]
Merge pull request #1309 from TheBlueMatt/2022-02-first-hop-log

Specify whether we have first-hop hints when routing

2 years agoFollow-up nits from #1199 (phantom node support)
Valentine Wallace [Sat, 19 Feb 2022 21:41:38 +0000 (16:41 -0500)]
Follow-up nits from #1199 (phantom node support)

2 years agoLog more during ChannelMonitor updating 2022-02-log-before-panic
Matt Corallo [Tue, 22 Feb 2022 00:18:09 +0000 (00:18 +0000)]
Log more during ChannelMonitor updating

Fixes #1323.

2 years agoMerge pull request #1314 from TheBlueMatt/2022-02-accept_chan_type
Arik Sosman [Fri, 18 Feb 2022 21:53:09 +0000 (13:53 -0800)]
Merge pull request #1314 from TheBlueMatt/2022-02-accept_chan_type

Update channel-type implementation to upstream spec as merged

2 years agoGenerate docs with features for docs.rs
Jeffrey Czyz [Sat, 12 Feb 2022 04:22:20 +0000 (22:22 -0600)]
Generate docs with features for docs.rs

Enable generating docs using --all-features or --features="std" where
applicable. Additionally, use doc_auto_cfg to tag items requiring a
feature.

https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#doc_auto_cfg-automatically-generate-doccfg

This requires building with nightly, which is what is used by docs.rs.

https://docs.rs/about/builds

To test locally, use:

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc ...

2 years agoFix rustdoc error on nightly
Jeffrey Czyz [Sat, 12 Feb 2022 04:17:27 +0000 (22:17 -0600)]
Fix rustdoc error on nightly

2 years agoUnhide struct docs in scoring module
Jeffrey Czyz [Sat, 12 Feb 2022 04:14:06 +0000 (22:14 -0600)]
Unhide struct docs in scoring module

The docs were hidden since a type alias should be used. However, the
alias docs don't contain much useful information and don't link to the
corresponding struct.

2 years agoFix `cargo doc` warning in lightning-block-sync
Jeffrey Czyz [Sat, 12 Feb 2022 04:12:33 +0000 (22:12 -0600)]
Fix `cargo doc` warning in lightning-block-sync

2 years agoSpecify whether we have first-hop hints when routing 2022-02-first-hop-log
Matt Corallo [Tue, 15 Feb 2022 20:59:40 +0000 (20:59 +0000)]
Specify whether we have first-hop hints when routing

This is incredibly useful when debugging issues with the router,
and is somewhat of an oversight currently.