Commit graph

384 commits

Author SHA1 Message Date
Matt Corallo
2d6d5cc86f Move the public path for channel_state types to their new path 2024-06-04 14:21:08 +00:00
Matt Corallo
bfda1b683b
Merge pull request #3063 from jirijakes/upgrade-bitcoin-031
Upgrade rust-bitcoin dependency to 0.31
2024-05-31 14:18:23 -07:00
Jiri Jakes
a8bd4c097f
Upgrade rust-bitcoin to 0.31 2024-05-30 18:35:29 +08:00
Jeffrey Czyz
b6ff46daab
Pass ClaimAlongRouteArgs to do_claim_payment_along_route 2024-05-24 16:52:08 -05:00
Matt Corallo
806b7f0e31
Merge pull request #3054 from TheBlueMatt/2024-04-fuzz-bolt11
Add fuzzing coverage for BOLT11 invoice deserialization
2024-05-08 13:24:31 -07:00
Matt Corallo
8db1226ae4 Use consistent byte/char offsets when parsing invoice HRPs
When parsing lightning-invoice HRPs we want to read them
char-by-char, tracking at which offset different fields were. Prior
to this commit this was done first by reading char-by-char and then
by indexing using the byte offset which works for ASCII strings but
fails on multi-byte characters.

This commit fixes this issue by simply always walking byte-by-byte
and rejecting multi-byte characters which don't belong in HRPs.
2024-05-08 19:56:21 +00:00
Matt Corallo
d14ea82b5d Move existing BOLT11 fuzz test to the fuzz crate 2024-05-08 19:36:15 +00:00
Valentine Wallace
0ea58d0713
Fix overflow in invoice amount setter. 2024-05-06 11:20:04 -04:00
Matt Corallo
e818c4b13f Move [u8; 32] wrapper types to a common module
The `PaymentHash`, `PaymentSecret`, `PaymentPreimage`, and
`ChannelId` types are all small wrappers around `[u8; 32]` and are
used throughout the codebase but were defined in the top-level
`ln/mod.rs` file and the relatively sparsely-populated
`ln/channel_id.rs` file.

Here we move them to a common `types` module and go ahead and
update all our in-crate `use` statements to refer to the new
module for bindings. We do, however, leave a `pub use` alias for
the old paths to avoid upgrade hassle for users.
2024-05-01 19:01:40 +00:00
Valentine Wallace
c6ae9288b9
Fix overflow in lightning-invoice amount_pico_btc. 2024-04-30 10:05:35 -04:00
Matt Corallo
49b375311b Bump crate versions to 0.0.123-beta/invoice 0.31-beta 2024-04-19 01:03:03 +00:00
Matt Corallo
ef2e739295 Remove a handful of redundant imports
... that newer rustc now warns about.
2024-04-05 09:05:56 +00:00
Matt Corallo
ae0d825d89 Use crate::prelude::* rather than specific imports
New rustc beta now warns on duplicate imports when one of the
imports is from a wildcard import or the default prelude. Thus, to
avoid this here we prefer to always use `crate::prelude::*` and let
it decide if we actually need to import anything.
2024-04-05 09:05:54 +00:00
Matt Corallo
39c1d6b2af Replace the generic parse_int_be with a macro called twice
`parse_int_be` is generic across integer types and also input
types, but to do so it relies on the `num-traits` crate. There's
not a lot of reason for this now that std has `from_be_bytes`, so
we drop the generic now and replace it with a macro which is called
twice to create two functions, both only supporting conversion from
`u5` arrays.
2024-03-13 19:18:20 +00:00
Matt Corallo
c89b96a4b9 Use std's from_be_bytes rather than our to_int_be for int conv
`lightning-invoice` was mostly written before std's `from_be_bytes`
was stabilized, so used its own `to_int_be` utility to do int
conversions from `u8` arrays. Now that the std option has been
stable for quite some time, we should juse use it instead.
2024-03-13 19:16:20 +00:00
Matt Corallo
36e434d8ce
Merge pull request #2909 from benthecarman/inv-pk-helper
Add helper function to properly get invoice pubkey
2024-02-22 19:32:02 +00:00
benthecarman
53fc986378
Add helper function to properly get invoice pubkey 2024-02-22 18:05:37 +00:00
Matt Corallo
eecd2cdf4f Drop lightning-invoice dependency on hashbrown` 2024-02-16 20:34:41 +00:00
benthecarman
0769b22f5c
Worlds smallest optimization
Preallocate for 8 items in the vec. I chose this value for

1. features
2. description
3. payment hash
4. expire time
5. min_final_cltv
6. payment secret
7. route hint
8. for the memes
2024-02-08 22:40:48 +00:00
Matt Corallo
dedc8306f6 Bump hashbrown dependency to 0.13
While this isn't expected to materially improve performance, it
does get us ahash 0.8, which allows us to reduce fuzzing
randomness, making our fuzzers much happier.

Sadly, by default `ahash` no longer tries to autodetect a
randomness source, so we cannot simply rely on `hashbrown` to do
randomization for us, but rather have to also explicitly depend on
`ahash`.
2024-02-02 18:05:08 +00:00
Matt Corallo
7b31b303c6 Bump versions to LDK 0.0.121/invoice 0.29 2024-01-22 22:32:30 +00:00
Matt Corallo
37017ec39f Bump crate versions to 0.0.120/invoice 0.28 2024-01-17 21:34:29 +00:00
shuoer86
8cd48060d7
Fix typo lightning-invoice/src/ser.rs 2024-01-12 20:46:26 +08:00
Elias Rohrer
15e14166da
Allow unused imports in lightning-invoice prelude 2023-12-18 08:53:28 +01:00
Elias Rohrer
be574f5c27
Fix unused imports in lightning-invoice no-std tests 2023-12-18 08:53:27 +01:00
Elias Rohrer
d8eababd8b
Drop unused sync module from lightning-invoice 2023-12-18 08:53:27 +01:00
Matt Corallo
c6e4debee9 Bump versions to 0.0.119/lightning-invoice 0.27 2023-12-15 23:53:40 +00:00
Matt Corallo
83e76d78b7 Drop explicit bitcoin_hashes dependency in lightning-invoice
Since `lightning-invoice` now depends on the `bitcoin` crate
directly, also depending on the `bitcoin_hashes` crate is redundant
and just means we confuse users by setting the `std` flag only on
`bitcoin`. Thus, we drop the explicit dependency here and replace
it with `bitcoin::hashes`.
2023-12-15 22:31:51 +00:00
Matt Corallo
90cc9930b7 Un-export the PrivateRoute inner field as there are invariants
When we make the `PrivateRoute` inner `RouteHint` `pub`, we failed
to note that the `PrivateRoute::new` constructor actually verifies
a length invariant. Thus, we un-export the inner field and force
users to go back through the `new` fn.
2023-12-15 22:31:51 +00:00
Elias Rohrer
ddf2509227
Bump MSRV to rustc 1.63.0 and edition to 2021
.. which is a reasonable common ground, also supported by Debian stable.
2023-12-08 14:03:45 +01:00
henghonglee
fa7f2f4986
Add WithChannelDetails 2023-12-01 11:30:19 -06:00
Arik Sosman
27b9794bed
Rename SignerProvider's Signer to EcdsaSigner. 2023-11-27 16:27:20 -08:00
Matt Corallo
b28068cc42 Drop panic if rust-bitcoin adds a new Network
`rust-bitcoin` 0.30 added `#[non_exhaustive]` to the `Network`
enum, allowing them to "add support" for a new network type without
a major version change in the future. When upgrading, we added a
simple `unreachable` for the general match arm, which would break
in a minor version change of `rust-bitcoin`.

While it seems [possible rust-bitcoin will change
this](https://github.com/rust-bitcoin/rust-bitcoin/issues/2225),
we still shouldn't ba panicking, which we drop here in favor of a
`debug_assert`ion, and a default value.
2023-11-26 19:07:10 +00:00
Wilmer Paulino
ad56847a6b
Remove nightly warnings 2023-11-22 15:58:01 -08:00
Wilmer Paulino
ec928d55b4
Bump rust-bitcoin to v0.30.2 2023-11-22 15:58:01 -08:00
Matt Corallo
9c9e5f896c
Merge pull request #2730 from benthecarman/invoice-utils
Add some public utilities to `lightning_invoice`
2023-11-15 22:01:33 +00:00
benthecarman
e80e8c8062
Have Invoice Description use UntrustedString 2023-11-15 12:35:35 -06:00
benthecarman
3def30721f
Make invoice fields public 2023-11-15 12:35:21 -06:00
Matt Corallo
22305a9bff Drop old expiry_time_from_unix_epoch helper in expiry time lookup
Since there's a much simpler way to go about it with
`Bolt11Invoice::expires_at`.
2023-11-12 17:18:00 +00:00
benthecarman
3fbfde360f
Impl display for invoice fields 2023-11-10 20:41:53 -06:00
Matt Corallo
a6039b9af2 Replace maze of BOLT11 payment utilities with parameter generators
`lightning-invoice` was historically responsible for actually
paying invoices, handling retries and everything. However, that
turned out to be buggy and hard to maintain, so the payment logic
was eventually moved into `ChannelManager`. However, the old
utilites remain.

Because our payment logic has a number of tunable parameters and
there are different ways to pay a BOLT11 invoice, we ended up with
six different methods to pay or probe a BOLT11 invoice, with more
requested as various options still were not exposed.

Instead, here, we replace all six methods with two simple ones
which return the arguments which need to be passed to
`ChannelManager`. Those arguments can be further tweaked before
passing them on, allowing more flexibility.
2023-11-10 19:23:21 +00:00
Matthew Rheaume
bf395070dd Added temporary_channel_id to create_channel.
By default, LDK will generate the initial temporary channel ID for you.
However, in certain cases, it's desirable to have a temporary channel ID
specified by the caller in case of any pre-negotiation that needs to
happen between peers prior to the channel open message. For example, LND
has a `FundingShim` API that allows for advanced funding flows based on
the temporary channel ID of the channel.

This patch adds support for optionally specifying the temporary channel
ID of the channel through the `create_channel` API.
2023-11-03 17:44:50 -07:00
Matt Corallo
b664875c1b Bump crate versions to lightning 0.0.118, invoice 0.26 2023-10-23 23:41:11 +00:00
Matt Corallo
6cafba9f5b
Merge pull request #2650 from TheBlueMatt/2023-10-make-clippy-shut-up
Make clippy shut up about `PartialOrd` and `Ord` both impl'd
2023-10-12 20:44:46 +00:00
Elias Rohrer
989304ed36
Merge pull request #2652 from tnull/2023-10-deref-achannelmanager 2023-10-08 09:11:19 +02:00
Elias Rohrer
808e72ad15
Have methods take AChannelManager as Deref::Target 2023-10-06 07:30:45 -10:00
Matt Corallo
ec7d665436 Make clippy shut up about PartialOrd and Ord both impl'd
Clippy gets mad that we have an implementation of `ParialOrd` and
`Ord` separately, even though both are identical. Making
`ParitalOrd` call `Ord` makes clippy shut up.
2023-10-06 00:02:45 +00:00
Matt Corallo
c74874604e Bump crate versions to 0.0.117/invoice 0.25 2023-10-03 23:00:48 +00:00
Matt Corallo
add71d42a0 Use crate::prelude::* to load Vec, rather than crate::Vec
This is kinda dumb, but the bindings get confused when referring
to `Vec` absolutely in a `use` statement, and there's no reason not
to load our prelude everywhere.
2023-10-01 00:05:01 +00:00
Matt Corallo
7036681728 Bump crate versions to 0.0.117-rc1/invoice 0.25-rc1 2023-09-29 23:39:18 +00:00