Commit graph

4819 commits

Author SHA1 Message Date
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
7de602a38a
Stop tracking MonitorUpdates from ChainSync in pending_monitor_updates
We no longer need to track them since we no longer hold events for
pending MonitorUpdates resulting from ChainSync.
2024-04-26 16:06:44 -07:00
Gursharan Singh
e084ab26e1
Stop storing last_chain_persist_height
We only used to store last_chain_persist_height to release
events held for more than LATENCY_GRACE_PERIOD_BLOCKS due to
pending monitor update with UpdateOrigin::ChainSync. Since we no
longer pause events for ChainSync persistence, we no longer need to
store last_chain_persist_height.
2024-04-26 16:02:20 -07:00
Gursharan Singh
cb86399f2e
Don't pause events for chainsync persistence
We used to wait on ChannelMonitor persistence to avoid
duplicate payment events. But this can still happen in cases where
ChannelMonitor handed the event to ChannelManager and we did not persist
ChannelManager after event handling.
It is expected to receive payment duplicate events and clients should handle these
events in an idempotent manner. Removing this hold-up of events simplifies
the logic and makes it easier to not persist ChannelMonitors on every block connect.
2024-04-26 14:37:41 -07: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
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
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
Elias Rohrer
9ac9d8e19f
Fix typo in OutputSweeper
... as 'ouputs' isn't a thing.
2024-04-22 11:29:42 +02:00
Lalitmohansharma1
d17e759d02 Allowing user-specified error message during force close channel
In this commit i added additional parameter `error_message` to
`force_close_sending_error`. This parameter will allow users to
configure error message and send to peers during the force closing
of channel.I have also updated the tests for this updated function.
2024-04-20 19:12:59 +05:30
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
a574f8b4a7
Allow delaying generation and broadcasting of spending txs
.. which enables users to batch output spends.
2024-04-18 16:20:03 +02:00
Elias Rohrer
071337a1f1
Add OutputSweeper utility persisting and sweeping spendable outputs
We add a `OutputSweeper` utility that allows to track the state of
spendable output descriptors as emitted by `Event::SpendableOutputs`.

To this end, the `OutputSweeper` persists the necessary information in
our `KVStore` and regularly tries to sweep the spendable outputs,
removing them after reaching threshold confirmations, i.e.,
`ANTI_REORG_DELAY`.
2024-04-18 16:20:03 +02:00
Elias Rohrer
ec956516d1
Add ConfirmationTarget::OutputSpendingFee 2024-04-18 16:20:02 +02:00
Jeffrey Czyz
478911d42a
Update PaymentPurpose's payment_preimage docs
Clarify that payment_preimage should only be used to claim a payment
when handling Event::PaymentClaimable, not Event::PaymentClaimed.
2024-04-18 09:15:25 -05:00
Jeffrey Czyz
8367e02110
Include InvoiceRequest fields in PaymentContext
When receiving a payment, it's useful to know information about the
InvoiceRequest. Include this data in PaymentContext::Bolt12Offer so
users can display information about an inbound payment (e.g., the payer
note).
2024-04-18 09:15:25 -05:00
Jeffrey Czyz
b06b2c787a
Test for PaymentContext in offers_tests.rs 2024-04-18 09:15:23 -05:00
Jeffrey Czyz
0c52ea23dc
Use BOLT 12 PaymentPurpose variants
When constructing a PaymentPurpose in ChannelManager, use the
PaymentContext from OnionPayload to determine which variant to
construct, including those for BOLT 12 payments.
2024-04-18 09:15:23 -05:00
Jeffrey Czyz
54ca54d191
BOLT 12 variants of PaymentPurpose
In order to provide more context in PaymentClaimable and PaymentClaimed
events, introduce new variants of PaymentPurpose for use with BOLT 12
payments. Separate variants are used for offers and refunds. An unknown
variant is used for backwards compatibility and ease of testing, but is
otherwise not publicly constructable.
2024-04-18 09:15:22 -05:00
Jeffrey Czyz
ef3ec8f146
Add PaymentPurpose::is_keysend utility method 2024-04-18 09:15:22 -05:00
Jeffrey Czyz
e74f24332f
Rename InvoicePayment to Bolt11InvoicePayment
PaymentPurpose will be expanded to include BOLT 12 payment context.
Rename the InvoicePayment variant accordinly before new variants are
added.
2024-04-18 09:15:22 -05:00