]> git.bitcoin.ninja Git - rust-lightning/log
rust-lightning
22 months agoser_macros: rename check_tlv_order
Valentine Wallace [Fri, 30 Dec 2022 23:50:26 +0000 (18:50 -0500)]
ser_macros: rename check_tlv_order

.. to disamgibutate from check_encoded_tlv_order

22 months agoProvide a `static_value` TLV field serialization type
Matt Corallo [Thu, 20 Oct 2022 19:41:38 +0000 (19:41 +0000)]
Provide a `static_value` TLV field serialization type

This is useful in the type serialization definition macros to avoid
writing or reading a field at all, simply using a static value on
each reload.

22 months agoParameterize Simple*ChannelManager with DefaultRouter and ProbScorer
Valentine Wallace [Thu, 22 Dec 2022 01:43:02 +0000 (20:43 -0500)]
Parameterize Simple*ChannelManager with DefaultRouter and ProbScorer

22 months agoTake in-flight HTLCs by reference in Router::find_route
Valentine Wallace [Mon, 19 Dec 2022 05:26:58 +0000 (00:26 -0500)]
Take in-flight HTLCs by reference in Router::find_route

Useful in upcoming work when for payment retries.

22 months agoImplement routing against the netgraph in tests
Valentine Wallace [Tue, 29 Nov 2022 20:16:47 +0000 (15:16 -0500)]
Implement routing against the netgraph in tests

22 months agoParameterize ChannelManager by a Router trait
Valentine Wallace [Fri, 28 Oct 2022 15:31:24 +0000 (11:31 -0400)]
Parameterize ChannelManager by a Router trait

This will be used in upcoming work to fetch routes on-the-fly for payment
retries, which will no longer be the responsibility of InvoicePayer.

22 months agoMerge pull request #1934 from TheBlueMatt/2022-12-113-bindings-upstream
Matt Corallo [Tue, 3 Jan 2023 17:06:37 +0000 (17:06 +0000)]
Merge pull request #1934 from TheBlueMatt/2022-12-113-bindings-upstream

Trivial Bindings Updates

22 months agoMerge pull request #1936 from TheBlueMatt/2023-01-in-flight-clone
Matt Corallo [Tue, 3 Jan 2023 16:43:18 +0000 (16:43 +0000)]
Merge pull request #1936 from TheBlueMatt/2023-01-in-flight-clone

`#[derive(Clone)]` for `InFlightHtlcs`

22 months ago`#[derive(Clone)]` for `InFlightHtlcs` 2023-01-in-flight-clone
Matt Corallo [Mon, 2 Jan 2023 01:07:59 +0000 (01:07 +0000)]
`#[derive(Clone)]` for `InFlightHtlcs`

This is useful for bindings, and generally isn't a bad thing for
users to have access to.

23 months agoNo-export `&self` methods on non-cloneable enum(s) 2022-12-113-bindings-upstream
Matt Corallo [Fri, 23 Dec 2022 20:44:24 +0000 (20:44 +0000)]
No-export `&self` methods on non-cloneable enum(s)

Specifically, `OnionMessageContents` is a non-cloneable enum, which
isn't stored opaque so we cannot call `&self` methods on it.
Because its methods aren't critical to the API for now, we simply
no-export them rather than trying to work out an alternative
approach.

23 months agoStore an owned `Score` in `ScorerAccountingForInFlightHtlcs`
Matt Corallo [Thu, 22 Dec 2022 21:58:53 +0000 (21:58 +0000)]
Store an owned `Score` in `ScorerAccountingForInFlightHtlcs`

`ScorerAccountingForInFlightHtlcs` generally stores a `Score`
reference generated by calling `LockableScore::lock`, which
actually returns an arbitrary `Score`. Given `Score` is implemented
directly on lock types, it makes sense to simply hold a fully owned
`Score` in `ScorerAccountingForInFlightHtlcs` rather than a mutable
reference to one.

23 months agoMerge pull request #1929 from valentinewallace/2022-12-outbound-payment-mod-followup
Matt Corallo [Wed, 21 Dec 2022 23:08:58 +0000 (23:08 +0000)]
Merge pull request #1929 from valentinewallace/2022-12-outbound-payment-mod-followup

Outbound payment module follow-up

23 months agooutbound_payment: put method signature closing paren on next line
Valentine Wallace [Tue, 20 Dec 2022 23:20:53 +0000 (18:20 -0500)]
outbound_payment: put method signature closing paren on next line

in long method signatures

23 months agoMerge pull request #1931 from TheBlueMatt/2022-12-1910-followups
Arik [Wed, 21 Dec 2022 19:05:09 +0000 (11:05 -0800)]
Merge pull request #1931 from TheBlueMatt/2022-12-1910-followups

Trivial #1910 Followups

23 months agoFix capitalization broken in 9d7bb73b599a7a9d8468a2f0c54d28f0ce6cf5 2022-12-1910-followups
Matt Corallo [Wed, 21 Dec 2022 16:39:37 +0000 (16:39 +0000)]
Fix capitalization broken in 9d7bb73b599a7a9d8468a2f0c54d28f0ce6cf5

9d7bb73b599a7a9d8468a2f0c54d28f0ce6cf543 broke some capitalization
in docs for `sign_invoice`, which we fix here as well as taking
this opportunity to clean up the `sign_invoice` docs more
generally.

23 months agoClean up use ordering introduced in 9d7bb73b599a7a9d8468a2f0c54d28f
Matt Corallo [Wed, 21 Dec 2022 16:38:28 +0000 (16:38 +0000)]
Clean up use ordering introduced in 9d7bb73b599a7a9d8468a2f0c54d28f

9d7bb73b599a7a9d8468a2f0c54d28f0ce6cf543 moved some code around
unnecessarily, which we fix here.

23 months agoFix cfg(test) indentation
Valentine Wallace [Tue, 20 Dec 2022 23:19:22 +0000 (18:19 -0500)]
Fix cfg(test) indentation

23 months agoMake add_new_pending_payment private to module
Valentine Wallace [Tue, 20 Dec 2022 23:18:17 +0000 (18:18 -0500)]
Make add_new_pending_payment private to module

And expose it in testing only, for safety

23 months agoMerge pull request #1928 from valentinewallace/2022-12-fix-main
valentinewallace [Wed, 21 Dec 2022 00:31:16 +0000 (19:31 -0500)]
Merge pull request #1928 from valentinewallace/2022-12-fix-main

Fix `main` build

23 months agoFix main build
Valentine Wallace [Tue, 20 Dec 2022 22:55:06 +0000 (17:55 -0500)]
Fix main build

23 months agoMerge pull request #1910 from arik-so/2022-12-keys-interface-name-split
Matt Corallo [Tue, 20 Dec 2022 22:19:43 +0000 (22:19 +0000)]
Merge pull request #1910 from arik-so/2022-12-keys-interface-name-split

Split KeysInterface into EntropySource, NodeSigner, and SignerProvider

23 months agoMerge pull request #1923 from valentinewallace/2022-12-outbound-payment-mod
valentinewallace [Tue, 20 Dec 2022 20:40:48 +0000 (15:40 -0500)]
Merge pull request #1923 from valentinewallace/2022-12-outbound-payment-mod

Abstract `ChannelManager` outbound payment logic

23 months agoSplit out KeysInterface into EntropySource, NodeSigner, and SignerProvider.
Arik Sosman [Thu, 8 Dec 2022 23:40:54 +0000 (15:40 -0800)]
Split out KeysInterface into EntropySource, NodeSigner, and SignerProvider.

23 months agoRename send_payment and retry_payment for retries
Valentine Wallace [Mon, 19 Dec 2022 01:34:34 +0000 (20:34 -0500)]
Rename send_payment and retry_payment for retries

Once ChannelManager supports payment retries, it will make more sense for its
current send_payment method to be named send_payment_with_route because
retrying should be the default. Here we get a head start on this by making the
rename in outbound_payment, but not changing the public interface yet.

23 months agoReduce visibility of outbound payment methods
Valentine Wallace [Sun, 18 Dec 2022 23:28:01 +0000 (18:28 -0500)]
Reduce visibility of outbound payment methods

23 months agoStart parameters on a newline if they don't fit
Valentine Wallace [Mon, 19 Dec 2022 20:30:16 +0000 (15:30 -0500)]
Start parameters on a newline if they don't fit

Separating out this commit to keep the main refactor move-only

23 months agoRemove unnecessary mut in finalize_claims
Valentine Wallace [Mon, 19 Dec 2022 20:27:29 +0000 (15:27 -0500)]
Remove unnecessary mut in finalize_claims

23 months agoSwap pending_outbound_payments for OutboundPayments struct
Valentine Wallace [Sun, 18 Dec 2022 18:28:47 +0000 (13:28 -0500)]
Swap pending_outbound_payments for OutboundPayments struct

This allows us to move a lot of outbound payment logic out of ChannelManager
and into the new outbound_payment module, and helps avoid growing
ChannelManager when we add retry logic to it in upcoming work.

23 months agoMove PaymentSendFailure into outbound_payment module
Valentine Wallace [Fri, 16 Dec 2022 21:05:12 +0000 (16:05 -0500)]
Move PaymentSendFailure into outbound_payment module

And re-export it in channelmanager.rs so it can remain public

23 months agoMove PendingOutboundPayment to new outbound_payment module
Valentine Wallace [Fri, 16 Dec 2022 20:32:52 +0000 (15:32 -0500)]
Move PendingOutboundPayment to new outbound_payment module

We want to move all outbound payment-related things to this new module, to help
break up ChannelManager so future payment retries work doesn't increase the
size of ChannelManager.

23 months agoMerge pull request #1922 from wpaulino/avoid-remaining-redundant-commitment-broadcasts
Matt Corallo [Mon, 19 Dec 2022 16:31:30 +0000 (16:31 +0000)]
Merge pull request #1922 from wpaulino/avoid-remaining-redundant-commitment-broadcasts

Avoid redundant broadcast of local commitment transaction

23 months agoMerge pull request #1908 from jkczyz/2022-11-refund
Matt Corallo [Fri, 16 Dec 2022 21:45:34 +0000 (21:45 +0000)]
Merge pull request #1908 from jkczyz/2022-11-refund

BOLT 12 refund encoding and building

23 months agoAvoid redundant broadcast of local commitment transaction
Wilmer Paulino [Tue, 13 Dec 2022 03:00:06 +0000 (19:00 -0800)]
Avoid redundant broadcast of local commitment transaction

This change follows the rationale of commit 62236c7 and addresses the
last remaining redundant local commitment broadcast.

There's no need to broadcast our local commitment transaction if we've
already seen a confirmed one as it'll be immediately rejected as a
duplicate/conflict.

This will also help prevent dispatching spurious events for bumping
commitment and HTLC transactions through anchor outputs since the
dispatch for said events follows the same flow as our usual commitment
broadcast.

23 months agoMerge pull request #1920 from TheBlueMatt/2022-12-rel-date
Matt Corallo [Fri, 16 Dec 2022 18:45:09 +0000 (18:45 +0000)]
Merge pull request #1920 from TheBlueMatt/2022-12-rel-date

Update release date on 0.0.113 in changelog

23 months agoMerge pull request #1903 from TheBlueMatt/2022-12-1867-followups
Matt Corallo [Fri, 16 Dec 2022 18:29:09 +0000 (18:29 +0000)]
Merge pull request #1903 from TheBlueMatt/2022-12-1867-followups

Clarify docs on `provide_channel_parameters`

23 months agoUpdate release date on 0.0.113 in changelog 2022-12-rel-date
Matt Corallo [Fri, 16 Dec 2022 15:57:11 +0000 (15:57 +0000)]
Update release date on 0.0.113 in changelog

23 months agoMerge pull request #1917 from TheBlueMatt/2022-12-0.0.113 v0.0.113
Arik [Fri, 16 Dec 2022 05:37:58 +0000 (21:37 -0800)]
Merge pull request #1917 from TheBlueMatt/2022-12-0.0.113

Cut 0.0.113

23 months agoBump crate versions to 0.0.113/invoice 0.21 2022-12-0.0.113
Matt Corallo [Thu, 15 Dec 2022 17:30:11 +0000 (17:30 +0000)]
Bump crate versions to 0.0.113/invoice 0.21

23 months agoAdd release notes for 0.0.113
Matt Corallo [Wed, 14 Dec 2022 19:38:54 +0000 (19:38 +0000)]
Add release notes for 0.0.113

Fixes #1890

23 months agoOnly do backtrace builds on stable to fix MSRV break in CI
Matt Corallo [Wed, 14 Dec 2022 19:46:19 +0000 (19:46 +0000)]
Only do backtrace builds on stable to fix MSRV break in CI

23 months agoMerge pull request #1918 from TheBlueMatt/2022-12-one-blinded-path
Matt Corallo [Thu, 15 Dec 2022 00:49:41 +0000 (00:49 +0000)]
Merge pull request #1918 from TheBlueMatt/2022-12-one-blinded-path

Unify blinding nomenclature to call them "paths" not "routes".

23 months agoRefund parsing tests
Jeffrey Czyz [Fri, 9 Dec 2022 22:41:16 +0000 (16:41 -0600)]
Refund parsing tests

Tests for checking refund semantics when parsing invoice_request bytes
as defined by BOLT 12.

23 months agoRefund building tests
Jeffrey Czyz [Fri, 9 Dec 2022 19:17:44 +0000 (13:17 -0600)]
Refund building tests

Tests for checking invoice_request message semantics when building a
refund as defined by BOLT 12.

23 months agoBuilder for creating refunds
Jeffrey Czyz [Tue, 29 Nov 2022 23:30:56 +0000 (18:30 -0500)]
Builder for creating refunds

Add a builder for creating refunds given a payer_id and other required
fields. Other settings are optional and duplicative settings will
override previous settings. Building produces a semantically valid
`invoice_request` message representing the refund, which then may be
communicated out of band (e.g., via QR code).

23 months agoRefund parsing from bech32 strings
Jeffrey Czyz [Tue, 23 Aug 2022 22:31:46 +0000 (17:31 -0500)]
Refund parsing from bech32 strings

Implement Bech32Encode for Refund, which supports creating and parsing
QR codes for the merchant-pays-user (i.e., offer for money) flow.

23 months agoRefund encoding and parsing
Jeffrey Czyz [Wed, 21 Sep 2022 14:32:23 +0000 (09:32 -0500)]
Refund encoding and parsing

Define an interface for BOLT 12 refunds (i.e., an `invoice_request`
message without an `offer_node_id`). A refund is more generally an
"offer for money". While it is encoded using the same TLV streams as an
`invoice_request` message, it has different semantics.

23 months agoUpdate references to "blinded route" to "blinded path" 2022-12-one-blinded-path
Matt Corallo [Wed, 14 Dec 2022 21:08:51 +0000 (21:08 +0000)]
Update references to "blinded route" to "blinded path"

Finishing the work from the previous two commits.

23 months agoRename `blinded_route` variables and module to `blinded_path`
Matt Corallo [Wed, 14 Dec 2022 20:49:53 +0000 (20:49 +0000)]
Rename `blinded_route` variables and module to `blinded_path`

Following up on the previous commit, this also renames variables
and the module used to `blinded_path`.

23 months agoUnify blinding nomenclature to call them "paths" not "routes".
Matt Corallo [Wed, 14 Dec 2022 20:45:37 +0000 (20:45 +0000)]
Unify blinding nomenclature to call them "paths" not "routes".

Currently the `onion_message` module exposes the blinded route
object as *both* `BlindedRoute` and `BlindedPath`. This is somewhat
confusing, and given they are really paths, not routes (at least in
the sense that a route could be multi-path, though for OMs they are
not), here we unify to only call them paths.

23 months agoRemove Option from OfferContents::signing_pubkey
Jeffrey Czyz [Tue, 13 Dec 2022 22:05:59 +0000 (16:05 -0600)]
Remove Option from OfferContents::signing_pubkey

Refunds (i.e., `invoice_request` without an `offer`) will have its own
contents type, so OfferContents::signing_pubkey can be required.

23 months agoCorrect docs on `generate_channel_keys` 2022-12-1867-followups
Matt Corallo [Tue, 13 Dec 2022 21:41:49 +0000 (21:41 +0000)]
Correct docs on `generate_channel_keys`

03de0598afd032e9fd5dbbaca0aabc6a367ce4f5 appeared to revert updated
docs due to a rebase error. This reverts the docs on
`generate_channel_keys` to the state they were in prior to that
commit, with one additional doc.

23 months agoClarify docs on `provide_channel_parameters`
Matt Corallo [Tue, 6 Dec 2022 18:16:46 +0000 (18:16 +0000)]
Clarify docs on `provide_channel_parameters`

Its very confusing to say that LDK will call
`provide_channel_parameters` more than once - its true for a
channel, but not for a given instance. Instead, phrase the docs
with reference to a specific instance, which is much clearer.

23 months agoMerge pull request #1915 from TheBlueMatt/2022-12-jit-reload-consistency
Matt Corallo [Tue, 13 Dec 2022 21:08:45 +0000 (21:08 +0000)]
Merge pull request #1915 from TheBlueMatt/2022-12-jit-reload-consistency

Drop forwarded HTLCs which were still pending at persist-time

23 months agoDrop forwarded HTLCs which were still pending at persist-time 2022-12-jit-reload-consistency
Matt Corallo [Tue, 13 Dec 2022 03:27:23 +0000 (03:27 +0000)]
Drop forwarded HTLCs which were still pending at persist-time

If, after forwarding an intercepted payment to our counterparty, we
restart with a ChannelMonitor update having been persisted, but the
corresponding ChannelManager update not having been persisted,
we'll still have the intercepted HTLC in the
`pending_intercepted_htlcs` map on start (and potentially a pending
`HTLCIntercepted` event). This will cause us to allow the user to
handle the forwarded HTLC twice, potentially double-forwarding it.

This builds on 0bb87ddad71d2e33199ebad79e9f709f869f2130, which
provided a preemptive fix for the general relay case (though it was
not an actual issue at the time). We simply check for the HTLCs
having been forwarded on startup and remove them from the map.

Fixes #1858

23 months agoRemove unused fetch in `lightning_invoice` tests.
Matt Corallo [Tue, 13 Dec 2022 01:03:18 +0000 (01:03 +0000)]
Remove unused fetch in `lightning_invoice` tests.

23 months agoMerge pull request #1894 from ssbright/2022-12-custom_payment_hash
Matt Corallo [Tue, 13 Dec 2022 00:00:32 +0000 (00:00 +0000)]
Merge pull request #1894 from ssbright/2022-12-custom_payment_hash

Add invoice constructor with custom payment hash

23 months agoMerge pull request #1900 from tnull/2022-12-improve-confirm-docs
Matt Corallo [Mon, 12 Dec 2022 23:22:52 +0000 (23:22 +0000)]
Merge pull request #1900 from tnull/2022-12-improve-confirm-docs

Improve `Confirm` docs

23 months agoMerge pull request #1892 from tnull/2022-12-spendableoutputdescriptor-doccs
Matt Corallo [Mon, 12 Dec 2022 22:45:00 +0000 (22:45 +0000)]
Merge pull request #1892 from tnull/2022-12-spendableoutputdescriptor-doccs

Clean up docs in `keysinterface.rs`

23 months agoMerge pull request #1907 from TheBlueMatt/2022-12-abandon-crash-reset
Matt Corallo [Mon, 12 Dec 2022 22:16:43 +0000 (22:16 +0000)]
Merge pull request #1907 from TheBlueMatt/2022-12-abandon-crash-reset

Note that abandon_payment does not persist the state update in docs

23 months agoAdd invoice constructor with custom payment hash
ssbright [Mon, 12 Dec 2022 21:08:38 +0000 (13:08 -0800)]
Add invoice constructor with custom payment hash

23 months agoImprove `Confirm` docs
Elias Rohrer [Mon, 5 Dec 2022 16:55:47 +0000 (17:55 +0100)]
Improve `Confirm` docs

23 months agoClean up docs in `keysinterface.rs`
Elias Rohrer [Thu, 1 Dec 2022 14:17:57 +0000 (15:17 +0100)]
Clean up docs in `keysinterface.rs`

23 months agoNote that abandon_payment does not persist the state update in docs 2022-12-abandon-crash-reset
Matt Corallo [Thu, 8 Dec 2022 00:33:15 +0000 (00:33 +0000)]
Note that abandon_payment does not persist the state update in docs

If a user calls `abandon_payment`, then restarts without freshly
persisting the `ChannelManager`, the payment will still be pending
on restart. This was unclear from the docs (and the docs seemed to
imply otherwise). Because this doesn't materially impact the
usability of `abandon_payment` (users shouldn't be called
`retry_payment` on an abandoned one anyway), we simply document it.

Fixes #1804.

23 months agoMerge pull request #1904 from TheBlueMatt/2022-12-1825-followups
Matt Corallo [Mon, 12 Dec 2022 17:58:21 +0000 (17:58 +0000)]
Merge pull request #1904 from TheBlueMatt/2022-12-1825-followups

Trivial Followups to #1825

23 months agoMerge pull request #1738 from jkczyz/2022-09-invoice-request
valentinewallace [Mon, 12 Dec 2022 16:25:07 +0000 (11:25 -0500)]
Merge pull request #1738 from jkczyz/2022-09-invoice-request

BOLT 12 `invoice_request` encoding and building

23 months agoMerge pull request #1906 from wpaulino/prevent-downgrade-from-anchors
Matt Corallo [Mon, 12 Dec 2022 03:11:30 +0000 (03:11 +0000)]
Merge pull request #1906 from wpaulino/prevent-downgrade-from-anchors

Use even types for opt_anchors

23 months agoMerge pull request #1886 from TheBlueMatt/2022-11-claim-relock
Matt Corallo [Mon, 12 Dec 2022 03:10:38 +0000 (03:10 +0000)]
Merge pull request #1886 from TheBlueMatt/2022-11-claim-relock

Relock `channel_state` in for each HTLC in `claim_funds` and lay the groundwork for async event generation

23 months agoCheck entire TLV stream instead of by field
Jeffrey Czyz [Fri, 9 Dec 2022 20:45:56 +0000 (14:45 -0600)]
Check entire TLV stream instead of by field

This causes a compilation error if a new field is added but missed in
the tests.

23 months agoAdd BOLT 12 merkle root test for `invoice_request`
Jeffrey Czyz [Mon, 28 Nov 2022 16:20:07 +0000 (11:20 -0500)]
Add BOLT 12 merkle root test for `invoice_request`

A BOLT 12 test vector uses an `invoice_request` message that has a
currency, which aren't supported, so using OfferBuilder::build_unchecked
is required to avoid a panic.

23 months agoInvoice request parsing tests
Jeffrey Czyz [Wed, 16 Nov 2022 22:13:52 +0000 (16:13 -0600)]
Invoice request parsing tests

Tests for checking invoice_request message semantics when parsing bytes
as defined by BOLT 12.

23 months agoInvoice request building tests
Jeffrey Czyz [Fri, 11 Nov 2022 03:12:58 +0000 (21:12 -0600)]
Invoice request building tests

Tests for checking invoice_request message semantics when building as
defined by BOLT 12.

23 months agoBuilder for creating invoice requests
Jeffrey Czyz [Wed, 31 Aug 2022 15:19:44 +0000 (10:19 -0500)]
Builder for creating invoice requests

Add a builder for creating invoice requests for an offer given a
payer_id. Other settings may be optional depending on the offer and
duplicative settings will override previous settings. Building produces
a semantically valid `invoice_request` message for the offer, which then
can be signed for the payer_id.

23 months agoInvoice request raw byte encoding and decoding
Jeffrey Czyz [Tue, 23 Aug 2022 22:31:46 +0000 (17:31 -0500)]
Invoice request raw byte encoding and decoding

When reading an offer, an `invoice_request` message is sent over the
wire. Implement Writeable for encoding the message and TryFrom for
decoding it by defining in terms of TLV streams. These streams represent
content for the payer metadata (0), reflected `offer` (1-79),
`invoice_request` (80-159), and signature (240).

23 months agoMerkle root hash computation
Jeffrey Czyz [Tue, 9 Aug 2022 22:37:02 +0000 (17:37 -0500)]
Merkle root hash computation

Offers uses a merkle root hash construction for signature calculation
and verification. Add a submodule implementing this so that it can be
used when parsing and signing invoice_request and invoice messages.

23 months agoSchnorr Signature serialization
Jeffrey Czyz [Fri, 24 Jun 2022 21:18:29 +0000 (16:18 -0500)]
Schnorr Signature serialization

BOLT 12 uses Schnorr signatures for signing offers messages, which need
to be serialized.

23 months agoInvoice request message interface and data format
Jeffrey Czyz [Mon, 19 Sep 2022 21:57:46 +0000 (16:57 -0500)]
Invoice request message interface and data format

Define an interface for BOLT 12 `invoice_request` messages. The
underlying format consists of the original bytes and the parsed
contents.

The bytes are later needed when constructing an `invoice` message. This
is because it must mirror all the `offer` and `invoice_request` TLV
records, including unknown ones, which aren't represented in the
contents.

The contents will be used in `invoice` messages to avoid duplication.
Some fields while required in a typical user-pays-merchant flow may not
be necessary in the merchant-pays-user flow (e.g., refund, ATM).

23 months agoAdd second TODO when claiming to mirror the existing TODO on claim fail 2022-11-claim-relock
Matt Corallo [Tue, 6 Dec 2022 21:19:29 +0000 (21:19 +0000)]
Add second TODO when claiming to mirror the existing TODO on claim fail

23 months agoDrop unused link in `claim_funds`
Matt Corallo [Tue, 6 Dec 2022 21:13:35 +0000 (21:13 +0000)]
Drop unused link in `claim_funds`

23 months agoDrop now-unused `ClaimFundsFromHop` enum and replace with an `Err`
Matt Corallo [Wed, 30 Nov 2022 21:48:46 +0000 (21:48 +0000)]
Drop now-unused `ClaimFundsFromHop` enum and replace with an `Err`

23 months agoHandle claim result event generation in claim_funds_from_hop
Matt Corallo [Tue, 6 Dec 2022 21:01:50 +0000 (21:01 +0000)]
Handle claim result event generation in claim_funds_from_hop

Currently `claim_funds` and `claim_funds_internal` call
`claim_funds_from_hop` and then surface and `Event` to the user
informing them of the forwarded/claimed payment based on it's
result. In both places we assume that a claim "completed" even if
a monitor update is being done async.

Instead, here we push that event generation through a
`MonitorUpdateCompletionAction` and a call to
`handle_monitor_update_completion_action`. This will allow us to
hold the event(s) until async monitor updates complete in the
future.

23 months agoDon't hold `channel_state` lock for entire duration of claim_funds
Matt Corallo [Wed, 30 Nov 2022 05:47:16 +0000 (05:47 +0000)]
Don't hold `channel_state` lock for entire duration of claim_funds

When `claim_funds` has to claim multiple HTLCs as a part of a
single MPP payment, it currently does so holding the
`channel_state` lock for the entire duration of the claim loop.
Here we swap that for taking the lock once for each HTLC. This
allows us to be more flexible with locks going forward, and
ultimately isn't a huge change - if our counterparty intends to
force-close a channel, us choosing to ignore it by holding the
`channel_state` lock for the duration of the claim isn't going to
result in a commitment update, it will just result in the preimage
already being in the `ChannelMonitor`.

23 months agoHandle closed-chan HTLC claims in `claim_funds_from_hop`
Matt Corallo [Tue, 6 Dec 2022 20:46:02 +0000 (20:46 +0000)]
Handle closed-chan HTLC claims in `claim_funds_from_hop`

Currently `claim_funds` does all HTLC claims in one `channel_state`
lock, ensuring that we always make claims from channels which are
open. It can thus avoid ever having to generate a
`ChannelMonitorUpdate` containing a preimage for a closed channel,
which we only do in `claim_funds_internal` (for forwarded payments).

In the next commit we'll change the locking of
`claim_funds_from_hop` so that `claim_funds` is no longer under a
single lock but takes a lock for each claim. This allows us to be
more flexible with locks going forward, and ultimately isn't a huge
change - if our counterparty intends to force-close a channel, us
choosing to ignore it by holding the `channel_state` lock for the
duration of the claim isn't going to result in a commitment update,
it will just result in the preimage already being in the
`ChannelMonitor`.

23 months agoAdd support for handling "actions" after a monitor update completes
Matt Corallo [Wed, 30 Nov 2022 18:37:12 +0000 (18:37 +0000)]
Add support for handling "actions" after a monitor update completes

This adds a new enum, `MonitorUpdateCompletionAction` and a method
to execute the "actions". They are intended to be done once a
(potentially-async) `ChannelMonitorUpdate` persistence completes,
however this behavior will be implemented in a future PR. For now,
this adds the relevant infrastructure which will allow us to
prepare `claim_funds` for better monitor async handling.

23 months agoStore pending claims awaiting monitor update in a separate map
Matt Corallo [Tue, 6 Dec 2022 18:33:52 +0000 (18:33 +0000)]
Store pending claims awaiting monitor update in a separate map

In the next commits we'll move to generating `PaymentClaimed`
events while handling `ChannelMonitorUpdate`s rather than directly
in line. Thus, as a prerequisite, here we move to storing the info
required to generate the `PaymentClaimed` event in a separate map.

Note that while this does introduce a new map which is written as
an even value which users cannot opt out of, the map is only filled
in when users use the asynchronous `ChannelMonitor` updates and
after a future PR. As these are still considered beta, breaking
downgrades for such users is considered acceptable in the future PR
(which will likely be one LDK version later).

23 months agoSlightly clarify comment on safety of only processing HTLCs once 2022-12-1825-followups
Matt Corallo [Wed, 7 Dec 2022 23:17:31 +0000 (23:17 +0000)]
Slightly clarify comment on safety of only processing HTLCs once

23 months agoEnsure `Event::BumpTransaction` is forwards-compatible
Matt Corallo [Wed, 7 Dec 2022 00:41:07 +0000 (00:41 +0000)]
Ensure `Event::BumpTransaction` is forwards-compatible

`Event`s with an odd type are ignored by older versions of LDK,
however they rely on the `write_tlv_fields` call to know how many
bytes to read and discard. We were missing that call in our writing
of `Event::BumpTransaction`, which we add here.

23 months agoUse `Witness::push_bitcoin_signature` where relevant
Matt Corallo [Wed, 7 Dec 2022 00:40:38 +0000 (00:40 +0000)]
Use `Witness::push_bitcoin_signature` where relevant

23 months agoDrop excess mut on `OnchainTxHandler::generate_external_htlc_claim`
Matt Corallo [Wed, 7 Dec 2022 00:40:17 +0000 (00:40 +0000)]
Drop excess mut on `OnchainTxHandler::generate_external_htlc_claim`

23 months agoDRY the comparison blocks in `update_claims_view_from_matched_txn`
Matt Corallo [Wed, 7 Dec 2022 00:30:43 +0000 (00:30 +0000)]
DRY the comparison blocks in `update_claims_view_from_matched_txn`

In `update_claims_view_from_matched_txn` we have two different
tx-equivalence checks which do the same thing - both check that the
tx which appeared on chain spent all of the outpoints which we
intended to spend in a given package. While one is more effecient
than the other (but only usable in a subset of cases), the
difference between O(N) and O(N^2) when N is 1-5 is trivial.

Still, it is possible we hit this code with just shy of 900 HTLC
outputs in a channel, and a transaction with a ton of inputs.

While having to spin through a few million entries if our
counterparty wastes a full block isn't really a big deal, we go
ahead and use a sorted vec and binary searches because its trivial.

23 months agoUse `PackageId` rather than `Txid` in `OnchainEvent::Claim`
Matt Corallo [Wed, 7 Dec 2022 00:29:11 +0000 (00:29 +0000)]
Use `PackageId` rather than `Txid` in `OnchainEvent::Claim`

In 19daccf7fb5ea81c8d235c1628a91efe0aa07b96, a `PackageId` type was
added to differentiate between an opaque Id for packages and the
`Txid` type which was being used for that purpose. It, however,
failed to also replace the single inner field in
`OnchainEvent::Claim` which was also a package ID. We do so here.

23 months agoUse even types for opt_anchors
Wilmer Paulino [Wed, 7 Dec 2022 18:30:25 +0000 (10:30 -0800)]
Use even types for opt_anchors

This prevents downgrading to older versions of LDK that are not capable
of supporting anchor channels when the field is serialized (i.e.,
opt_anchors is `Some`).

23 months agoMerge pull request #1863 from TheBlueMatt/2022-11-holding-cell-batch-update
Matt Corallo [Wed, 7 Dec 2022 17:52:04 +0000 (17:52 +0000)]
Merge pull request #1863 from TheBlueMatt/2022-11-holding-cell-batch-update

Lean on the holding cell when batch-forwarding/failing HTLCs

23 months agoMerge pull request #1825 from wpaulino/anchors-bump-htlc-resolution-event
Matt Corallo [Wed, 7 Dec 2022 05:51:27 +0000 (05:51 +0000)]
Merge pull request #1825 from wpaulino/anchors-bump-htlc-resolution-event

Introduce new BumpTransactionEvent variant HTLCResolution

23 months agoExtend BaseSign with HTLC output signing support for external claims
Wilmer Paulino [Wed, 30 Nov 2022 22:05:02 +0000 (14:05 -0800)]
Extend BaseSign with HTLC output signing support for external claims

23 months agoYield BumpHTLCResolution events
Wilmer Paulino [Wed, 31 Aug 2022 19:03:35 +0000 (12:03 -0700)]
Yield BumpHTLCResolution events

23 months agoExpose HTLC transaction construction helpers
Wilmer Paulino [Wed, 30 Nov 2022 22:03:45 +0000 (14:03 -0800)]
Expose HTLC transaction construction helpers

23 months agoRename set_equality within update_claims_view_from_matched_txn
Wilmer Paulino [Tue, 22 Nov 2022 01:22:06 +0000 (17:22 -0800)]
Rename set_equality within update_claims_view_from_matched_txn

23 months agoGenerate ClaimEvent for HolderHTLCOutput inputs from anchor channels
Wilmer Paulino [Wed, 30 Nov 2022 22:03:26 +0000 (14:03 -0800)]
Generate ClaimEvent for HolderHTLCOutput inputs from anchor channels

23 months agoIntroduce internal package ID to track pending claims
Wilmer Paulino [Mon, 28 Nov 2022 15:47:44 +0000 (07:47 -0800)]
Introduce internal package ID to track pending claims

Now that our txids will no longer be stable for package claims that
require external funds to be allocated, we transition to a 32-byte array
identifier to remain compatible with them.

23 months agoSupport HolderHTLCOutput inputs from anchor channels
Wilmer Paulino [Wed, 31 Aug 2022 18:56:59 +0000 (11:56 -0700)]
Support HolderHTLCOutput inputs from anchor channels