Commit graph

1504 commits

Author SHA1 Message Date
Ken Sedgwick
c47d014a8e
Add unit test coverage for package::weight_{offered,received}_htlc 2022-01-13 14:44:05 -08:00
Ken Sedgwick
37001b8b0e
make WEIGHT{_REVOKED,}_{OFFERED,RECEIVED}_HTLC functions with opt_anchors parameter 2022-01-13 14:37:18 -08:00
Ken Sedgwick
3a163d2c61
Isolated channelmonitor weight unit tests and added anchor loops 2022-01-13 14:37:17 -08:00
Ken Sedgwick
8f09e5a7ff
Set the SigHashType of remote htlc signatures w/ anchors to SinglePlusAnyoneCanPay 2022-01-13 14:37:03 -08:00
Matt Corallo
b62b244c3c
Merge pull request #1223 from lightning-signer/2021-12-invoice-nostd
Adapt lightning-invoice to no_std
2022-01-06 19:25:36 +00:00
Devrandom
01915810d4 Adapt lightning-invoice to no_std 2022-01-05 23:18:03 +01:00
Matt Corallo
94c41d8c0a
Merge pull request #1226 from TheBlueMatt/2022-01-bindings-no-std
Support building `cfg=c_bindings` with `no-std`
2022-01-05 21:01:06 +00:00
Matt Corallo
ffbef9fec7 Support building cfg=c_bindings with no-std
This will be needed for JavaScript bindings eventually.
2022-01-05 07:24:46 +00:00
Matt Corallo
3ca63426f9
Merge pull request #1220 from TheBlueMatt/2021-12-stale-update-gossip-log
Log gossip rejections due to stale channel_updates at GOSSIP level
2022-01-03 19:54:20 +00:00
hackerrdave
d46c2a20e1 update repo name to use lightningdevkit 2021-12-26 22:53:16 -05:00
Matt Corallo
d5a1435905 Log gossip rejections due to stale channel_updates at GOSSIP level
This further reduces noise at the TRACE level during initial gossip
sync.
2021-12-19 20:13:38 +00:00
Matt Corallo
d26469a77a Add a C-not exported tag to NetGraphMsgHandler.network_graph 2021-12-18 20:20:23 +00:00
Matt Corallo
ae4f6198db Add a constructor to MultiThreadedLockableScore
...as otherwise the struct is rather useless.
2021-12-18 20:20:23 +00:00
Matt Corallo
2a8a396f1e
Merge pull request #1217 from TheBlueMatt/2021-12-0.0.104
Cut 0.0.104
2021-12-17 23:30:54 +00:00
Matt Corallo
ec86e2a1a7 Bump versions to 0.0.104/invoice 0.12 2021-12-17 21:34:19 +00:00
Matt Corallo
a3330acecf Remove trailing whitespace in the FeeEstimator interface 2021-12-17 04:35:58 +00:00
Valentine Wallace
41cfd833f1
inbound_payment: Add utility to get payment preimage given hash/secret
User-requested feature
2021-12-16 18:11:14 -08:00
Valentine Wallace
d734ad814e
inbound_payment: DRY verify method for use in getting preimage
in the next commit(s)
2021-12-16 16:29:11 -08:00
Valentine Wallace
d20239bbeb
create_inbound_payment: warn about dup hashes
Leftover feedback from #1177
2021-12-16 16:27:13 -08:00
Valentine Wallace
6e0820ca19
Salt inbound payment ExpandedKey
Leftover feedback from #1177
2021-12-16 16:24:24 -08:00
Valentine Wallace
8464875555
Drop need to store pending inbound payments
and replace payment_secret with encrypted metadata

See docs on `inbound_payment::verify` for details

Also add min_value checks to all create_inbound_payment* methods
2021-12-16 15:32:21 -08:00
Valentine Wallace
1d516a6fc5
Add get_single_block to chacha20 module
In the next commit, we'll want to get a single block from a chacha stream that
takes a 16-byte nonce.
2021-12-16 15:30:52 -08:00
Valentine Wallace
063b7583c1
Macro-ize checking that the total value of an MPP's parts is sane
This DRY-ed code will be used in upcoming commits when we stop storing inbound
payment data
2021-12-16 15:30:52 -08:00
Valentine Wallace
6dd1ec1fed
Add get_inbound_payment_key_material to KeysInterface
This will allow us to retrieve key material for encrypting/decrypting inbound
payment info, in upcoming commits
2021-12-16 15:30:52 -08:00
Matt Corallo
73e8dc41a6 Automatically prune NetworkGraph of stale channels hourly in BP 2021-12-16 18:33:24 +00:00
Matt Corallo
cd43ff4a5e Reject channel_update messages with timestamps too old or new
Because we time out channel info that is older than two weeks now,
we should also reject new channel info that is older than two
weeks, in addition to rejecting future channel info.
2021-12-16 18:33:24 +00:00
Matt Corallo
4677e14c00 Add a method to prune stale channels from NetworkGraph
We define "stale" as "haven't heard an updated channel_update in
two weeks", as described in BOLT 7.

We also filter out stale channels at write-time for `std` users, as
we can look up the current time.
2021-12-16 18:33:24 +00:00
Matt Corallo
c575429639 Drop allow_wallclock_use feature in favor of simply using std
Fixes #1147.
2021-12-16 18:33:24 +00:00
Matt Corallo
11d644824e DRY up network_graph tests substantially with message creation fns 2021-12-16 18:33:24 +00:00
Matt Corallo
064d709910
Merge pull request #1148 from dunxen/2021-11-new-onion-errors
Add mpp_timeout and invalid_onion_payload descriptions
2021-12-15 23:32:30 +00:00
Conor Okus
88a86d126f
Merge pull request #1211 from ConorOkus/2021-11-add-max-conversion
Update docs to add max return value to conversion list
2021-12-15 16:15:21 +00:00
Matt Corallo
54114c9d85
Merge pull request #1202 from TheBlueMatt/2021-12-fix-retries-races
Fix payment retry races and inform users when a payment fails
2021-12-15 04:58:46 +00:00
Matt Corallo
05d7a33a58 Make attempting to retry a succeeded payment an APIError, not Route
This is symmetric with the new failure once a payment is abandoned.
2021-12-15 03:57:13 +00:00
Matt Corallo
7782d0a1ef Expose an event when a payment has failed and retries complete
When a payment fails, a payer needs to know when they can consider
a payment as fully-failed, and when only some of the HTLCs in the
payment have failed. This isn't possible with the current event
scheme, as discovered recently and as described in the previous
commit.

This adds a new event which describes when a payment is fully and
irrevocably failed, generating it only after the payment has
expired or been marked as expired with
`ChannelManager::mark_retries_exceeded` *and* all HTLCs for it
have failed. With this, a payer can more simply deduce when a
payment has failed and use that to remove payment state or
finalize a payment failure.
2021-12-15 03:57:13 +00:00
Matt Corallo
0b3240ee6a Add a variant to PendingOutboundPayment for retries-exceeded
When a payer gives up trying to retry a payment, they don't know
for sure what the current state of the event queue is.
Specifically, they cannot be sure that there are not multiple
additional `PaymentPathFailed` or even `PaymentSuccess` events
pending which they will see later. Thus, they have a very hard
time identifying whether a payment has truly failed (and informing
the UI of that fact) or if it is still pending. See [1] for more
information.

In order to avoid this mess, we will resolve it here by having the
payer give `ChannelManager` a bit more information - when they
have given up on a payment - and using that to generate a
`PaymentFailed` event when all paths have failed.

This commit adds the neccessary storage and changes for the new
state inside `ChannelManager` and a public method to mark a payment
as failed, the next few commits will add the new `Event` and use
the new features in our `PaymentRetrier`.

[1] https://github.com/lightningdevkit/rust-lightning/issues/1164
2021-12-15 03:57:13 +00:00
Matt Corallo
8c9615e8d6 DRY up payment failure macros in functional_test_utils
... with a more extensible expectation-checking framework for them.
2021-12-15 03:55:55 +00:00
Duncan Dean
e88c7210f8
Add mpp_timeout and invalid_onion_payload descriptions & handling 2021-12-14 21:11:32 +02:00
Conor Okus
0c34737e35 Updates Fee estimator docs to include a max return value for get_est_sat_per_1000_weight
Updates docs to include a max return value for get_est_sat_per_1000_weight

Adds max to both conversions

Additional detail
2021-12-14 12:36:34 +00:00
Matt Corallo
09714e6fe2
Merge pull request #1169 from TheBlueMatt/2021-11-fix-update-announcements
Fix announcements of our own gossip
2021-12-09 18:21:55 +00:00
Matt Corallo
0fe2aef0e6 Add a comment describing the timestamp field's use 2021-12-09 03:49:50 +00:00
Matt Corallo
61518f9721
Merge pull request #1203 from lightning-signer/2021-12-value-to-self
Getter for the total channel balance
2021-12-08 02:24:32 +00:00
Matt Corallo
cd4dc39a8c
Merge pull request #1208 from TheBlueMatt/2021-12-less-force-close
Reduce force-closures with user fee estimators which round poorly
2021-12-07 20:11:47 +00:00
Matt Corallo
cd9cd47f68
Merge pull request #1205 from TheBlueMatt/2021-12-new-feature-bit
Support the channel_type feature bit.
2021-12-07 19:28:29 +00:00
Matt Corallo
d5e70ad185 Reduce force-closures with user fee estimators which round poorly
See comment for more
2021-12-07 18:49:05 +00:00
Matt Corallo
8f4a22fe31 Support the channel_type feature bit.
Note that this feature bit does absolutely nothing. We signal it
(as we already support channel type negotiation), but do not bother
to look to see if peers support it, as we don't care - we simply
look for the TLV entry and deduce if a peer supports channel type
negotiation from that.

The only behavioral change at all here is that we don't barf if a
peer sets channel type negotiation to required via the feature bit
(instead of failing the channel at open-time), but of course no
implementations do this, and likely won't for some time (if ever -
you can simply fail channels with unknown types later, and there's
no reason to refuse connections, really).

As defined in https://github.com/lightning/bolts/pull/906
2021-12-07 18:05:29 +00:00
Devrandom
02a9f92ea4 Getter for the total channel balance
The existing balance getters subtract reserve, this one does not.
2021-12-07 15:06:22 +01:00
Matt Corallo
3ec529d7cc
Merge pull request #1201 from jkczyz/2021-12-idempotent-channelmanager
Ensure ChannelManager methods are idempotent
2021-12-07 00:42:02 +00:00
Jeffrey Czyz
c453d04137
Ensure ChannelManager methods are idempotent
During event handling, ChannelManager methods may need to be called as
indicated in the Event documentation. Ensure that these calls are
idempotent for the same event rather than panicking. This allows users
to persist events for later handling without needing to worry about
processing the same event twice (e.g., if ChannelManager is not
persisted but the events were, the restarted ChannelManager would return
some of the same events).
2021-12-06 17:18:33 -06:00
Matt Corallo
9c6961ea84
Merge pull request #1204 from TheBlueMatt/2021-12-no-torv2
Remove OnionV2 parsing support
2021-12-06 22:49:18 +00:00
Matt Corallo
d47aebca38
Merge pull request #1130 from TheBlueMatt/2021-10-mon-fail-after-conf
Always return failure in update_monitor after funding spend
2021-12-06 19:35:58 +00:00