Commit graph

362 commits

Author SHA1 Message Date
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
Matt Corallo
3141630f78
Merge pull request #2607 from DhananjayPurohit/civkit-branch
Issue in adding rust lightning as dependency on windows
2023-09-28 16:54:44 +00:00
DhananjayPurohit
cf0cef81b3 chore: remove time_utils.rs
No longer needed time_utils in lightning-invoice
2023-09-28 13:29:48 +05:30
Matt Corallo
94140b91d8 Bump versions to 0.0.117-alpha2/invoice 0.25.0-alpha2 2023-09-26 20:21:08 +00:00
Matt Corallo
1ac53ed02b
Merge pull request #2417 from tnull/2023-07-max-total-fee
Add config option to set maximum total routing fee
2023-09-26 20:07:52 +00:00
Elias Rohrer
d7e2ff6220
Introduce RouteParameters::max_total_routing_fee_msat
Currently, users have no means to upper-bound the total fees accruing
when finding a route. Here, we add a corresponding field to
`RouteParameters` which will be used to limit the candidate set during
path finding in the following commits.
2023-09-26 09:44:04 +02:00
Elias Rohrer
a37a16a3ce
Merge pull request #2589 from ErikDeSmedt/reexport_route_hint_hop
Reexport RouteHintHop
2023-09-22 09:09:41 +02:00
Matt Corallo
e01b51db67 Update crate version numbers to 0.0.117-alpha1/invoice 0.25-alpha1 2023-09-21 20:27:12 +00:00
Erik De Smedt
d1d23ff073 Reexport RouteHintHop
Earlier @benthecarman re-exported `RouteHint` to make life-easier
for developpers that use `lightning-invoice` and don't use the
`lightning`-crate.

This only solved part of the issue. To create a `RouteHint` the
developer must also have access to `RouteHintHop`.

See also:
  PR https://github.com/lightningdevkit/rust-lightning/pull/2572
	commit 79b426f49b
2023-09-21 15:40:34 +02:00
Matt Corallo
36af1f06fa
Merge pull request #2534 from tnull/2023-08-upstream-preflight-probing
Upstream and fix preflight probing
2023-09-18 16:41:57 +00:00
Elias Rohrer
f75ac9addf
Expose AChannelManager trait and use it in lightning-invoice 2023-09-18 15:08:28 +02:00
Elias Rohrer
20c842b496
Add preflight probing capabilities
We add a `ChannelManager::send_preflight_probes` method that can be used
to send pre-flight probes given some [`RouteParameters`]. Additionally,
we add convenience methods in for spontaneous probes and send pre-flight
probes for a given invoice.

As pre-flight probes might take up some of the available liquidity, we
here introduce that channels whose available liquidity is less than the
required amount times
`UserConfig::preflight_probing_liquidity_limit_multiplier` won't be used
to send pre-flight probes.

This commit is a more or less a carbon copy of the pre-flight
probing code recently added to LDK Node.
2023-09-18 15:08:27 +02:00
benthecarman
79b426f49b
Re-export RouteHint and PaymentSecret 2023-09-14 12:41:11 -05:00
Elias Rohrer
1f32ba4616
Remove mention of spontaneous payments from lightning-invoice 2023-09-13 11:52:45 +02:00
Elias Rohrer
266a3aa915
Have get_route take RouteParameters 2023-09-06 19:35:37 +02:00
optout
e99e6ab562
Use new ChannelId type 2023-08-26 01:30:40 +02:00
optout
513c2b4e4b Use Display of PaymentHash; avoid log_bytes macro 2023-08-22 18:16:50 +02:00
Matt Corallo
31049ed961 Delay RAA-after-next processing until PaymentSent is are handled
In 0ad1f4c943 we fixed a nasty bug
where a failure to persist a `ChannelManager` faster than a
`ChannelMonitor` could result in the loss of a `PaymentSent` event,
eventually resulting in a `PaymentFailed` instead!

As noted in that commit, there's still some risk, though its been
substantially reduced - if we receive an `update_fulfill_htlc`
message for an outbound payment, and persist the initial removal
`ChannelMonitorUpdate`, then respond with our own
`commitment_signed` + `revoke_and_ack`, followed by receiving our
peer's final `revoke_and_ack`, and then persist the
`ChannelMonitorUpdate` generated from that, all prior to completing
a `ChannelManager` persistence, we'll still forget the HTLC and
eventually trigger a `PaymentFailed` rather than the correct
`PaymentSent`.

Here we fully fix the issue by delaying the final
`ChannelMonitorUpdate` persistence until the `PaymentSent` event
has been processed and document the fact that a spurious
`PaymentFailed` event can still be generated for a sent payment.

The original fix in 0ad1f4c943 is
still incredibly useful here, allowing us to avoid blocking the
first `ChannelMonitorUpdate` until the event processing completes,
as this would cause us to add event-processing delay in our general
commitment update latency. Instead, we ultimately race the user
handling the `PaymentSent` event with how long it takes our
`revoke_and_ack` + `commitment_signed` to make it to our
counterparty and receive the response `revoke_and_ack`. This should
give the user plenty of time to handle the event before we need to
make progress.

Sadly, because we change our `ChannelMonitorUpdate` semantics, this
change requires a number of test changes, avoiding checking for a
post-RAA `ChannelMonitorUpdate` until after we process a
`PaymentSent` event. Note that this does not apply to payments we
learned the preimage for on-chain - ensuring `PaymentSent` events
from such resolutions will be addressed in a future PR. Thus, tests
which resolve payments on-chain switch to a direct call to the
`expect_payment_sent` function with the claim-expected flag unset.
2023-08-17 22:19:48 +00:00
Alec Chen
039b1c8d10
Allow users to provide custom TLVs through RecipientOnionFields
Custom TLVs allow users to send extra application-specific data with
a payment. These have the additional flexibility compared to
`payment_metadata` that they don't have to reflect recipient generated
data provided in an invoice, in which `payment_metadata` could be
reused.

We ensure provided type numbers are unique, increasing, and within the
experimental range with the `RecipientOnionFields::with_custom_tlvs`
method.

This begins sender-side support for custom TLVs.
2023-08-08 15:55:00 -05:00
Matt Corallo
983f2c1870 Bump crate versions to 0.0.116 release 2023-07-21 20:42:13 +00:00
Matt Corallo
cc5fea84e6 Update version numbers to rc1, from alpha1 2023-07-17 20:07:30 +00:00
Jeffrey Czyz
7ad3f88eba
Qualify the BOLT 11 invoice description type
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:59:33 -05:00
Jeffrey Czyz
a28c90a1b3
Qualify the BOLT 11 invoice signature type
A previous commit qualified the BOLT 11 invoice type, so any related
types should be similarly qualified, if public.
2023-07-14 15:53:07 -05:00