]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
18 months agoMove final_cltv_expiry_delta from PaymentParams to Payee::Clear
Valentine Wallace [Thu, 27 Apr 2023 21:37:38 +0000 (17:37 -0400)]
Move final_cltv_expiry_delta from PaymentParams to Payee::Clear

Since blinded pay params won't have this value.

18 months agoAdd BOLT 12 features to PaymentParams
Valentine Wallace [Wed, 3 May 2023 18:05:20 +0000 (14:05 -0400)]
Add BOLT 12 features to PaymentParams

18 months agoMove BOLT11 features from top level PaymentParams to Payee::Clear
Valentine Wallace [Wed, 3 May 2023 17:04:25 +0000 (13:04 -0400)]
Move BOLT11 features from top level PaymentParams to Payee::Clear

Since blinded payees don't have this.

18 months agoError if BOLT 11 features are provided for blinded payment params
Valentine Wallace [Sat, 29 Apr 2023 19:37:51 +0000 (15:37 -0400)]
Error if BOLT 11 features are provided for blinded payment params

18 months agoMove payee node id from top level PaymentParams to Payee::Clear
Valentine Wallace [Sat, 29 Apr 2023 21:13:02 +0000 (17:13 -0400)]
Move payee node id from top level PaymentParams to Payee::Clear

Since blinded payees don't have one

18 months agoError if clear hints are provided for blinded PaymentParams
Valentine Wallace [Sat, 29 Apr 2023 18:47:59 +0000 (14:47 -0400)]
Error if clear hints are provided for blinded PaymentParams

18 months agoGroundwork for refactoring PaymentParams::Hints to ::Payee
Valentine Wallace [Wed, 26 Apr 2023 19:15:19 +0000 (15:15 -0400)]
Groundwork for refactoring PaymentParams::Hints to ::Payee

Minor changes in preparation for supporting route blinding in
PaymentParameters. In the next commit, we'll be moving more
unblinded-payee-specific fields from the top level parameters into the clear
enum variant.

18 months agoMerge pull request #2244 from benthecarman/signature-size
Wilmer Paulino [Tue, 2 May 2023 19:01:51 +0000 (12:01 -0700)]
Merge pull request #2244 from benthecarman/signature-size

Incorporate low-R values into estimate signature size

18 months agoMerge pull request #2213 from benthecarman/error-sign-provider-addrs
Matt Corallo [Tue, 2 May 2023 17:48:05 +0000 (17:48 +0000)]
Merge pull request #2213 from benthecarman/error-sign-provider-addrs

Allow get_shutdown_scriptpubkey and get_destination_script to return an Error

18 months agoAllow get_shutdown_scriptpubkey and get_destination_script to return an error
benthecarman [Sat, 22 Apr 2023 05:48:28 +0000 (00:48 -0500)]
Allow get_shutdown_scriptpubkey and get_destination_script to return an error

18 months agoIncorporate low-R values into estimate signature size
benthecarman [Tue, 2 May 2023 07:01:37 +0000 (02:01 -0500)]
Incorporate low-R values into estimate signature size

18 months agoMerge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow
Wilmer Paulino [Fri, 28 Apr 2023 19:15:02 +0000 (12:15 -0700)]
Merge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow

Fix overflow in `awaiting_pong_timer...` with too many peers

18 months agoMerge pull request #2217 from alecchendev/2023-04-expose-hash-in-balance
Wilmer Paulino [Fri, 28 Apr 2023 18:11:01 +0000 (11:11 -0700)]
Merge pull request #2217 from alecchendev/2023-04-expose-hash-in-balance

Expose `PaymentHash` and `PaymentPreimage` in `Balance`

18 months agoMerge pull request #2239 from valentinewallace/2023-04-remove-redundant-final-cltv...
Wilmer Paulino [Fri, 28 Apr 2023 17:46:51 +0000 (10:46 -0700)]
Merge pull request #2239 from valentinewallace/2023-04-remove-redundant-final-cltv-param

Remove redundant `final_cltv_delta` param from `get_route`

18 months agoFix overflow in `awaiting_pong_timer...` with too many peers 2023-04-ping-count-overflow
Matt Corallo [Fri, 28 Apr 2023 16:19:04 +0000 (16:19 +0000)]
Fix overflow in `awaiting_pong_timer...` with too many peers

If we have more than
127 / `MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` (31) peers,
`awaiting_pong_timer_tick_intervals` can overflow before we hit
the limit. This isn't super harmful, we'll still disconnect peers
as long as they don't send *any* messages between two pings, but it
does cause us to not disconnect peers which are extremely slow in
responding to messages, e.g. because they are overloaded.

18 months agoMerge pull request #2230 from freddiekrugerrand/2228-validatechainhash
Matt Corallo [Thu, 27 Apr 2023 23:00:42 +0000 (23:00 +0000)]
Merge pull request #2230 from freddiekrugerrand/2228-validatechainhash

Check chain hash for channel announcement and update

18 months agoMerge pull request #2044 from freddiekrugerrand/1782-limitchannelhints
Matt Corallo [Thu, 27 Apr 2023 22:02:16 +0000 (22:02 +0000)]
Merge pull request #2044 from freddiekrugerrand/1782-limitchannelhints

Limit route hints to three channels

18 months agoRemove redundant final_cltv_delta param from get_route
Valentine Wallace [Thu, 27 Apr 2023 20:49:02 +0000 (16:49 -0400)]
Remove redundant final_cltv_delta param from get_route

PaymentParameters already includes this value.

This set us up to better support route blinding, since there is no known
final_cltv_delta when paying to a blinded route.

18 months agoMerge pull request #2234 from dunxen/2023-04-bpteststemp
Matt Corallo [Wed, 26 Apr 2023 17:49:52 +0000 (17:49 +0000)]
Merge pull request #2234 from dunxen/2023-04-bpteststemp

Use `env::temp_dir()` for BP tests

18 months agoMerge pull request #2229 from TheBlueMatt/2023-04-115-bindings-upstream-2
Matt Corallo [Wed, 26 Apr 2023 17:34:18 +0000 (17:34 +0000)]
Merge pull request #2229 from TheBlueMatt/2023-04-115-bindings-upstream-2

Trivial Bindings Updates

18 months agoMerge pull request #2233 from TheBlueMatt/2023-04-fix-future-leak
Wilmer Paulino [Wed, 26 Apr 2023 17:27:29 +0000 (10:27 -0700)]
Merge pull request #2233 from TheBlueMatt/2023-04-fix-future-leak

Fix a leak in FutureState when a Notifier is dropped un-woken

18 months agoCheck chain hash for channel announcement and update
Fred Walker [Wed, 26 Apr 2023 12:58:05 +0000 (08:58 -0400)]
Check chain hash for channel announcement and update

18 months agoUse `env::temp_dir()` for BP tests
Duncan Dean [Wed, 26 Apr 2023 12:57:18 +0000 (14:57 +0200)]
Use `env::temp_dir()` for BP tests

Currently `BackgroundProcessor` tests create persister directories in the
current working directory and rely on cleaning up in a `Drop` implementation.

Unfortunately, it seems that in the async tests that nodes are not
`drop()`ed for some reason and so the directories created by those
tests remain behind in the current working directory.

This commit at least ensures that these test directories are created in
a temporary location for the OS using `temp_dir()`. It doesn't aim to
solve the lack of cleanup in the async tests.

Partial fix for #2224 but I believe it's enough to resolve it as these
temp directories that do remain will be purged by the OS at some stage
and are overwritten by subsequent tests if there is a conflict.

18 months agoFix a leak in `FutureState` when a `Notifier` is dropped un-woken 2023-04-fix-future-leak
Matt Corallo [Wed, 26 Apr 2023 05:01:13 +0000 (05:01 +0000)]
Fix a leak in `FutureState` when a `Notifier` is dropped un-woken

If a `Notifier` has an internal `FutureState` which gathers some
sleeper callbacks, but is never actaully woken, those callbacks
will leak due to a circular `Arc` reference when the `Notifier` is
`drop`'d.

Because `Notifier`s are rarely `drop`'d in production this isn't a
huge deal, but shows up materially in bindings tests as they spawn
many nodes over the course of a short test.

Fixes #2232

18 months agoHold a reference to the `Arc<FutureState>` when completing futures
Matt Corallo [Wed, 26 Apr 2023 04:29:59 +0000 (04:29 +0000)]
Hold a reference to the `Arc<FutureState>` when completing futures

This will allow us to pass in that state to the callbacks in the
next commit.

18 months agoAdd a bindings constructor for `lightning-invoice`'s `Sha256` wrapper 2023-04-115-bindings-upstream-2
Matt Corallo [Tue, 25 Apr 2023 17:35:24 +0000 (17:35 +0000)]
Add a bindings constructor for `lightning-invoice`'s `Sha256` wrapper

18 months ago[bindings] Disable BOLT12 builders which require move semantics
Matt Corallo [Tue, 25 Apr 2023 06:10:05 +0000 (06:10 +0000)]
[bindings] Disable BOLT12 builders which require move semantics

18 months agoLimit phantom invoice hints to 3
Fred Walker [Thu, 2 Mar 2023 19:37:16 +0000 (14:37 -0500)]
Limit phantom invoice hints to 3

18 months agoMove phantom route hint selection into its own function
Fred Walker [Thu, 2 Mar 2023 19:34:13 +0000 (14:34 -0500)]
Move phantom route hint selection into its own function

18 months agoMerge pull request #2222 from benthecarman/pub-utxo-resolver
Matt Corallo [Tue, 25 Apr 2023 02:01:06 +0000 (02:01 +0000)]
Merge pull request #2222 from benthecarman/pub-utxo-resolver

18 months agoMerge pull request #2211 from TheBlueMatt/2023-04-0.0.115-cut v0.0.115
Matt Corallo [Tue, 25 Apr 2023 00:20:18 +0000 (00:20 +0000)]
Merge pull request #2211 from TheBlueMatt/2023-04-0.0.115-cut

Cut 0.0.115

19 months agoAdd 0.0.115 CHANGELOG entries 2023-04-0.0.115-cut
Matt Corallo [Fri, 21 Apr 2023 23:28:25 +0000 (23:28 +0000)]
Add 0.0.115 CHANGELOG entries

19 months agoBump crate versions to 0.0.115/invoice 0.23
Matt Corallo [Fri, 21 Apr 2023 23:36:43 +0000 (23:36 +0000)]
Bump crate versions to 0.0.115/invoice 0.23

19 months agoMerge pull request #2004 from tnull/2023-02-add-async-bp-example
Matt Corallo [Mon, 24 Apr 2023 22:38:40 +0000 (22:38 +0000)]
Merge pull request #2004 from tnull/2023-02-add-async-bp-example

Add Tokio example to `process_events_async` docs

19 months agoMerge pull request #2209 from TheBlueMatt/2023-04-better-discon-err-msg
Matt Corallo [Mon, 24 Apr 2023 21:22:06 +0000 (21:22 +0000)]
Merge pull request #2209 from TheBlueMatt/2023-04-better-discon-err-msg

Clarify the error message when we disconnect a peer

19 months agoMerge pull request #2220 from TheBlueMatt/2023-04-dont-ban-cln
Matt Corallo [Mon, 24 Apr 2023 21:15:08 +0000 (21:15 +0000)]
Merge pull request #2220 from TheBlueMatt/2023-04-dont-ban-cln

Don't remove nodes if there's no channel_update for a temp failure

19 months agoAdd Tokio example to `process_events_async` docs
Elias Rohrer [Thu, 2 Feb 2023 20:55:58 +0000 (14:55 -0600)]
Add Tokio example to `process_events_async` docs

19 months agoAdd function for updating network graph with announcement with no UTXO resolver
benthecarman [Mon, 24 Apr 2023 13:10:25 +0000 (08:10 -0500)]
Add function for updating network graph with announcement with no UTXO resolver

19 months agoDon't remove nodes if there's no channel_update for a temp failure 2023-04-dont-ban-cln
Matt Corallo [Sun, 23 Apr 2023 16:17:29 +0000 (16:17 +0000)]
Don't remove nodes if there's no channel_update for a temp failure

Previously, we were requiring any `UPDATE` onion errors to include
a `channel_update`, as the spec mandates[1]. If we see an onion
error which is missing one we treat it as a misbehaving node that
isn't behaving according to the spec and simply remove the node.

Sadly, it appears at least some versions of CLN are such nodes, and
opt to not include `channel_update` at all if they're returning a
`temporary_channel_failure`. This causes us to completely remove
CLN nodes from our graph after they fail to forward our HTLC.

While CLN is violating the spec here, there's not a lot of reason
to not allow it, so we go ahead and do so here, treating it simply
as any other failure by letting the scorer handle it.

[1] The spec says `Please note that the channel_update field is
mandatory in messages whose failure_code includes the UPDATE flag`
however doesn't repeat it in the requirements section so its not
crazy that someone missed it when implementing.

19 months agoRemove unused import in functional_test_utils
Matt Corallo [Mon, 24 Apr 2023 17:57:06 +0000 (17:57 +0000)]
Remove unused import in functional_test_utils

19 months agoFix unused `Secp256k1` context in monitor_tests
Matt Corallo [Sun, 23 Apr 2023 16:54:53 +0000 (16:54 +0000)]
Fix unused `Secp256k1` context in monitor_tests

19 months agoMerge pull request #2221 from TheBlueMatt/2023-04-bp-exit-fast
Matt Corallo [Mon, 24 Apr 2023 16:47:47 +0000 (16:47 +0000)]
Merge pull request #2221 from TheBlueMatt/2023-04-bp-exit-fast

Check for `background-processor` exit condition before+after sleep

19 months agoMerge pull request #2146 from valentinewallace/2023-03-blinded-pathfinding-groundwork
Matt Corallo [Mon, 24 Apr 2023 16:46:15 +0000 (16:46 +0000)]
Merge pull request #2146 from valentinewallace/2023-03-blinded-pathfinding-groundwork

Blinded pathfinding groundwork

19 months agoCheck for `background-processor` exit condition before+after sleep 2023-04-bp-exit-fast
Matt Corallo [Mon, 24 Apr 2023 03:48:42 +0000 (03:48 +0000)]
Check for `background-processor` exit condition before+after sleep

In a synchronous `BackgroundProcessor`, the exit is done by setting
an atomic flag, which is most likely to happen while we're asleep.
Thus, we previously checked for the exit condition after the sleep
(and after we persisted the `ChannelManager`, if required, though
this is no longer required and dates back to when we didn't do a
re-persist after breaking out of the main loop).

For an async `background-processor`, this is also fine, however
because of the relatively longer sleep time, if the exit flag is
set via a sleep check returning true during event processing, we
may end up delaying exit rather substantially.

In order to avoid this, we simply check for the exit condition both
before and immediately after the sleep in `background-processor`.

19 months agoAdd payment hash to `MaybePreimageClaimableHTLC`
Alec Chen [Sun, 23 Apr 2023 04:21:40 +0000 (23:21 -0500)]
Add payment hash to `MaybePreimageClaimableHTLC`

19 months agoAdd payment hash to `MaybeTimeoutClaimableHTLC`
Alec Chen [Sun, 23 Apr 2023 06:03:51 +0000 (01:03 -0500)]
Add payment hash to `MaybeTimeoutClaimableHTLC`

19 months agoAdd payment preimage and hash to `ContentiousClaimable`
Alec Chen [Sun, 23 Apr 2023 06:03:15 +0000 (01:03 -0500)]
Add payment preimage and hash to `ContentiousClaimable`

19 months agoDRY up repeated HTLC `Balance`s in tests
Alec Chen [Sun, 23 Apr 2023 05:37:13 +0000 (00:37 -0500)]
DRY up repeated HTLC `Balance`s in tests

This makes it easier to add a new field on the `Balance` variants.

19 months agoAdd `PartialOrd`, `Ord` to `PaymentHash`, `PaymentPreimage` for tests
Alec Chen [Sun, 23 Apr 2023 04:04:26 +0000 (23:04 -0500)]
Add `PartialOrd`, `Ord` to `PaymentHash`, `PaymentPreimage` for tests

19 months agoMerge pull request #2212 from wpaulino/off-by-one-locktime
Matt Corallo [Sat, 22 Apr 2023 21:54:06 +0000 (21:54 +0000)]
Merge pull request #2212 from wpaulino/off-by-one-locktime

Fix off-by-one finalized transaction locktime

19 months agoFix off-by-one finalized transaction locktime
Wilmer Paulino [Sat, 15 Apr 2023 00:03:51 +0000 (17:03 -0700)]
Fix off-by-one finalized transaction locktime

While these transactions were still valid, we incorrectly assumed that
they would propagate with a locktime of `current_height + 1`, when in
reality, only those with a locktime strictly lower than the next height
in the chain are allowed to enter the mempool.

19 months agoCatch up test nodes to latest block height
Wilmer Paulino [Sun, 16 Apr 2023 05:12:11 +0000 (22:12 -0700)]
Catch up test nodes to latest block height

In a future commit, we plan to correctly enforce that the spending
transaction has a valid locktime relative to the chain for the node
broascasting it in `TestBroadcaster::broadcast_transaction` to. We catch
up these test node instances to their expected height, such that we do
not fail said enforcement.

19 months agoUse current height when generating claims on block_disconnected
Wilmer Paulino [Fri, 21 Apr 2023 22:54:03 +0000 (15:54 -0700)]
Use current height when generating claims on block_disconnected

The `height` argument passed to `OnchainTxHandler::block_disconnected`
represents the height being disconnected, and not the current height.
Due to the incorrect assumption, we'd generate a claim with a locktime
in the future.

Ultimately, we shouldn't be generating claims within
`block_disconnected`. Rather, we should retry the claim at a later block
height, since the bitcoin blockchain does not ever roll back without
connecting a new block. Addressing this is left for future work.

19 months agoMerge pull request #2199 from tnull/2023-04-fix-async-event-processing
Matt Corallo [Sat, 22 Apr 2023 01:45:06 +0000 (01:45 +0000)]
Merge pull request #2199 from tnull/2023-04-fix-async-event-processing

Allow async events processing without holding `total_consistency_lock`

19 months agoMerge pull request #2208 from wpaulino/monitor-rebroadcast-pending-claims
Matt Corallo [Fri, 21 Apr 2023 23:33:52 +0000 (23:33 +0000)]
Merge pull request #2208 from wpaulino/monitor-rebroadcast-pending-claims

Implement pending claim rebroadcast on force-closed channels

19 months agoCall ChainMonitor::rebroadcast_pending_claims on REBROADCAST_TIMER tick
Wilmer Paulino [Mon, 17 Apr 2023 18:52:15 +0000 (11:52 -0700)]
Call ChainMonitor::rebroadcast_pending_claims on REBROADCAST_TIMER tick

This will prompt monitors to rebroadcast/fee-bump their pending claims
on a force-closed channel once on startup and every 30 seconds after.

19 months agoImplement pending claim rebroadcast on force-closed channels
Wilmer Paulino [Mon, 17 Apr 2023 21:17:53 +0000 (14:17 -0700)]
Implement pending claim rebroadcast on force-closed channels

This attempts to rebroadcast/fee-bump each pending claim a monitor is
tracking for a force-closed channel. This is crucial in preventing
certain classes of pinning attacks and ensures reliability if
broadcasting fails. For implementations of `FeeEstimator` that also
support mempool fee estimation, we may broadcast a fee-bumped claim
instead, ensuring we can also react to mempool fee spikes between
blocks.

19 months agoExtend OnchainTxHandler::generate_claim to optionally force feerate bump
Wilmer Paulino [Thu, 20 Apr 2023 21:16:24 +0000 (14:16 -0700)]
Extend OnchainTxHandler::generate_claim to optionally force feerate bump

In the next commit, we plan to extend the `OnchainTxHandler` to retry
pending claims on a timer. This timer may fire with much more frequency
than incoming blocks, so we want to avoid manually bumping feerates
(currently by 25%) each time our fee estimator provides a lower feerate
than before.

19 months agoFix outbound_payment for new Path::blinded_tail
Valentine Wallace [Wed, 19 Apr 2023 17:20:58 +0000 (13:20 -0400)]
Fix outbound_payment for new Path::blinded_tail

19 months agoUpdate changelog for backwards compat
Valentine Wallace [Sun, 9 Apr 2023 21:58:34 +0000 (17:58 -0400)]
Update changelog for backwards compat

19 months agoAccount for Path::blinded_tail when adding a shadow cltv offset
Valentine Wallace [Sun, 9 Apr 2023 20:28:12 +0000 (16:28 -0400)]
Account for Path::blinded_tail when adding a shadow cltv offset

19 months agoTest scoring paths with blinded tails
Valentine Wallace [Wed, 19 Apr 2023 15:56:58 +0000 (11:56 -0400)]
Test scoring paths with blinded tails

19 months agoAccount for Path::blinded_tail in InflightHtlcs::process_path
Valentine Wallace [Sun, 9 Apr 2023 19:57:28 +0000 (15:57 -0400)]
Account for Path::blinded_tail in InflightHtlcs::process_path

19 months agoSupport (de)serializing Path::blinded_tails in HTLCSource
Valentine Wallace [Sun, 9 Apr 2023 19:49:19 +0000 (15:49 -0400)]
Support (de)serializing Path::blinded_tails in HTLCSource

19 months agoSupport (de)serializing Path::blinded_tails in Routes
Valentine Wallace [Sun, 9 Apr 2023 19:47:47 +0000 (15:47 -0400)]
Support (de)serializing Path::blinded_tails in Routes

19 months agoSupport (de)ser for Path::blinded_tails in events
Valentine Wallace [Sun, 9 Apr 2023 19:41:33 +0000 (15:41 -0400)]
Support (de)ser for Path::blinded_tails in events

19 months agoAdd blinded path {metadata} fields to Path, but disallow paying blinded paths for now
Valentine Wallace [Tue, 18 Apr 2023 16:06:35 +0000 (12:06 -0400)]
Add blinded path {metadata} fields to Path, but disallow paying blinded paths for now

19 months agoMerge pull request #2210 from alandotcom/patch-1
Matt Corallo [Fri, 21 Apr 2023 19:01:39 +0000 (19:01 +0000)]
Merge pull request #2210 from alandotcom/patch-1

Fix README typo

19 months agoFix README typo
Alan Cohen [Fri, 21 Apr 2023 17:20:35 +0000 (13:20 -0400)]
Fix README typo

19 months agoClean up handshake timeout disconnection log message 2023-04-better-discon-err-msg
Matt Corallo [Fri, 21 Apr 2023 17:18:04 +0000 (17:18 +0000)]
Clean up handshake timeout disconnection log message

It currently reads "disconnected from peer which hasn't completed
handshake due to ping timeout", which is confusing.

Instead, it will now read "disconnected from peer which hasn't
completed handshake due to ping/handshake timeout"

19 months agoAllow events processing without holding `total_consistency_lock`
Elias Rohrer [Fri, 21 Apr 2023 16:02:54 +0000 (18:02 +0200)]
Allow events processing without holding `total_consistency_lock`

Unfortunately, the RAII types used by `RwLock` are not `Send`, which is
why they can't be held over `await` boundaries. In order to allow
asynchronous events processing in multi-threaded environments, we here
allow to process events without holding the `total_consistency_lock`.

19 months agoReplace Vec<RouteHop> with new Path struct
Valentine Wallace [Sun, 9 Apr 2023 17:50:44 +0000 (13:50 -0400)]
Replace Vec<RouteHop> with new Path struct

This lays groundwork for adding blinded path info to Path

19 months agoAdd utilities for getting a path's final value and cltv delta
Valentine Wallace [Wed, 19 Apr 2023 01:18:44 +0000 (21:18 -0400)]
Add utilities for getting a path's final value and cltv delta

19 months agoMinor Route/RouteHop doc updates
Valentine Wallace [Wed, 5 Apr 2023 01:28:45 +0000 (21:28 -0400)]
Minor Route/RouteHop doc updates

19 months agoClarify the error message when we disconnect a peer
Matt Corallo [Fri, 21 Apr 2023 14:39:01 +0000 (14:39 +0000)]
Clarify the error message when we disconnect a peer

We very regularly receive confusion over the super generic
"Peer sent invalid data or we decided to disconnect due to a
protocol error" message, which doesn't say very much. Usually, we
end up disconnecting because we have a duplicate connection with a
peer, which doesn't merit such a scary message.

Instead, here we clarify the error message to just refer to the
fact that we're disconnecting, and note that its usually a dup
connection in a parenthetical.

19 months agoFix BP prune timer and don't panic on persistence notification failure
Elias Rohrer [Thu, 20 Apr 2023 13:37:11 +0000 (15:37 +0200)]
Fix BP prune timer and don't panic on persistence notification failure

19 months agoMerge pull request #2205 from wpaulino/sign-ecdsa-with-noncedata
Matt Corallo [Thu, 20 Apr 2023 21:53:13 +0000 (21:53 +0000)]
Merge pull request #2205 from wpaulino/sign-ecdsa-with-noncedata

Generate local signatures with additional randomness

19 months agoUse new feature to gate test vectors behind
Wilmer Paulino [Wed, 19 Apr 2023 22:13:35 +0000 (15:13 -0700)]
Use new feature to gate test vectors behind

To match the local signatures found in test vectors, we must make sure
we don't use any additional randomess when generating signatures, as
we'll arrive at a different signature otherwise.

19 months agoSign gossip messages without grinding low R signatures
Wilmer Paulino [Wed, 19 Apr 2023 22:11:34 +0000 (15:11 -0700)]
Sign gossip messages without grinding low R signatures

Gossip messages always use signatures in their compact form, so grinding
for low R signatures is unnecessary.

19 months agoGenerate local signatures with additional randomness
Wilmer Paulino [Wed, 19 Apr 2023 22:08:29 +0000 (15:08 -0700)]
Generate local signatures with additional randomness

Previously, our local signatures would always be deterministic, whether
we'd grind for low R value signatures or not. For peers supporting
SegWit, Bitcoin Core will generally use a transaction's witness-txid, as
opposed to its txid, to advertise transactions. Therefore, to ensure a
transaction has the best chance to propagate across node mempools in the
network, each of its broadcast attempts should have a unique/distinct
witness-txid, which we can achieve by introducing random nonce data when
generating local signatures, such that they are no longer deterministic.

19 months agoImplement EntropySource for InMemorySigner
Wilmer Paulino [Wed, 19 Apr 2023 21:58:57 +0000 (14:58 -0700)]
Implement EntropySource for InMemorySigner

This allows the `InMemorySigner` to produce its own randomness, which we
plan to use when generating signatures in future work.

We can no longer derive `Clone` due to the `AtomicCounter`, so we opt to
implement it manually.

19 months agoMerge pull request #2206 from jkczyz/2023-04-invoice-description
Matt Corallo [Thu, 20 Apr 2023 18:18:28 +0000 (18:18 +0000)]
Merge pull request #2206 from jkczyz/2023-04-invoice-description

Expose description from Invoice's offer/refund

19 months agooutbound_payment: remove unused cltv delta var
Valentine Wallace [Mon, 3 Apr 2023 16:03:42 +0000 (12:03 -0400)]
outbound_payment: remove unused cltv delta var

19 months agoExtract read/write variants from impl_for_vec
Valentine Wallace [Sun, 9 Apr 2023 20:51:55 +0000 (16:51 -0400)]
Extract read/write variants from impl_for_vec

We'll need to (de)serialize vecs of BlindedPaths differently based on whether
we're writing or reading

19 months agoUpdate PaymentParameters::route_hints for blinded paths
Valentine Wallace [Fri, 17 Mar 2023 21:45:12 +0000 (17:45 -0400)]
Update PaymentParameters::route_hints for blinded paths

19 months agoUpdate docs and method names for blinded payment paths
Valentine Wallace [Thu, 16 Mar 2023 02:30:41 +0000 (22:30 -0400)]
Update docs and method names for blinded payment paths

19 months agoMove blinded_path and its utils into a new module
Valentine Wallace [Thu, 16 Mar 2023 01:56:57 +0000 (21:56 -0400)]
Move blinded_path and its utils into a new module

19 months agoExpose description from Invoice's offer/refund
Jeffrey Czyz [Thu, 20 Apr 2023 13:30:18 +0000 (08:30 -0500)]
Expose description from Invoice's offer/refund

This will allow clients like VLS to check the description for an invoice
as part of verification.

19 months agoMerge pull request #1989 from jkczyz/2023-01-stateless-offers
Matt Corallo [Thu, 20 Apr 2023 04:25:21 +0000 (04:25 +0000)]
Merge pull request #1989 from jkczyz/2023-01-stateless-offers

Stateless BOLT 12 message verification

19 months agoDRY up InvoiceFields construction
Jeffrey Czyz [Mon, 17 Apr 2023 23:31:52 +0000 (18:31 -0500)]
DRY up InvoiceFields construction

19 months agoSupport responding to refunds with transient keys
Jeffrey Czyz [Mon, 10 Apr 2023 16:58:14 +0000 (11:58 -0500)]
Support responding to refunds with transient keys

19 months agoExtract keys from Offer::metadata to sign Invoice
Jeffrey Czyz [Wed, 5 Apr 2023 05:04:41 +0000 (00:04 -0500)]
Extract keys from Offer::metadata to sign Invoice

For offers where the signing pubkey is derived, the keys need to be
extracted from the Offer::metadata in order to sign an invoice.
Parameterize InvoiceBuilder such that a build_and_sign method is
available for this situation.

19 months agoDRY up verification of invreq TLV records
Jeffrey Czyz [Tue, 4 Apr 2023 19:59:09 +0000 (14:59 -0500)]
DRY up verification of invreq TLV records

19 months agoStateless verification of Invoice for Refund
Jeffrey Czyz [Mon, 6 Feb 2023 21:30:44 +0000 (15:30 -0600)]
Stateless verification of Invoice for Refund

Stateless verification of Invoice for Offer

Verify that an Invoice was produced from a Refund constructed by the
payer using the payer metadata reflected in the Invoice. The payer
metadata consists of a 128-bit encrypted nonce and possibly a 256-bit
HMAC over the nonce and Refund TLV records (excluding the payer id)
using an ExpandedKey.

Thus, the HMAC can be reproduced from the refund bytes using the nonce
and the original ExpandedKey, and then checked against the metadata. If
metadata does not contain an HMAC, then the reproduced HMAC was used to
form the signing keys, and thus can be checked against the payer id.

19 months agoRefund metadata and payer id derivation
Jeffrey Czyz [Mon, 6 Feb 2023 21:10:07 +0000 (15:10 -0600)]
Refund metadata and payer id derivation

Add support for deriving a transient payer id for each Refund from an
ExpandedKey and a nonce. This facilitates payer privacy by not tying any
Refund to any other nor to the payer's node id.

Additionally, support stateless Invoice verification by setting payer
metadata using an HMAC over the nonce and the remaining TLV records,
which will be later verified when receiving an Invoice response.

19 months agoStateless verification of Invoice for Offer
Jeffrey Czyz [Mon, 30 Jan 2023 20:57:43 +0000 (14:57 -0600)]
Stateless verification of Invoice for Offer

Verify that an Invoice was produced from an InvoiceRequest constructed
by the payer using the payer metadata reflected in the Invoice. The
payer metadata consists of a 128-bit encrypted nonce and possibly a
256-bit HMAC over the nonce and InvoiceRequest TLV records (excluding
the payer id) using an ExpandedKey.

Thus, the HMAC can be reproduced from the invoice request bytes using
the nonce and the original ExpandedKey, and then checked against the
metadata. If metadata does not contain an HMAC, then the reproduced HMAC
was used to form the signing keys, and thus can be checked against the
payer id.

19 months agoFix builder docs in offers module
Jeffrey Czyz [Tue, 21 Mar 2023 01:24:54 +0000 (20:24 -0500)]
Fix builder docs in offers module

19 months agoInvoiceRequest metadata and payer id derivation
Jeffrey Czyz [Mon, 30 Jan 2023 20:56:42 +0000 (14:56 -0600)]
InvoiceRequest metadata and payer id derivation

Add support for deriving a transient payer id for each InvoiceRequest
from an ExpandedKey and a nonce. This facilitates payer privacy by not
tying any InvoiceRequest to any other nor to the payer's node id.

Additionally, support stateless Invoice verification by setting payer
metadata using an HMAC over the nonce and the remaining TLV records,
which will be later verified when receiving an Invoice response.

19 months agoRefactor InvoiceRequestContents fields into a sub-struct
Jeffrey Czyz [Fri, 10 Mar 2023 23:12:12 +0000 (17:12 -0600)]
Refactor InvoiceRequestContents fields into a sub-struct

InvoiceRequestBuilder has a field containing InvoiceRequestContents.
When deriving the payer_id from the remaining fields, a struct is needed
without payer_id as it not optional. Refactor InvoiceRequestContents to
have an inner struct without the payer_id such that
InvoiceRequestBuilder can use it instead.

19 months agoStateless verification of InvoiceRequest
Jeffrey Czyz [Wed, 8 Feb 2023 01:15:44 +0000 (19:15 -0600)]
Stateless verification of InvoiceRequest

Verify that an InvoiceRequest was produced from an Offer constructed by
the recipient using the Offer metadata reflected in the InvoiceRequest.
The Offer metadata consists of a 128-bit encrypted nonce and possibly a
256-bit HMAC over the nonce and Offer TLV records (excluding the signing
pubkey) using an ExpandedKey.

Thus, the HMAC can be reproduced from the offer bytes using the nonce
and the original ExpandedKey, and then checked against the metadata. If
metadata does not contain an HMAC, then the reproduced HMAC was used to
form the signing keys, and thus can be checked against the signing
pubkey.