Commit graph

2295 commits

Author SHA1 Message Date
Matt Corallo
b9a934ee92 Deny broken doc links in lightning-invoice as well 2021-04-30 17:33:05 +00:00
Matt Corallo
8cde7e8db9 Fix merge conflicts between #898 and #895. 2021-04-30 17:32:36 +00:00
Matt Corallo
47cb2939c8
Merge pull request #898 from jkczyz/2021-04-invoice-expiry
Require min_final_cltv_expiry in invoices
2021-04-30 17:25:59 +00:00
Matt Corallo
3b67be235a
Merge pull request #895 from valentinewallace/invoice-chanman-utility
Invoice chanman utility
2021-04-29 23:55:37 +00:00
Valentine Wallace
4c7be7e137
Add utility to create an invoice using the ChannelManager
This also allows the ChannelManager to track information for inbound payments
to check the PaymentSecret on receive.
2021-04-29 19:13:36 -04:00
Valentine Wallace
feb882f6a4
Move invoice signing behind KeysInterface 2021-04-29 18:39:47 -04:00
Valentine Wallace
f24bbd63cc
Move PaymentPreimage+PaymentHash+PaymentSecret to top-level ln module 2021-04-29 18:39:47 -04:00
Valentine Wallace
6f5d81631a
Make _test_utils depend on bitcoinconsensus feature 2021-04-29 18:39:47 -04:00
Valentine Wallace
9529226adf
invoice: swap PaymentSecret for ChannelManager's PaymentSecret 2021-04-29 18:39:47 -04:00
Matt Corallo
3be185ad13
Merge pull request #905 from TheBlueMatt/2021-04-mention-invoice-storage-docs
Mention storage req for users with a public invoice generation API
2021-04-29 22:26:12 +00:00
Matt Corallo
f02910f81e Mention storage req for users with a public invoice generation API 2021-04-29 22:02:48 +00:00
Matt Corallo
38a544eafd
Merge pull request #904 from lightning-signer/no-send-sync
Remove Send and Sync from core crate
2021-04-29 22:02:01 +00:00
Jeffrey Czyz
aafa741f29
Test default invoice field values 2021-04-29 14:08:42 -07:00
Jeffrey Czyz
383ebc0406
Require min_final_cltv_expiry in invoice 2021-04-29 14:08:41 -07:00
Jeffrey Czyz
e0ec016817
Use default for invoice's min_final_cltv_expiry 2021-04-29 14:08:41 -07:00
Jeffrey Czyz
25a3e041d9
Use constant for invoice's default expiry value 2021-04-29 14:04:12 -07:00
Devrandom
ec35fe62a1 Remove Send and Sync from core crate 2021-04-29 21:07:28 +02:00
Matt Corallo
cb0b4bfd76
Merge pull request #903 from TheBlueMatt/2021-04-invoice-bindings
Prepare lightning-invoice for export in C
2021-04-29 18:57:37 +00:00
Matt Corallo
c9afea2d16 Drop redundant generic parameter bounds on ChainMonitor trait impls
The ChannelSigner bounds are specified both in `impl<>` and in the
`where` clause, which the C bindings generator doesn't like. There
is no reason to have them specified twice.
2021-04-29 18:36:51 +00:00
Matt Corallo
2484c1afc2 Add no-export tags for lightning-invoice where we can't map to C 2021-04-29 15:48:16 +00:00
Matt Corallo
3d3147fe83 Rename lightning_invoice::Signature to InvoiceSignature
This prevents aliasing the global secp256k1::Signature name in C
bindings and also makes it a little more explicit that the object
is different from other signature types.
2021-04-29 15:48:16 +00:00
Matt Corallo
236342332e Do not return a reference to a u64 in rust-lightning-invoices
There is generally never a reason to return a non-mutable reference
to a u64 vs just copying it, same applies here. It makes the API
slightly less consistent, but is easier to map in bindings and just
makes more sense.
2021-04-29 15:48:16 +00:00
Matt Corallo
0725098eef
Merge pull request #900 from lightning-signer/init-asap
Send Init message immediately after handshake even if not initiator
2021-04-29 00:26:13 +00:00
Matt Corallo
6494e53a8f
Merge pull request #902 from TheBlueMatt/2021-04-fix-fuzz-test
Fix fuzz secp patch by bumping the rust-secp version number in patch
2021-04-29 00:24:40 +00:00
Matt Corallo
a8bc8fb349
Merge pull request #893 from TheBlueMatt/2021-04-features-chanman
Require payment secrets and track them in ChannelManager
2021-04-28 19:59:33 +00:00
Matt Corallo
615ef7d6f8 Add a const and docs for the min min_final_cltv_expiry we allow 2021-04-28 15:30:25 -04:00
Matt Corallo
fd0ebcf8ec Add some simple tests of payment secret tracking 2021-04-28 15:30:25 -04:00
Matt Corallo
f9a6cb2a8b Fail PendingInboundPayments after their expiry time is reached 2021-04-28 15:30:25 -04:00
Matt Corallo
3b8ac139ba Give users who use get_payment_secret_preimage the PaymentPreimage
For users who get PaymentPreimages via
`get_payment_secret_preimage`, they need to provide the
PaymentPreimage back in `claim_funds` but they aren't actually
given the preimage anywhere.

This commit gives users the PaymentPreimage in the
`PaymentReceived` event.
2021-04-28 15:30:25 -04:00
Matt Corallo
ecaeddca47 Make the PaymentSecret in PaymentReceived events non-Optional 2021-04-28 15:30:25 -04:00
Matt Corallo
5e968114b6 Drop the amount parameter to claim_funds
Like the payment_secret parameter, this paramter has been the source
of much confusion, so we just drop it.

Users should prefer to do this check when registering the payment
secret instead of at claim-time.
2021-04-28 15:30:25 -04:00
Matt Corallo
5a1404809f Drop now-useless PaymentSecret parameters when claiming/failing-back 2021-04-28 15:30:25 -04:00
Matt Corallo
210b887d7c Add a user_payment_id to get_payment_secret+PaymentReceived
This allows users to store metadata about an invoice at
invoice-generation time and then index into that storage with a
general-purpose id when they call `get_payment_secret`. They will
then be provided the same index when the payment has been received.
2021-04-28 15:30:25 -04:00
Matt Corallo
25e4f3e46e Drop dead code for handling non-MPP payments in claim_funds 2021-04-28 15:30:25 -04:00
Matt Corallo
533a003472 [fuzz] Always use PaymentSecrets in chanmon_consistency 2021-04-28 15:30:25 -04:00
Matt Corallo
8bf3d8dec2 Req+check payment secrets for inbound payments pre-PaymentReceived
Our current PaymentReceived API is incredibly easy to mis-use -
the "obvious" way to implement a client is to always call
`ChannelManager::claim_funds` in response to a `PaymentReceived`
event. However, users are *required* to check the payment secret
and value against the expected values before claiming in order to
avoid a number of potentially funds-losing attacks.

Instead, if we rely on payment secrets being pre-registered with
the ChannelManager before we receive HTLCs for a payment we can
simply check the payment secrets and never generate
`PaymentReceived` events if they do not match. Further, when the
user knows the value to expect in advance, we can have them
register it as well, allowing us to check it for them.

Other implementations already require payment secrets for inbound
payments, so this shouldn't materially lose compatibility.
2021-04-28 15:30:25 -04:00
Matt Corallo
a7082901fe Use payment_secrets in all sends in functional tests
This prepares us for requiring payment_secrets for all received
payments, by demonstrating test changes work even prior to the new
requirement.

In order to avoid needing to pipe payment secrets through to
additional places in the claim logic and then removing that
infrastructure once payment secrets are required, we use the new
payment secret storage in ChannelManager to look up the payment
secret for any given pament hash in claim and fail-back functions.
This part of the diff is reverted in the next commit.
2021-04-28 15:30:25 -04:00
Matt Corallo
73a3bb3dca Use known InvoiceFeatures for routing in tests 2021-04-28 15:30:25 -04:00
Matt Corallo
6e5cf5e8d4 Pipe through PaymentSecrets in tests during payment hash creation
In order to reduce code movement in the next commit, this commit
simply tweaks get_payment_preimage_hash!() and related functions in
functional tests to return a payment secret. Further, we ensure
that we always call get_payment_preimage_hash!() with the node
which will ultimately receive the payment.
2021-04-28 15:30:25 -04:00
Matt Corallo
7d8dc7ac1a DRY the get_route_and_payment_hash!() macro duplicated in tests 2021-04-28 15:30:25 -04:00
Matt Corallo
7bf6bd2317 Add payment secret and preimage tracking in ChannelManager
This adds support for tracking payment secrets and (optionally)
payment preimages in ChannelManager. This potentially makes client
implementations much simper as they don't have to have external
payment preimage tracking.

This doesn't yet use such tracking anywhere.
2021-04-28 15:30:25 -04:00
Matt Corallo
2ef384db2d Fix fuzz secp patch by bumping the rust-secp version number in patch 2021-04-28 15:17:59 -04:00
Devrandom
7113dbd904 Send Init message immediately after handshake even if not initiator
We were waiting for the initiator, but the spec doesn't guarantee that they will send Init first, so we might theoretically wait forever.

Also, lnprototest expects this behavior.
2021-04-28 15:22:34 +02:00
Matt Corallo
3180c436f5 Set payment_secret to required in features flags 2021-04-27 23:40:33 +00:00
Matt Corallo
affefb677e
Merge pull request #854 from TheBlueMatt/2021-03-fix-lens
Fix serialization expected lengths and check them in test/fuzzing
2021-04-27 02:05:29 +00:00
Matt Corallo
ee0ffe5dfd Use more descriptive names in serialization impl macros 2021-04-27 01:09:12 +00:00
Matt Corallo
25b9fd8079 Fix serialization expected lengths and check them in test/fuzzing 2021-04-27 01:09:12 +00:00
Matt Corallo
7af9976261
Merge pull request #897 from TheBlueMatt/2021-04-fix-ci
Bump MSRV to 1.36
2021-04-27 01:06:11 +00:00
Matt Corallo
5625c3ab52 Test lightning-persister on rustc 1.36 as well 2021-04-27 00:36:52 +00:00
Matt Corallo
c4ab6756dd Bump MSRV to 1.36.0
Debian is shipping 1.41 on oldstable and rust-bitcoin will likely
move to 1.36 over the coming months, so there's little reason to
wait on this.

cc https://github.com/rust-bitcoin/rust-bitcoin/issues/510
2021-04-27 00:36:52 +00:00