Commit graph

7087 commits

Author SHA1 Message Date
Matt Corallo
2b14cc40a6
Merge pull request #3017 from jkczyz/2024-04-optional-pubkey
Sending to `Offer` without `signing_pubkey`
2024-04-29 12:05:30 -07:00
Matt Corallo
d00e55077a
Merge pull request #3028 from jkczyz/2024-04-offer-id-followups
Follow-ups to #2970
2024-04-29 11:26:44 -07:00
Jeffrey Czyz
33b6162fd2
Remove InvoiceRequestFields::features
InvoiceRequestFeatures may contain a large, odd bit. Including this in
InvoiceRequestFields, which is in each BlindedPath of a Bolt12Invoice,
could cause the invoice's onion message to exceed the maximum size. The
features are already checked before sending an invoice.
2024-04-29 12:27:39 -05:00
Jeffrey Czyz
7b864425ea
Remove InvoiceRequestFields::amount_msats
Event::PaymentClaimable and Event::PaymentClaimed already contain the
paid amount, so there's no need to included the requested amount in
InvoiceRequestFields.
2024-04-29 12:27:38 -05:00
Jeffrey Czyz
8e562be5d4
Remove PaymentContext from OnionPayload
PaymentContext is already stored in ClaimablePayment via PaymentPurpose,
so there is no need to repeat it in each ClaimableHTLC via OnionPayload.
This avoids cloning the PaymentContext each time an HTLC is received,
other than for the first HTLC for a payment.
2024-04-29 12:27:34 -05:00
Jeffrey Czyz
b7635c4dc2
Bolt12Invoice for Offer without signing_pubkey
When parsing a Bolt12Invoice use both the Offer's signing_pubkey and
paths to determine if it is for an Offer or a Refund. Previously, an
Offer was required to have a signing_pubkey. But now that it is
optional, the Offers paths can be used to make the determination.
Additionally, check that the invoice matches one of the blinded node ids
from the paths' last hops.
2024-04-26 18:14:09 -05:00
Jeffrey Czyz
61e4fcea8e
Add InvoiceRequestTlvStream::paths
Instead of reusing OfferTlvStream::paths, add a dedicated paths TLV to
InvoiceRequestTlvStream such that it can be used in Refund. This allows
for an Offer without a signing_pubkey and still be able to differentiate
whether an invoice is for an offer or a refund.
2024-04-26 18:14:09 -05:00
Jeffrey Czyz
94d5af663d
Allow parsing Offer without signing_pubkey
If an offer has at least one path, it may omit the signing pubkey and
use the blinded node id of the last hop of a path to sign an invoice.
Allow parsing such offers but not yet creating them.
2024-04-26 18:14:09 -05:00
Jeffrey Czyz
520fecf8fc
Optional OfferContents::signing_pubkey
If an Offer contains a path, the blinded_node_id of the path's final hop
can be used as the signing pubkey. Make Offer::signing_pubkey and
OfferContents::signing_pubkey return an Option to support this. Upcoming
commits will implement this behavior.
2024-04-26 18:14:09 -05:00
Gursharan Singh
8701b1bbe3
Merge pull request #3003 from TheBlueMatt/2024-04-2964-followups
#2964 Followups
2024-04-25 13:19:09 -07:00
Matt Corallo
dfb250b976
Merge pull request #3021 from TheBlueMatt/2024-04-drop-blocked-completed-updates
Drop completed blocked `ChannelMonitorUpdate`s on startup
2024-04-25 11:33:18 -07:00
Matt Corallo
eebab4015d
Merge pull request #3004 from TheBlueMatt/2024-04-2761-followups
#2761 Followups
2024-04-25 10:52:12 -07:00
Matt Corallo
c40504a0fc Drop completed blocked ChannelMonitorUpdates on startup
If a user receives a payment preimage for an outbound payment, the
`PaymentSent` event will block any eventual RAA
`ChannelMonitorUpdate` from the same channel, assuming it comes in
before the event can be processed. If this blocking kicks in, but
the flow eventually completes with the RAA `ChannelMonitorUpdate`
being persisted, but the `ChannelManager` is only persisted prior
to the event being handled, on startup we'll have a fully
up-to-date `ChannelMonitor` but a pending, blocked
`ChannelMonitorUpdate`. When the `PaymentSent` event is replayed
we'll end up trying to apply a redundant `ChannelMonitorUpdate`
which will panic.

See the test added in this commit for an implementation of this
situation.

In this commit we fix this issue by simply dropping blocked
`ChannelMonitorUpdate`s the same as we do pending ones.
2024-04-25 15:13:56 +00:00
Elias Rohrer
9a438eea3b
Merge pull request #3015 from tnull/2024-04-sweeper-error-on-persistence-failure
Make `OutputSweeper::track_spendable_outputs` fallible
2024-04-24 16:35:51 +02:00
Elias Rohrer
afb452a813
Make OutputSweeper::track_spendable_outputs fallible
.. as otherwise we might only log an error and continue if we fail to
persist the sweeper state.
2024-04-24 09:46:34 +02:00
Matt Corallo
0e22b1245a
Merge pull request #2981 from dunxen/2024-03-PR2419fixups
Fixups for #2419
2024-04-23 06:48:40 -07:00
Duncan Dean
59a8bd5d65
Add intermediate ConstructedTransaction 2024-04-23 11:33:05 +02:00
Duncan Dean
a04dde7664
Add lower bound segwit input weight estimates 2024-04-23 11:30:59 +02:00
Duncan Dean
a6bee822fb
Add descriptions to test cases 2024-04-23 11:30:33 +02:00
Duncan Dean
62d4952348
Abort if we add a duplicate input 2024-04-23 11:30:00 +02:00
Duncan Dean
ebd57c5d53
Make sent_tx_* fallible and handle errors & simplify counterparty_weight_contributed calc 2024-04-23 11:29:45 +02:00
Duncan Dean
774b048d8f
Check if msg.script.is_witness_program() before checking version 2024-04-23 11:29:24 +02:00
Duncan Dean
4eb70fdf7a
Use HashMaps as, well, HashMaps (don't iter for key match) 2024-04-23 11:29:18 +02:00
Jeffrey Czyz
d6900723df
Remove unnecessary PaymentPreimage clone 2024-04-22 16:43:26 -05:00
Gursharan Singh
d25d55a682
Merge pull request #2990 from TheBlueMatt/2024-04-log-in-flights
Log pending in-flight updates when we are missing a monitor
2024-04-22 10:29:35 -07:00
Matt Corallo
6ab91cb43f Drop the rustup-specific calling in ci/rustfmt.sh
The +rustversion call semantics are specific to rustup and do not
work with standard rust toolchains. However, because rustfmt
formatting differs slightly between stable and our 1.63 target, we
need to keep the +1.63.0 for rustup users.

Thus, here, we check for the presence of a `rustup` command and
pass the "+1.63.0" argument if we find one.
2024-04-22 13:05:53 +00:00
Matt Corallo
eeea0f473e Include channel_keys.rs in the rustfmt list
Since its already formatted and there's not much active work going
on in it.
2024-04-22 13:00:38 +00:00
Matt Corallo
57c8275e0e Only include derive_add_tweak for base key types that use it
Specifically `RevocationBasepoint` has a different derivation, so
shouldn't have a `derive_add_tweak` at all. We also use this
opportunity to link to the `from_basepoint` function in the
`derive_add_tweak` docs.
2024-04-22 13:00:29 +00:00
Matt Corallo
db31f43b87 Word-wrap new doc comment in DelayedPaymentOutputDescriptor 2024-04-22 13:00:29 +00:00
Matt Corallo
9f1c9062db Use Sha256s for tweaks in sign to enforce randomness
We assume that tweaks are the output of a SHA-256 hash function
(and thus that failing to create a private key from the has
negligible probability) in `add_public_key_tweak` and elsewhere.

Thus, we really shouldn't be taking byte arrays in the public API
but rather `Sha256` objects, and communicating in the docs for
`add_public_key_tweak` that we can panic if its not the output of
a hash function, both of which we do here.
2024-04-22 13:00:29 +00:00
Matt Corallo
23d9514259 Simplify and clarify derive_add_tweak documentation 2024-04-22 13:00:29 +00:00
Matt Corallo
fd0c3e4579 Log when a ChannelMonitor's claimable balances set goes empty 2024-04-22 12:24:00 +00:00
Matt Corallo
93e77632d6 Debug-log monitor update starts and completions in ChainMonitor
When a `ChannelMonitor[Update]` persistence completes, we rely on
logging in `ChannelManager` to hear about it. However, this won't
happen at all if there's still pending updates as no `MonitorEvent`
will be generated.

Thus, here, we add logging directly in `ChainMonitor`, ensuring we
can deduce when individual updates completed from debug logs.
2024-04-22 12:21:33 +00:00
Matt Corallo
6ee8d81a58
Merge pull request #3009 from tnull/2024-04-fix-sweeper-typo
Fix typo in `OutputSweeper`
2024-04-22 04:36:41 -07:00
Elias Rohrer
9ac9d8e19f
Fix typo in OutputSweeper
... as 'ouputs' isn't a thing.
2024-04-22 11:29:42 +02:00
Matt Corallo
800f750cc9
Merge pull request #3005 from TheBlueMatt/2024-04-0.0.123-beta
Cut 0.0.123-beta
2024-04-19 07:51:06 -07:00
Matt Corallo
49b375311b Bump crate versions to 0.0.123-beta/invoice 0.31-beta 2024-04-19 01:03:03 +00:00
Wilmer Paulino
2c0fcf21f2
Merge pull request #2761 from yellowred/self_sufficient_psbt
Implement PSBT fields that were missing for a Signer
2024-04-18 17:45:56 -07:00
olegkubrakov
e08f7de3fa Implement Script for Witness and Add Tweak in PSBT.
Adding Witness Script and key tweaks makes
a Partially Signed Bitcoin Transaction the single data
source needed for a Signer to produce valid signatures.
A Signer is not required to be able to generate L2 keys,
e.g delayed payment basepoint.
2024-04-18 16:57:54 -07:00
Matt Corallo
71fef35eb2 Correct ChannelMonitor::is_fully_resolved docs
The block count at which the monitor will become prunable was
changed by an update while the PR was pending but not propagated
to the docs.
2024-04-18 21:43:16 +00:00
Matt Corallo
195e666953
Merge pull request #2964 from jbesraa/prune-stale-chanmonitor
Add `archive_fully_resolved_monitors` to `ChainMonitor`
2024-04-18 14:39:43 -07:00
Gursharan Singh
ae4c35c3e0
Merge pull request #2998 from tnull/2024-04-fix-potential-lock-race-in-CM-write 2024-04-18 13:21:08 -07:00
Jeffrey Czyz
19dae8b193
Merge pull request #3001 from optout21/splicing-feature-bit-with-any
Add splicing feature flag
2024-04-18 14:24:00 -05:00
Gursharan Singh
6264a44259
Merge pull request #2999 from keyuebao/keyue/update-ldk-docs
Update docs for ChannelClosed Event
2024-04-18 10:26:07 -07:00
jbesraa
4b5504366b Add ChainMonitor::archive_fully_resolved_monitor_channels
Archives fully resolved channel monitors by adding them to a backup
  location and removing them from the primary storage & the monitor set.

  This is useful for pruning fully resolved monitors from the monitor
  set and primary storage so they are not reloaded on every new new
  block connection.

  We also add a new function, `archive_persisted_channel` to the
  `Persist` trait that writes the monitor to an archive storage and
  removes it from the primary storage.
2024-04-18 17:12:07 +00:00
jbesraa
9a1649c2b2 Add ChannelMonitor::is_fully_resolved function
Checks if the monitor is fully resolved. Resolved monitor is one that has claimed all of
  its ouputs and balacnes.

  This function returns true only if `get_claimable_balances` has been empty for at least
  2016 blocks.
2024-04-18 15:53:21 +00:00
Matt Corallo
fd237101fd
Merge pull request #2825 from tnull/2024-01-upstream-output-sweeper
Add `OutputSweeper` utility persisting and sweeping spendable outputs
2024-04-18 08:24:47 -07:00
Matt Corallo
56a87ccf7b
Merge pull request #2970 from jkczyz/2024-03-offer-id
Include a `PaymentContext` in `PaymentPurpose`
2024-04-18 08:21:19 -07:00
Elias Rohrer
be8c0d099d
Edit Event::SpendableOutputs docs to mention OutputSweeper 2024-04-18 16:20:03 +02:00
Elias Rohrer
681106d23f
Add basic OutputSweeper test in BP
.. we simply check that the `OutputSweeper` generates a spending tx and
that the `TrackedSpendableOutput` is pruned once it reaches
`ANTI_REORG_DELAY`.
2024-04-18 16:20:03 +02:00