rust-lightning
12 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`.

12 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

12 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.

12 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.

12 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.

12 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`

12 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

12 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.

12 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.

12 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.

12 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

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

12 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`.

12 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

12 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

12 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.

12 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.

12 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.

12 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.

12 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

12 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.

12 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

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

12 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

12 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.

12 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

12 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.

12 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.

12 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.

12 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

12 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.

12 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.

12 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.

12 months agoMerge pull request #2203 from wpaulino/retry-untractable-packages
Matt Corallo [Thu, 20 Apr 2023 02:20:34 +0000 (02:20 +0000)]
Merge pull request #2203 from wpaulino/retry-untractable-packages

Retry untractable packages

12 months agoTlvStream range iterator
Jeffrey Czyz [Wed, 25 Jan 2023 17:34:43 +0000 (11:34 -0600)]
TlvStream range iterator

Add an iterator that yields TlvRecords over a range of a TlvStream.
Useful for verifying that, e.g., an InvoiceRequest was sent in response
to an Offer constructed by the intended recipient.

12 months agoOffer metadata and signing pubkey derivation
Jeffrey Czyz [Wed, 8 Feb 2023 01:13:08 +0000 (19:13 -0600)]
Offer metadata and signing pubkey derivation

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

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

12 months agoMake PackageTemplate::height_timer non-optional
Wilmer Paulino [Sat, 15 Apr 2023 00:03:32 +0000 (17:03 -0700)]
Make PackageTemplate::height_timer non-optional

Now that we leverage a package's `height_timer` even for untractable
packages, there's no need to have it be an `Option` anymore. We aim to
not break compatibility by keeping the deserialization of such as an
`option`, and use the package's `height_original` when not present. This
allows us to retry packages from older `ChannelMonitor` versions that
have had a failed initial package broadcast.

12 months agoUse existing height timer to retry untractable packages
Wilmer Paulino [Sat, 15 Apr 2023 00:02:16 +0000 (17:02 -0700)]
Use existing height timer to retry untractable packages

Untractable packages are those which cannot have their fees updated once
signed, hence why they weren't retried. There's no harm in retrying
these packages by simply re-broadcasting them though, as the fee market
could have spontaneously spiked when we first broadcast it, leading to
our transaction not propagating throughout node mempools unless
broadcast manually.

12 months agoMerge pull request #2127 from TheBlueMatt/2023-03-payment-metadata
Matt Corallo [Wed, 19 Apr 2023 17:17:49 +0000 (17:17 +0000)]
Merge pull request #2127 from TheBlueMatt/2023-03-payment-metadata

Support sending `PaymentMetadata` in HTLCs

12 months agoFix variable name typo 2023-03-payment-metadata
Matt Corallo [Mon, 17 Apr 2023 14:54:32 +0000 (14:54 +0000)]
Fix variable name typo

12 months agoUpdate and clarify the reasons for HTLCDestination::FailedPayment
Matt Corallo [Mon, 10 Apr 2023 23:24:01 +0000 (23:24 +0000)]
Update and clarify the reasons for HTLCDestination::FailedPayment

12 months agoAdd some tests of payment metadata being sent and received
Matt Corallo [Sat, 8 Apr 2023 01:17:51 +0000 (01:17 +0000)]
Add some tests of payment metadata being sent and received

12 months agoExpose the `RecipientOnionFields` in `Event::PaymentClaimable`
Matt Corallo [Fri, 7 Apr 2023 20:48:01 +0000 (20:48 +0000)]
Expose the `RecipientOnionFields` in `Event::PaymentClaimable`

This finally completes the piping of the `payment_metadata` from
from the BOLT11 invoice on the sending side all the way through the
onion sending + receiving ends to the user on the receive events.

12 months agoPipe received `payment_metadata` through the HTLC receipt pipeline
Matt Corallo [Fri, 7 Apr 2023 20:43:54 +0000 (20:43 +0000)]
Pipe received `payment_metadata` through the HTLC receipt pipeline

When we receive an HTLC, we want to pass the `payment_metadata`
through to the `PaymentClaimable` event. This does most of the
internal refactoring required to do so - storing a
`RecipientOnionFields` in the inbound HTLC tracking structs,
including the `payment_metadata`.

In the future this struct will allow us to do MPP keysend receipts
(as it now stores an Optional `payment_secret` for all inbound
payments) as well as custom TLV receipts (as the struct is
extensible to store additional fields and the internal API supports
filtering for fields which are consistent across HTLCs).

12 months ago`continue` automatically after `fail_htlc` in receiving an HTLC
Matt Corallo [Fri, 7 Apr 2023 20:41:53 +0000 (20:41 +0000)]
`continue` automatically after `fail_htlc` in receiving an HTLC

If we receive an HTLC and are processing it a potential MPP part,
we always continue in the per-HTLC loop if we call the `fail_htlc`
macro, thus its nice to actually do the `continue` therein rather
than at the callsites.

12 months agoAdd a debug_assert the newly-documented (but existing) requirement
Matt Corallo [Wed, 19 Apr 2023 14:51:45 +0000 (14:51 +0000)]
Add a debug_assert the newly-documented (but existing) requirement

If we add an entry to `claimable_payments` we have to ensure we
actually accept the HTLC we're considering, otherwise we'll end up
with an empty `claimable_payments` entry.

12 months agoActually test `futures` builds
Elias Rohrer [Tue, 18 Apr 2023 14:27:02 +0000 (16:27 +0200)]
Actually test `futures` builds

Currently the BP `futures` tests rely on `std`. In order to actually
have them run, we should enable `std`, i.e., remove
`--no-default-features`.

12 months agoFix unrelated warnings
Elias Rohrer [Mon, 17 Apr 2023 11:41:24 +0000 (13:41 +0200)]
Fix unrelated warnings

Just two trivial compiler warnings that are unrelated to the changes
made here.

12 months agoMake `claimable_payments` map value a struct, rather than a tuple
Matt Corallo [Fri, 7 Apr 2023 20:19:03 +0000 (20:19 +0000)]
Make `claimable_payments` map value a struct, rather than a tuple

This makes the `claimable_payments` code more upgradable allowing
us to add new fields in the coming commit(s).

12 months agoAdd a `payment_metadata` field to `RecipientOnionFields`
Matt Corallo [Fri, 24 Mar 2023 01:31:14 +0000 (01:31 +0000)]
Add a `payment_metadata` field to `RecipientOnionFields`

This adds the new `payment_metadata` to `RecipientOnionFields`,
passing the metadata from BOLT11 invoices through the send pipeline
and finally copying them info the onion when sending HTLCs.

This completes send-side support for the new payment metadata
feature.

12 months agoDeserialize payment metadata fields in the onion final hop data
Matt Corallo [Fri, 24 Mar 2023 17:07:07 +0000 (17:07 +0000)]
Deserialize payment metadata fields in the onion final hop data

12 months agoSupport setting the new payment metadata field in invoices
Matt Corallo [Tue, 21 Dec 2021 06:03:07 +0000 (06:03 +0000)]
Support setting the new payment metadata field in invoices

This adds support for setting the new payment metadata field in
BOLT11 invoices, using a new type flag on the builder to enforce
transition correctness.

We allow users to set the payment metadata as either optional or
required, defaulting to optional so that invoice parsing does not
fail if the sender does not support payment metadata fields.

12 months agoSupport reading the new `payment_metadata` field in invoices
Matt Corallo [Tue, 21 Dec 2021 05:25:18 +0000 (05:25 +0000)]
Support reading the new `payment_metadata` field in invoices

This adds support for reading the new `PaymentMetadata` BOLT11
invoice field, giving us access to the `Vec<u8>` storing arbitrary
bytes we have to send to the recipient.

12 months agoUnset the optional bit for a feature when setting the required bit
Matt Corallo [Tue, 21 Dec 2021 05:23:51 +0000 (05:23 +0000)]
Unset the optional bit for a feature when setting the required bit

There is no reason to set both, and this currently makes testing
the new BOLT invoice tests slightly harder, so we just unset it.

12 months agoAdd features module-level documentation for missing features
Matt Corallo [Tue, 28 Mar 2023 20:46:11 +0000 (20:46 +0000)]
Add features module-level documentation for missing features

12 months agoAdd another ExpandedKey derivation for Offers
Jeffrey Czyz [Tue, 7 Feb 2023 21:25:36 +0000 (15:25 -0600)]
Add another ExpandedKey derivation for Offers

To support transient signing pubkeys and payer ids for Offers, add
another key derivation to ExpandedKey. Also useful for constructing
metadata for stateless message authentication.

12 months agoAdd missing UnknownRequiredFeatures tests
Jeffrey Czyz [Mon, 6 Feb 2023 18:55:54 +0000 (12:55 -0600)]
Add missing UnknownRequiredFeatures tests

12 months agoCommon offers test_utils module
Jeffrey Czyz [Thu, 2 Feb 2023 23:13:09 +0000 (17:13 -0600)]
Common offers test_utils module

Move utility functions used across all offers modules into a common
module. Avoids duplicating larger utilities such as payment_path across
more than one module.

12 months agoMerge pull request #2198 from TheBlueMatt/2023-04-fewer-disables
Matt Corallo [Tue, 18 Apr 2023 15:56:58 +0000 (15:56 +0000)]
Merge pull request #2198 from TheBlueMatt/2023-04-fewer-disables

Only disable channels ~10 min after disconnect, rather than one

12 months agoOnly disable channels ~10 min after disconnect, rather than one 2023-04-fewer-disables
Matt Corallo [Mon, 17 Apr 2023 23:09:11 +0000 (23:09 +0000)]
Only disable channels ~10 min after disconnect, rather than one

We correctly send out a gossip channel disable update after one
full time tick being down (1-2 minutes). This is pretty nice in
that it avoids nodes trying to route through our nodes too often
if they're down. Other nodes have a much longer time window,
causing them to have much less aggressive channel disables. Sadly,
at one minute it's not super uncommon for tor nodes to get disabled
(once a day or so on two nodes I looked at), and this causes the
lightning terminal scorer to consider the LDK node unstable (even
though it's the one doing the disabling - so is online). This
causes user frustration and makes LDK look bad (even though it's
probably failing fewer payments).

Given this, and future switches to block-based `channel_update`
timestamp fields, it makes sense to go ahead and switch to delaying
channel disable announcements for 10 minutes. This puts us more in
line with other implementations and reduces gossip spam, at the
cost of less reliable payments.

Fixes #2175, at least the currently visible parts.

12 months agoSet `channel_update` disable bit based on staged even for onions
Matt Corallo [Mon, 17 Apr 2023 22:59:18 +0000 (22:59 +0000)]
Set `channel_update` disable bit based on staged even for onions

When generating a `channel_update` either in response to a fee
configuration change or an HTLC failure, we currently poll the
channel to check if the peer's connected when setting the disabled
bit in the `channel_update`. This could cause cases where we set
the disable bit even though the peer *just* disconnected, and don't
generate a followup broadcast `channel_update` with the disabled
bit unset.

While a node generally shouldn't rebroadcast a `channel_update` it
received in an onion, there's nothing inherently stopping them from
doing so. Obviously in the fee-update case we expect the message to
propagate.

Luckily, since we already "stage" disable-changed updates, we can
check the staged state and use that to set the disabled bit in all
`channel_update` cases.

12 months agoMerge pull request #2138 from swilliamson5/replace-our-max-htlcs-constant
Matt Corallo [Mon, 17 Apr 2023 21:58:07 +0000 (21:58 +0000)]
Merge pull request #2138 from swilliamson5/replace-our-max-htlcs-constant

Replace `OUR_MAX_HTLCS` with config knob

12 months agoMerge pull request #2196 from wpaulino/ci-ignore-master-cancel-prev
Matt Corallo [Mon, 17 Apr 2023 21:54:55 +0000 (21:54 +0000)]
Merge pull request #2196 from wpaulino/ci-ignore-master-cancel-prev

Prevent unnecessary CI workflow runs

12 months agoMerge pull request #2195 from TheBlueMatt/2023-04-115-bindings-upstream
Matt Corallo [Mon, 17 Apr 2023 21:25:37 +0000 (21:25 +0000)]
Merge pull request #2195 from TheBlueMatt/2023-04-115-bindings-upstream

12 months agoCancel in-progress jobs on updated push
Wilmer Paulino [Mon, 17 Apr 2023 18:32:53 +0000 (11:32 -0700)]
Cancel in-progress jobs on updated push

At times, PRs can go through multiple pushes in a short amount of time,
spawning a workflow run for each. Most of the time, there's no need to
let the previous jobs running if the code itself has changed (e.g., via
a force push), and we'd benefit from having those slots be used by other
PRs/branches instead.

12 months agoIgnore workflow runs on master branch
Wilmer Paulino [Mon, 17 Apr 2023 17:25:30 +0000 (10:25 -0700)]
Ignore workflow runs on master branch

This master branch is just an alias to the main branch for legacy
reasons, so there's no need to run workflows on both branches.

12 months agoMark the invoice `Network` getter no-export 2023-04-115-bindings-upstream
Matt Corallo [Mon, 17 Apr 2023 17:35:50 +0000 (17:35 +0000)]
Mark the invoice `Network` getter no-export

...as it is redundant with the `currency` getter if we're not using
the rust-bitcoin types natively.

12 months agoMerge pull request #2177 from TheBlueMatt/2023-04-test-function-generics
Wilmer Paulino [Mon, 17 Apr 2023 16:56:18 +0000 (09:56 -0700)]
Merge pull request #2177 from TheBlueMatt/2023-04-test-function-generics

Genericize Test Functions

12 months agoMerge pull request #2191 from TheBlueMatt/2023-04-fix-bucket-deser
Matt Corallo [Mon, 17 Apr 2023 15:11:53 +0000 (15:11 +0000)]
Merge pull request #2191 from TheBlueMatt/2023-04-fix-bucket-deser

Fix deserialization of u16 arrays

12 months agoMerge pull request #2187 from benthecarman/invoice-serde-no-std
Matt Corallo [Mon, 17 Apr 2023 13:28:49 +0000 (13:28 +0000)]
Merge pull request #2187 from benthecarman/invoice-serde-no-std

12 months agoReplace OUR_MAX_HTLCS constant with config knob
Steven Williamson [Wed, 29 Mar 2023 23:45:09 +0000 (19:45 -0400)]
Replace OUR_MAX_HTLCS constant with config knob
holder_max_accepted_htlcs. Set upper bound of 483

Writes an even TLV if the value isn't 50

12 months agoFix deserialization of u16 arrays 2023-04-fix-bucket-deser
Matt Corallo [Sun, 16 Apr 2023 21:57:20 +0000 (21:57 +0000)]
Fix deserialization of u16 arrays

u16 arrays are used in the historical liquidity range tracker.
Previously, we read them without applying the stride multiple,
reading bytes repeatedly and at an offset, corrupting data as we
go.

This applies the correct stride multiplayer fixing the issue.

12 months agoAdd CI test for compile no-std serde lightning-invoice
benthecarman [Sun, 16 Apr 2023 18:17:22 +0000 (13:17 -0500)]
Add CI test for compile no-std serde lightning-invoice

12 months agoFix compiling lightning-invoice for no-std + serde
benthecarman [Sat, 15 Apr 2023 20:38:53 +0000 (15:38 -0500)]
Fix compiling lightning-invoice for no-std + serde

12 months agoMerge pull request #2172 from TheBlueMatt/2023-04-fix-panicy-debug-assert
Matt Corallo [Fri, 14 Apr 2023 15:00:12 +0000 (15:00 +0000)]
Merge pull request #2172 from TheBlueMatt/2023-04-fix-panicy-debug-assert

Remove a race-y debug assertion in new channel update handling

12 months agoMerge pull request #2180 from benthecarman/impl-pk-to-node-id
Matt Corallo [Fri, 14 Apr 2023 14:56:51 +0000 (14:56 +0000)]
Merge pull request #2180 from benthecarman/impl-pk-to-node-id

Implement to and from for PublicKey and NodeId

12 months agoImpl FromStr for NodeId
benthecarman [Thu, 13 Apr 2023 17:54:04 +0000 (12:54 -0500)]
Impl FromStr for NodeId

12 months agoMerge pull request #2179 from benthecarman/use-node-alias-type
Matt Corallo [Thu, 13 Apr 2023 19:46:30 +0000 (19:46 +0000)]
Merge pull request #2179 from benthecarman/use-node-alias-type

Use NodeAlias type in NodeAnnouncement

12 months agoMove some additional test macros into functions 2023-04-test-function-generics
Matt Corallo [Thu, 16 Mar 2023 18:27:52 +0000 (18:27 +0000)]
Move some additional test macros into functions

This marginally reduces the quantity of code compiled in tests
further.

12 months agoIntroduce traits to make test utils generic across the `CM` Holder
Matt Corallo [Fri, 17 Mar 2023 20:50:19 +0000 (20:50 +0000)]
Introduce traits to make test utils generic across the `CM` Holder

In our test utilities, we generally refer to a `Node` struct which
holds a `ChannelManager` and a number of other structs. However, we
use the same utilities in benchmarking, where we have a different
`Node`-like struct. This made moving from macros to functions
entirely impossible, as we end up needing multiple types in a given
context.

Thus, here, we take the pain and introduce some wrapper traits
which encapsulte what we need from `Node`, swapping some of our
macros to functions.

12 months agoUse NodeAlias type in NodeAnnouncement
benthecarman [Wed, 12 Apr 2023 21:09:28 +0000 (16:09 -0500)]
Use NodeAlias type in NodeAnnouncement

12 months agoImplement to and from for PublicKey and NodeId
benthecarman [Thu, 13 Apr 2023 00:14:03 +0000 (19:14 -0500)]
Implement to and from for PublicKey and NodeId

12 months agoDRY the event handling in `ChannelManager`
Matt Corallo [Thu, 30 Mar 2023 23:35:07 +0000 (23:35 +0000)]
DRY the event handling in `ChannelManager`

In the coming commits we'll add some additional complexity to the
event handling flows, so best to DRY them up before we get there.

12 months agoMerge pull request #2142 from alecchendev/2023-03-expose-fail-reason-in-payment-failure
valentinewallace [Tue, 11 Apr 2023 21:26:16 +0000 (17:26 -0400)]
Merge pull request #2142 from alecchendev/2023-03-expose-fail-reason-in-payment-failure

Expose a failure reason in `PaymentFailed`

12 months agoAdd reason to `Event::PaymentFailed`
Alec Chen [Sat, 1 Apr 2023 00:07:57 +0000 (19:07 -0500)]
Add reason to `Event::PaymentFailed`

This includes adding a reason to `PendingOutboundPayment::Abandoned` and
using that reason when pushing an `Event::PaymentFailed`.

12 months agoMerge pull request #2173 from benthecarman/convert-currency-to-netowkr
valentinewallace [Mon, 10 Apr 2023 16:21:16 +0000 (12:21 -0400)]
Merge pull request #2173 from benthecarman/convert-currency-to-netowkr

Convert Network to and from Currency

12 months agoConvert Network to and from Currency
benthecarman [Sun, 9 Apr 2023 02:24:17 +0000 (21:24 -0500)]
Convert Network to and from Currency

12 months agoRemove a race-y debug assertion in new channel update handling 2023-04-fix-panicy-debug-assert
Matt Corallo [Sun, 9 Apr 2023 01:43:39 +0000 (01:43 +0000)]
Remove a race-y debug assertion in new channel update handling

In 6090d9e6a862a2010eb80be56b7449947bc08374 we swapped out old
debug assertions that checked that a lock was `try_lock`able to
test that certain locks weren't held when we needed to be able to
take them in some near branch. However, another slipped in after in
the `ChannelMonitorUpdate` handling rework, which is replaced with
the new debug assertions here.

12 months agoMerge pull request #2161 from benthecarman/prune-stale-channels-rgs
Arik [Sat, 8 Apr 2023 06:26:19 +0000 (23:26 -0700)]
Merge pull request #2161 from benthecarman/prune-stale-channels-rgs

Prune stale channels from network graph after RGS sync.

12 months agoMerge pull request #2158 from TheBlueMatt/2023-04-handle_err_more-check
valentinewallace [Fri, 7 Apr 2023 20:19:27 +0000 (16:19 -0400)]
Merge pull request #2158 from TheBlueMatt/2023-04-handle_err_more-check

Test for extra locks held in `handle_error` unconditionally

12 months agoDefine the `PaymentMetadata` feature to be used in invoices
Matt Corallo [Tue, 21 Dec 2021 05:23:15 +0000 (05:23 +0000)]
Define the `PaymentMetadata` feature to be used in invoices

12 months agoMerge pull request #2023 from futurepaul/fallback-to-address
Jeffrey Czyz [Fri, 7 Apr 2023 19:39:32 +0000 (14:39 -0500)]
Merge pull request #2023 from futurepaul/fallback-to-address

add `Fallback` getter that returns `Address`

12 months agoCreate `PaymentFailureReason` enum
Alec Chen [Thu, 30 Mar 2023 03:30:08 +0000 (22:30 -0500)]
Create `PaymentFailureReason` enum

12 months agoMerge pull request #2170 from TheBlueMatt/2023-04-silent-merge-conflict
Matt Corallo [Fri, 7 Apr 2023 18:27:33 +0000 (18:27 +0000)]
Merge pull request #2170 from TheBlueMatt/2023-04-silent-merge-conflict

Fix silent merge conflict between new test and payment refactor

12 months agoMerge pull request #2162 from jkczyz/2023-04-invoice-hash
Wilmer Paulino [Fri, 7 Apr 2023 17:11:36 +0000 (10:11 -0700)]
Merge pull request #2162 from jkczyz/2023-04-invoice-hash

12 months agoFix silent merge conflict between new test and payment refactor 2023-04-silent-merge-conflict
Matt Corallo [Fri, 7 Apr 2023 16:29:19 +0000 (16:29 +0000)]
Fix silent merge conflict between new test and payment refactor

12 months agoMerge pull request #2148 from TheBlueMatt/2023-04-claim-from-closed
Matt Corallo [Fri, 7 Apr 2023 16:17:25 +0000 (16:17 +0000)]
Merge pull request #2148 from TheBlueMatt/2023-04-claim-from-closed

Allow claiming a payment if a channel with an HTLC has closed

12 months agoMerge pull request #2139 from TheBlueMatt/2023-03-metadata-prefactors
Matt Corallo [Fri, 7 Apr 2023 16:14:30 +0000 (16:14 +0000)]
Merge pull request #2139 from TheBlueMatt/2023-03-metadata-prefactors

Add a new `RecipientOnionFields` and replace `PaymentSecret` with it

12 months agoMerge pull request #2165 from wpaulino/fix-bp-channel-pending-panic-flake
Matt Corallo [Fri, 7 Apr 2023 16:08:34 +0000 (16:08 +0000)]
Merge pull request #2165 from wpaulino/fix-bp-channel-pending-panic-flake

Use signal for handling ChannelPending in test_background_event_handling

12 months agoSplit up comically long error return 2023-04-handle_err_more-check
Matt Corallo [Fri, 7 Apr 2023 04:54:07 +0000 (04:54 +0000)]
Split up comically long error return