Commit graph

2316 commits

Author SHA1 Message Date
Matt Corallo
c9b12e18f2
Merge pull request #910 from TheBlueMatt/2021-05-sort-addrs
By default sort network addrs before inclusion in node_announcements
2021-05-06 01:25:44 +00:00
Matt Corallo
37fe22fece By default sort network addrs before inclusion in node_announcements
In  #797, we stopped enforcing that read/sent node_announcements
had their addresses sorted. While this is fine in practice, we
should still make a best-effort to sort them to comply with the
spec's forward-compatibility requirements, which we do here in the
ChannelManager.
2021-05-05 00:22:14 +00:00
Matt Corallo
c60543c0ed
Merge pull request #909 from TheBlueMatt/2021-04-0.0.14
Bump versions to 0.0.14, lightning-invoice 0.5
2021-05-04 02:14:03 +00:00
Matt Corallo
d782df01ba
Merge pull request #901 from jkczyz/2021-04-invoice-feature-semantics
Hide InvoiceFeatures behind InvoiceBuilder API
2021-05-04 02:00:52 +00:00
Matt Corallo
58e4ce251e
Merge pull request #845 from ariard/2021-03-hardcode-dust
Switch to a max counterparty's `dust_limit_satoshis` constant
2021-05-04 01:44:18 +00:00
Jeffrey Czyz
2226ae292b
Test feature bit semantics in Invoice::from_signed 2021-05-03 16:23:28 -07:00
Jeffrey Czyz
0592c52f23
Test feature bits in InvoiceBuilder 2021-05-03 16:23:28 -07:00
Jeffrey Czyz
20e776bc8e
Add basic_mpp support to InvoiceBuilder
Since InvoiceFeatures are an implementation detail of InvoiceBuilder, an
explicit call is needed to support the basic_mpp feature. Since it is
dependent on the payment_secret feature, conditionally define the
builder's method only when payment_secret has been set.
2021-05-03 16:23:27 -07:00
Jeffrey Czyz
b5f0ebab77
Hide InvoiceFeatures behind InvoiceBuilder API
Instead of relying on users to set an invoice's features correctly,
enforce the semantics inside InvoiceBuilder. For instance, if the user
sets a PaymentSecret then InvoiceBuilder should ensure the appropriate
feature bits are set. Thus, for this example, the TaggedField
abstraction can be retained while still ensuring BOLT 11 semantics at
the builder abstraction.
2021-05-03 16:23:24 -07:00
Matt Corallo
b307c1f2ad Make third HTLC non-dust again in the full_stack_target demo seed 2021-05-03 19:14:50 -04:00
Antoine Riard
ce56e3f00a Add bolt2_open_channel_sane_dust_limit 2021-05-03 15:37:40 -04:00
Antoine Riard
16619ff590 Replace config max counterpary dust_limit_satoshis by a constant.
Current Bitcoin Core's policy will reject a p2wsh as a dust if it's
under 330 satoshis. A typical p2wsh output is 43 bytes big to which
Core's `GetDustThreshold()` sums up a minimal spend of 67 bytes (even
if a p2wsh witnessScript might be smaller). `dustRelayFee` is set
to 3000 sat/kb, thus 110 * 3000 / 1000 = 330. As all time-sensitive
outputs are p2wsh, a value of 330 sat is the lower bound desired
to ensure good propagation of transactions. We give a bit margin to
our counterparty and pick up 660 satoshis as an accepted
`dust_limit_satoshis` upper bound.

As this reasoning is tricky and error-prone we hardcode it instead of
letting the user picking up a non-sense value.

Further, this lower bound of 330 sats is also hardcoded as another constant
(MIN_DUST_LIMIT_SATOSHIS) instead of being dynamically computed on
feerate (derive_holder_dust_limit_satoshis`). Reducing risks of
non-propagating transactions in casee of failing fee festimation.
2021-05-03 15:37:38 -04:00
Matt Corallo
d4d3225809
Merge pull request #908 from TheBlueMatt/2021-04-invoice-real-bindings
Minor Tweaks to lightning-invoice for C bindings
2021-05-01 00:50:25 +00:00
Matt Corallo
f551d5946b Bump versions to 0.0.14, lightning-invoice 0.5 2021-05-01 00:43:15 +00:00
Matt Corallo
83ab933f35 Add a not-exported tag to the Display implementation for RawHrp
RawHrp is already not-exported, so implementations for it should be
as well.
2021-05-01 00:36:58 +00:00
Matt Corallo
aed4665d44 Use explicit import lists instead of glob imports in invoice
While this is less readable, I spent way too long trying to adapt
the bindings generation code to handle glob imports and concluded
it would take refactoring almost the entire import-resolution
logic. While this may be a good refactor to do eventually, its
probably not worth it today.
2021-05-01 00:36:58 +00:00
Jeffrey Czyz
7310e2684c
Sanity test InvoiceFeatures 2021-04-30 12:04:35 -07:00
Jeffrey Czyz
1ec0232dc5
Require feature var_onion_optin
Feature payment_secret is required and depends on var_onion_optin, so
the latter must also be required.
2021-04-30 12:04:30 -07:00
Matt Corallo
2242b621fd Skip TaggedField for now as enum { A(A) } is broken in Java
... due to A and A aliasing each other.
2021-04-30 19:00:50 +00:00
Matt Corallo
246493f300 Set default error type for SignOrCreationError for bindings
The C bindings generator now looks to default generic types as the
way to map a struct or enum parameter. Because SignOrCreationError
is only used directly with an error type of `()`, we set that to
the default and assume no other error types are needed.
2021-04-30 19:00:50 +00:00
Matt Corallo
e26c3df71a
Merge pull request #907 from TheBlueMatt/2021-04-merge-conflicts
Fix merge conflicts between #898 and #895.
2021-04-30 19:00:35 +00:00
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