Commit graph

3790 commits

Author SHA1 Message Date
Jeffrey Czyz
4e3c031d56
Support paying BOLT 12 invoices
Add a send_payment_for_bolt12_invoice method to OutboundPayments for
initiating payment of a BOLT 12 invoice. This will be called from an
OffersMessageHandler, after which any retries are handled using the
Retryable logic.
2023-09-07 16:55:22 -05:00
Jeffrey Czyz
2852e4cdef
Rename OutboundPayments::retry_payment_internal
It will be used for initial attempts at paying BOLT 12 invoices, so
rename it something that covers both that and retries.
2023-09-07 16:55:22 -05:00
Jeffrey Czyz
283d9b4e03
Refactor OutboundPayments::retry_payment_internal
Consolidate the creation and insertion of onion_session_privs to the
PendingOutboundPayment::Retryable arm. In an upcoming commit, this
method will be reused for an initial BOLT 12 invoice payment. However,
onion_session_privs are created using a different helper.
2023-09-07 16:55:22 -05:00
Jeffrey Czyz
b5169301d8
Add PendingOutboundPayment::InvoiceReceived
When a BOLT 12 invoice has been received, a payment attempt is made and
any errors result in abandoning the PendingOutboundPayment. This results
in generating at PaymentFailed event, which has a PaymentHash. Thus,
when receiving an invoice, transition from AwaitingInvoice to a new
InvoiceReceived state, the latter of which contains a PaymentHash such
the abandon_payment helper can still be used.
2023-09-07 16:54:09 -05:00
Jeffrey Czyz
cbeaeb708f
Test removing abandoned AwaitingInvoice payments 2023-09-07 16:45:12 -05:00
Jeffrey Czyz
fe2244e9cf
Test for removing stale AwaitingInvoice payments 2023-09-07 16:45:11 -05:00
Jeffrey Czyz
7f4c473c88
Move IDEMPOTENCY_TIMEOUT_TICKS to where it is used 2023-09-07 16:45:11 -05:00
Jeffrey Czyz
581ea7c6ed
Add PendingOutboundPayment::AwaitingInvoice
When a BOLT 12 invoice has been requested, in order to guarantee
invoice payment idempotency the future payment needs to be tracked. Add
an AwaitingInvoice variant to PendingOutboundPayment such that only
requested invoices are paid only once. Timeout after a few timer ticks
if a request has not been received.
2023-09-07 16:44:13 -05:00
Elias Rohrer
7a656719af
Add TestStore implementation of KVStore 2023-09-07 22:49:22 +02:00
Elias Rohrer
cc1b505b30
Migrate to KVStore/FilesystemStore
Firstly, we switch our BP over to use `FilesystemStore`, which also gives us test
coverage and ensures the compatibility.

Then, we remove the superseded `KVStorePersister` trait and
the `FilesystemPersister` code.
2023-09-07 22:49:22 +02:00
Elias Rohrer
4305ee4106
Add read_channel_monitors utility
This replaces the `FilesystemPersister::read_channelmonitors` method, as
we can now implement a single utility for all `KVStore`s.
2023-09-07 22:49:22 +02:00
Elias Rohrer
d1405f38bc
Add KVStore interface trait
We upstream the `KVStore` interface trait from LDK Node, which will
replace `KVStorePersister` in the coming commits.

Besides persistence, `KVStore` implementations will also offer to `list`
keys present in a given `namespace` and `read` the stored values.
2023-09-07 22:49:21 +02:00
Jeffrey Czyz
6d0c5f00ba
Add an InvoiceRequestFailed event
When an invoice is requested but either receives an error or never
receives a response, surface an event to indicate to the user that the
corresponding future payment has failed.
2023-09-07 11:08:53 -05:00
Elias Rohrer
b5e959460f
Merge pull request #2134 from jbesraa/add_fromstr_to_netaddress
implement fromstr trait to netaddress
2023-09-07 14:16:25 +02:00
Matt Corallo
82d92ddaa0
Merge pull request #2557 from waterson/stale-monitor-force-close-debugging
Log each condition that was violated for a stale monitor
2023-09-07 04:10:59 +00:00
Chris Waterson
ff8c5dbe16 Fix misspelling, s/and/but/. 2023-09-06 15:10:51 -07:00
Matt Corallo
072a6fffb2
Merge pull request #2555 from tnull/2023-08-have-get-route-take-params
Have `get_route` and `Route` take `RouteParameters`
2023-09-06 20:22:08 +00:00
Elias Rohrer
543674f1da
Improve Route::get_total_amount docs 2023-09-06 19:35:39 +02:00
Elias Rohrer
6082b57097
Include overpaid value in Route::get_total_fees 2023-09-06 19:35:38 +02:00
Elias Rohrer
61cf75265e
Have Route hold RouteParameters 2023-09-06 19:35:38 +02:00
Elias Rohrer
266a3aa915
Have get_route take RouteParameters 2023-09-06 19:35:37 +02:00
jbesraa
4f45cdcad6 Implement from_str trait for NetAddress
- Add fuzz test for `NetAddress` `from_str` function
2023-09-06 19:25:30 +03:00
Chris Waterson
a70aa52b0a Log each condition that was violated for a stale monitor
There are several conditions that can be violated which indicate a stale
monitor. This logs each that doesn't hold.
2023-09-06 08:38:08 -07:00
jbesraa
32a0113fda Fix indent in message_signing.rs 2023-09-06 15:07:25 +03:00
jbesraa
b2d3b94b17 Move zbase32 implementation to base32 file 2023-09-06 15:07:25 +03:00
jbesraa
d736ca8595 Add RFC4648 base32 encode and decode functions 2023-09-06 15:07:25 +03:00
Matt Corallo
eb44d999ae
Merge pull request #1924 from benthecarman/handle-coinbase-funding-channel
Handle if funding output is in a coinbase transaction
2023-09-05 16:56:35 +00:00
Duncan Dean
b28bf0b472
Add test for coinbase funding transactions 2023-09-04 17:13:50 +02:00
benthecarman
9a37135aee
Support creating coinbase funding transactions in tests 2023-09-04 17:13:24 +02:00
benthecarman
a2e01d5648
Handle if funding output is in a coinbase transaction 2023-09-04 17:13:23 +02:00
Joseph Goulden
25c0f489ae Downgrade log message regarding Channel Monitor sync still being in progress from info to debug 2023-09-03 12:48:56 +01:00
Matt Corallo
e9d9711de4
Merge pull request #2522 from sr-gi/202308-set-feature
Adds a set of convenience methods to set non-custom features
2023-09-01 18:25:53 +00:00
Sergi Delgado Segura
992f1029ac Adds a set of convenience methods to set non-custom features
Currently only custom features can be set by specifying the feature bit. Add also the
ability to do so for regular features.
2023-09-01 11:30:21 +02:00
Elias Rohrer
b3612b83c4
Add constructor to RouteParameters 2023-09-01 10:35:42 +02:00
optout
8952446684
Fix wrong msg type in SendTxAbort, typo 2023-09-01 00:00:13 +02:00
Matt Corallo
073f0780f6
Merge pull request #2468 from jkczyz/2023-08-offer-payment-id
Offer outbound payments
2023-08-29 19:29:21 +00:00
Jeffrey Czyz
7a3e06b1e7
Include PaymentId in payer metadata
When receiving a BOLT 12 invoice originating from either an invoice
request or a refund, the invoice should only be paid once. To accomplish
this, require that the invoice includes an encrypted payment id in the
payer metadata. This allows ChannelManager to track a payment when
requesting but prior to receiving the invoice. Thus, it can determine if
the invoice has already been paid.
2023-08-29 11:08:11 -05:00
Jeffrey Czyz
861e0eee9e
Add a ChaCha20 utility for encrypting in place
Similar to ChaCha20::encrypt_single_block only encrypts in-place.
2023-08-29 11:08:11 -05:00
Jeffrey Czyz
4732484520
Add a ChaCha20 utility for encrypting a block
This hides an encryption implementation detail from callers.
2023-08-29 11:08:11 -05:00
Jeffrey Czyz
4fafae0733
Add an encryption key to ExpandedKey for Offers
Metadata such as the PaymentId should be encrypted when included in an
InvoiceRequest or a Refund, as it is user data and is exposed to the
payment recipient. Add an encryption key to ExpandedKey for this purpose
instead of reusing offers_base_key.
2023-08-29 11:08:11 -05:00
Jeffrey Czyz
971cb20d2e
Remove unnecessary #[allow(unused)] 2023-08-29 11:08:11 -05:00
Jeffrey Czyz
21fa551825
Split InvoiceRequest::verify_and_respond_using_derived_keys
InvoiceRequest::verify_and_respond_using_derived_keys takes a payment
hash. To avoid generating one for invoice requests that ultimately
cannot be verified, split the method into one for verifying and another
for responding.
2023-08-29 11:08:04 -05:00
Elias Rohrer
1f2ee2170f
Merge pull request #2531 from optout21/channel-id-breaking
Add ChannelId pending change note; formatting
2023-08-29 13:30:46 +02:00
Matt Corallo
5626e21bea
Merge pull request #2536 from waterson/test-channel-signer
Rename EnforcingSigner to TestChannelSigner
2023-08-28 20:43:08 +00:00
Valentine Wallace
911113814f
Fix BlindedPath::new_for_payment docs 2023-08-28 13:20:11 -04:00
Matt Corallo
2c4f82478e
Merge pull request #2528 from arik-so/arik/2023-08-2470-shorter-term-monitor-locks
Release monitor write lock in between update iterations
2023-08-28 17:07:03 +00:00
Chris Waterson
e38916d838 Rename EnforcingSigner to TestChannelSigner
Since the advent of VLS, EnforcingSigner is only used now for testing.
2023-08-28 09:48:35 -07:00
optout
d5d336f215
Add ChannelId pending change note; formatting 2023-08-28 07:20:23 +02:00
Arik Sosman
f80284cc88
Fix flaky aggregated HTLC revocation test.
Releasing write locks in between monitor updates
requires storing a set of cloned keys to iterate
over. For efficiency purposes, that set of keys
is an actual set, as opposed to array, which means
that the iteration order may not be consistent.

The test was relying on an event array index to
access the revocation transaction. We change that
to accessing a hash map keyed by the txid, fixing
the test.
2023-08-27 10:24:38 -07:00
Arik Sosman
c7a4949a25
Release write lock between monitor update iterations.
Previously, updating block data on a chain monitor
would acquire a write lock on all of its associated
channel monitors and not release it until the loop
completed.

Now, we instead acquire it on each iteration,
fixing #2470.
2023-08-27 10:24:37 -07:00