Commit graph

5846 commits

Author SHA1 Message Date
Matt Corallo
2e113b549d
Merge pull request #2472 from tnull/2023-08-add-kvstore
Replace `KVStorePersister` with `KVStore`
2023-09-07 22:26:03 +00:00
Jeffrey Czyz
44b9c54fa9
Configure BOLT 12 invoice payment retry strategy
Replace a constant three retry attempts for BOLT 12 invoice payments
with a retry strategy specified when creating a pending outbound
payment. This is configured by users in a later commit when constructing
an InvoiceRequest or a Refund.
2023-09-07 16:55:23 -05:00
Jeffrey Czyz
2f6b5d157a
Use u32 instead of usize in Retry::Attempts
An upcoming commit requires serializing Retry, so use a type with a
fixed byte length. Otherwise, using eight bytes to serialize a usize
would fail to read on 32-bit machines.
2023-09-07 16:55:22 -05:00
Jeffrey Czyz
50336b3c7b
Add tests for send_payment_for_bolt12_invoice 2023-09-07 16:55:22 -05:00
Jeffrey Czyz
19c43d0693
pub(crate) visibility for offers/test_utils.rs
The test utilities for Offers are needed for testing message handling in
ChannelManager and OutboundPayments.
2023-09-07 16:55:22 -05:00
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
7576c89adb
Add benchmarking for FilesystemStore
We re-add benchmarking for `FilesystemStore` now that we switched over
to it.
2023-09-07 22:49:22 +02:00
Elias Rohrer
413f9a7de6
Migrate FilesystemPersister tests to FilesystemStore 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
f22d1b6390
Add FilesystemStore
We upstream the `FilesystemStore` implementation, which is backwards
compatible with `lightning-persister::FilesystemPersister`.
2023-09-07 22:49:21 +02:00
Elias Rohrer
c18f43fb07
Add test_utils
We add a utility function needed by upcoming `KVStore` implementation
tests.
2023-09-07 22:49:21 +02:00
Elias Rohrer
931ea2667a
Update lightning-persister crate 2023-09-07 22:49:21 +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
Elias Rohrer
1d01e4747b
Merge pull request #2548 from JosephGoulden/chain-monitor-logging
Downgrade log message "Channel Monitor sync is still in progress" from info to debug
2023-09-05 09:19:27 +02: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
Matt Corallo
ef8945e339
Merge pull request #2543 from optout21/txabort-typo
[minor] Fix wrong msg type in SendTxAbort, typo
2023-09-01 15:13:54 +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