Commit graph

295 commits

Author SHA1 Message Date
Matt Corallo
2b08a47e88 Improve ChannelDetails readability significantly.
After the merge of #984, Jeff pointed out that `ChannelDetails` has
become a bit of a "bag of variables", and that a few of the variable
names in #984 were more confusing than necessary in context.

This addresses several issues by:
 * Splitting counterparty parameters into a separate
   `ChannelCounterpartyParameters` struct,
 * using the name `unspendable_punishment_reserve` for both outbound
   and inbound channel reserves, differentiating them based on their
   position in the counterparty parameters struct or not,
 * Using the name `force_close_spend_delay` instead of
   `spend_csv_on_our_commitment_funds` to better communicate what
   is occurring.
2021-07-08 16:46:57 +00:00
Matt Corallo
b786adff5b Drop the cdylib export of lightning-invoice
There are ~zero functions in lightning-invoice that are materially
callable from C, so there isn't any reason to tag it as a cdylib
(and make rustc build it as such). Instead, we have C bindings now.
2021-06-24 04:32:25 +00:00
Matt Corallo
f875579311 Clarify invoice comment noting the relevant final-cltv-expiry vals 2021-06-17 20:17:24 +00:00
Matt Corallo
e7974dac84 Expose doc-linked constants in lightning-invoice
These constants are generally useful, and are linked from
documentation, so should be exposed in any case.
2021-06-17 15:48:20 +00:00
Matt Corallo
294009969a
Merge pull request #944 from TheBlueMatt/2021-06-0.0.99
0.0.98
2021-06-11 17:02:11 +00:00
Jeffrey Czyz
d0355b7b45
Fix type name in docs 2021-06-11 08:44:35 -07:00
Jeffrey Czyz
200f3d155c
Accept multi-hop route hints in get_route
Lightning invoices allow for zero or more multi-hop route hints. Update
get_route's interface to accept such hints, although only the last hop
from each is used for the time being.

Moves RouteHint from lightning-invoice crate to lightning crate. Adds a
PrivateRoute wrapper around RouteHint for use in lightning-invoice.
2021-06-11 08:44:32 -07:00
Jeffrey Czyz
c9d1ed5c14
Add find_all_extract macro to lightning-invoice
Used for extracting more than one field of the same type.
2021-06-10 12:54:55 -07:00
Matt Corallo
9c9081dfcb Bump versions to 0.0.98, lightning-invoice to 0.6.0 2021-06-08 21:08:29 +00:00
Devrandom
bac5f4930f Add proper signet support for invoices 2021-06-07 16:29:39 +02:00
Valentine Wallace
4503ef3523
Correct default expiry.
We previously stated in the codebase that the default invoice expiry
stated in the spec is 2 hours. It's actually 1 hour.
2021-05-14 16:51:46 -04:00
Matt Corallo
e84f5edbc5 Increase the CLTV delay required on payments and forwards
This increases the CLTV_CLAIM_BUFFER constant to 18, much better
capturing how long it takes to go on chain to claim payments.
This is also more in line with other clients, and the spec, which
sets the default CLTV delay in invoices to 18.

As a side effect, we have to increase MIN_CLTV_EXPIRY_DELTA as
otherwise as are subject to an attack where someone can hold an
HTLC being forwarded long enough that we *also* close the channel
on which we received the HTLC.
2021-05-05 20:09:11 +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
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
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
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
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
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
f24bbd63cc
Move PaymentPreimage+PaymentHash+PaymentSecret to top-level ln module 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
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
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
Valentine Wallace
b24d02c6a2
Add Features feature to invoices. 2021-04-26 12:29:46 -04:00
Valentine Wallace
2cbe4a09ec
Fix indentation in payment_secret function 2021-04-23 17:11:40 -04:00
Valentine Wallace
a62a71cb52
invoice: rename Route to RouteHint (which is more accurate) 2021-04-20 16:26:56 -04:00
Valentine Wallace
ad900658ce
Rename RouteHint to RouteHintHop (which is more accurate) 2021-04-20 16:26:56 -04:00
Valentine Wallace
21cb8db1b6
invoice: swap RouteHop for RouteHint
To prevent naming conflicts in bindings
2021-04-20 16:26:52 -04:00
Valentine Wallace
c3d25ed4bd
Fix Windows 2021-04-09 10:08:27 -04:00
Valentine Wallace
741f118da4
Clean up lightning-invoice Cargo.toml and README 2021-04-09 10:08:27 -04:00
Valentine Wallace
56069ba7aa
Clean up lightning-invoice CI, license, and add to workspaces 2021-04-09 10:08:27 -04:00
Sebastian
f00bb10a82
Pure import of lightning-invoice crate
Original repo: https://github.com/rust-bitcoin/rust-lightning-invoice
2021-04-09 10:08:27 -04:00