Commit graph

6177 commits

Author SHA1 Message Date
Matt Corallo
d0795d8904
Merge pull request #2679 from TheBlueMatt/2023-10-116-bindings-1
Small bindings tweaks for 0.0.118
2023-10-23 22:58:15 +00:00
Matt Corallo
35eb38df14 Fix CI on rustc 1.50 and below
rustc doesn't allow `--features` with `-p`, so we simply skip the
steps that rely on it.
2023-10-23 19:50:12 +00:00
Matt Corallo
49a5fdf6aa Use a tuple, not a struct, for PendingOnionMessage in bindings
Bindings aren't currently able to handle a struct with a generic
which is actually exposed - we map all structs concretely to a
single type, whereas having fluctuating types on a struct requires
mapping the inner field to a trait first.

Since this isn't super practical, we make `PendingOnionMessage` a
tuple in bindings, rather than a struct.
2023-10-23 19:42:32 +00:00
Matt Corallo
3f416bc24e
Merge pull request #2676 from TheBlueMatt/2023-10-various-followups
Various Followups to 2039 and 2674
2023-10-23 19:16:29 +00:00
Matt Corallo
32d2d0f1cf Add relevant no-export tags to functions returning builders
Because we can't map move semantics in most languages, we also
can't map our current builders. Thus, we have to mark them
no-export.
2023-10-23 16:50:42 +00:00
Matt Corallo
4918c415af Drop an unnecessary no-export on ParsedOnionMessageContents 2023-10-23 16:50:35 +00:00
Matt Corallo
4443db67f9 Do not compile the Simple* type aliases in c_bindings at all
Because the bindings changes now require further changes to our
type definitions, avoiding building the `Simple*` type aliases
entirely makes the patchset there simpler.
2023-10-21 16:30:41 +00:00
Matt Corallo
bbb8facbe6 Fix (and test) the c_bindings build flag
Rather than only building with the `c_bindings` flag in certain
crates, we go ahead and test all crates with the flag in CI here.
2023-10-21 14:30:21 +00:00
Matt Corallo
d2532dce34 Remove some additional excess words in ConfirmationTarget docs 2023-10-21 14:30:13 +00:00
Matt Corallo
d7668e1d12 Remove a redundant sentence in ConfirmationTarget docs
... and correct direction which causes force-closure in another
sentence.
2023-10-21 14:30:13 +00:00
Matt Corallo
803fb557e8 Drop unused use import. 2023-10-21 14:30:13 +00:00
Matt Corallo
d974a07e96 Avoid a redundant allocation in InvoiceError handling in one case
... by passing an owned `String`, rather than taking an `&str` and
`to_owned()`ing it.
2023-10-21 14:30:13 +00:00
Matt Corallo
50c55dcf32 Use Default::default() for scoring params in tests
In 26c1639ab6 we switched to using
`Default::default()` to initialize `()` for scoring parameters in
tests. A number of `()`s slipped back in recently, which we replace
here.
2023-10-21 14:30:13 +00:00
Matt Corallo
a1a2f2abc8
Merge pull request #2667 from wpaulino/random-htlc-holder-sigs-non-anchors
Use sign_holder_htlc_transaction to sign non-anchors holder HTLCs
2023-10-20 22:55:08 +00:00
Matt Corallo
fba99b73bf
Merge pull request #2674 from wpaulino/consider-anchor-outputs-value-balances
Consider anchor outputs value throughout balance checks and computations
2023-10-20 22:54:08 +00:00
Wilmer Paulino
b06a652e58
Move HTLCDescriptor to sign module
Now that `HTLCDescriptor` is no longer specific to anchors, it doesn't
make sense for it to live in the `bump_transaction` module anymore.
2023-10-20 15:32:16 -07:00
Wilmer Paulino
aae4e7c0ca
Don't sign holder HTLCs along with holder commitments
`sign_holder_commitment_and_htlcs` never really made sense. Unlike
`sign_counterparty_commitment`, the signatures for holder HTLC
transactions may be required much later than the commitment
transaction's. While it was nice for us to only reach the signer once to
obtain all holder signatures, it's not really ideal anymore as we want
our signatures to be random and not reused.

We no longer return all holder HTLC signatures and instead defer to
obtaining them via `EcdsaChannelSigner::sign_holder_htlc_transaction`.
2023-10-20 15:32:15 -07:00
Wilmer Paulino
a9d9d26655
Remove caching of holder HTLC signatures
Since we want our holder HTLC signatures to be randomly generated and
not reused, our existing caches are useless now, so we opt to remove
them.
2023-10-20 15:32:14 -07:00
Wilmer Paulino
03ec74631f
Use sign_holder_htlc_transaction to sign non-anchors holder HTLCs
We want to ensure we use fresh random signatures to prevent certain
classes of transaction replacement attacks at the bitcoin P2P layer.
This was already covered for commitment transactions and zero fee holder
HTLC transactions, but was missing for holder HTLC transactions on
non-anchors channels.

We can easily do this by reusing the existing
`EcdsaChannelSigner::sign_holder_htlc_transaction` method and
circumventing the existing `holder_htlc_sigs/prev_holder_htlc_sigs`
caches, which will be removed in a later commit anyway.
2023-10-20 15:32:13 -07:00
Matt Corallo
ec4395cf6e Apply a default max fee rather than none when paying for BOLT12
If the user declines to specify a `max_total_routing_fee_msat` in
the new BOLT12 payment methods, rather than defaulting to no limit
on the fee we pay at all, we should default to our "usual default",
ie the one calculated in
`RouteParameters::from_payment_params_and_value`.

We do this here, as well as documenting the behavior on the payment
methods.
2023-10-20 18:09:09 +00:00
Wilmer Paulino
27fba2dcc0
Only account for fee spike buffer multiple on non-anchor channels
Anchor outputs channels are no longer susceptible to fee spikes as they
now mostly target the dynamic minimum mempool fee and can contribute the
remainder of fees when closing.
2023-10-20 11:04:42 -07:00
Wilmer Paulino
834f4d710c
Consider anchor outputs value on channel open
We should make sure the funding amount of a channel can cover all its
associated costs, including the value of anchor outputs, to make sure
that it is actually usable once "opened".
2023-10-20 11:04:42 -07:00
Wilmer Paulino
297390a882
Consider anchor outputs value on inbound HTLCs
This could lead us to accept HTLCs that would put the sender below
their reserve, which must never happen.
2023-10-20 11:04:41 -07:00
Wilmer Paulino
d7672d4ebe
Consider anchor outputs value in get_available_balances
This could lead us to sending/forwarding HTLCs that would put us below
our reserve, forcing our counterparty to close the channel on us due to
an invalid update.
2023-10-20 11:04:40 -07:00
Wilmer Paulino
37a3a03f12
Run chanmon_consistency_test with anchor outputs channels 2023-10-20 11:04:39 -07:00
Wilmer Paulino
5958604ea6
Provide missing derivation parameters to OnchainTxHandler
`OnchainTxHandler` will need to construct `HTLCDescriptor`s for holder
HTLCs, but it did not have access to all of the derivation parameters
that need to be provided.
2023-10-20 11:03:02 -07:00
Wilmer Paulino
9510e298f9
Support signing non-anchors HTLCs with HTLCDescriptor
We plan to use `EcdsaChannelSigner::sign_holder_htlc_transaction` to
also sign holder HTLC transactions on non-anchor outputs channels.
`HTLCDescriptor` was only used in an anchor outputs context, so a few
things needed changing, mostly to handle the different scripts and
feerate.
2023-10-20 11:03:01 -07:00
Matt Corallo
be8797e17a
Merge pull request #2660 from benthecarman/flexible-fee-rate
More flexible fee rate estimates
2023-10-20 17:37:17 +00:00
benthecarman
dd15ab0394
More flexible fee rate estimates 2023-10-20 11:53:52 -05:00
Matt Corallo
10b8f4c44e
Merge pull request #2039 from jkczyz/2023-02-offer-flow
BOLT 12 Offers message flow
2023-10-20 16:40:17 +00:00
Matt Corallo
33bbf26f2f
Merge pull request #2670 from yanganto/socket-addr-to-string
Impl `Display` for SocketAddress
2023-10-20 15:57:43 +00:00
Jeffrey Czyz
fe9044831e
Fix PaymentConstraints::max_cltv_expiry docs 2023-10-20 09:51:31 -05:00
Jeffrey Czyz
6a97f648d3
Fix build warnings 2023-10-20 09:51:29 -05:00
Jeffrey Czyz
6d2ffdd8bd
Expand request_refund_payment docs for limitations 2023-10-20 09:49:58 -05:00
Jeffrey Czyz
a841e6b9e1
Onion message routing to immediate peers.
DefaultMessageRouter always fails. Update it so that it can route to a
directly connected peer. This is needed for an Offers minimum viable
product.
2023-10-20 09:49:58 -05:00
Jeffrey Czyz
681f89881e
Add privacy section to pay_for_offer docs 2023-10-20 09:49:57 -05:00
Jeffrey Czyz
3fd9fc6fc0
Organize create_refund and pay_for_offer docs 2023-10-20 09:49:57 -05:00
Jeffrey Czyz
5a0b111668
Document InvoiceRequestFailed in ChannelManager 2023-10-20 09:49:57 -05:00
Jeffrey Czyz
2840252cbc
Revert "Config-guard Event::InvoiceRequestFailed"
This reverts commit c7219e4683.
2023-10-20 09:49:57 -05:00
Jeffrey Czyz
0e41d8085a
Use ChannelManager as OffersMessageHandler 2023-10-20 09:49:57 -05:00
Jeffrey Czyz
debc20cc3e
OffersMessageHandler impl for ChannelManager
Define the BOLT 12 message flow in ChannelManager's
OffersMessageHandler implementation.
- An invoice_request message results in responding with an invoice
  message if it can be verified that the request is for a valid offer.
- An invoice is paid if it can be verified to have originated from a
  sent invoice_request or a refund.
- An invoice_error is sent in some failure cases.
- Initial messages enqueued for sending are released to OnionMessenger
2023-10-20 09:49:57 -05:00
Jeffrey Czyz
b191fd48d5
Check offer expiry when building invoice in no-std
Building an invoice will fail if the underlying offer or refund has
already expired. The check was skipped in no-std since there is no
system clock. However, the invoice creation time can be used instead.
This prevents responding to an invoice request if the offer has already
expired.
2023-10-20 09:49:57 -05:00
Jeffrey Czyz
89542807bd
Grammar fix in docs 2023-10-20 09:49:56 -05:00
Jeffrey Czyz
6f6e086196
BOLT12 invoice_feature methods for ChannelManager 2023-10-20 09:49:56 -05:00
Jeffrey Czyz
1d85efed78
Qualify BOLT11 ChannelManager invoice_features 2023-10-20 09:49:56 -05:00
Jeffrey Czyz
46b794e9a2
Utility for creating and sending Bolt12Invoices
Add a utility to ChannelManager for creating a Bolt12Invoice for a
Refund such that the ChannelManager can recognize the PaymentHash and
reconstruct the PaymentPreimage from the PaymentSecret, the latter of
which is contained in a BlindedPath within the invoice.
2023-10-20 09:49:56 -05:00
Jeffrey Czyz
ffe9ae285d
Utility for paying for an Offer
Add a utility to ChannelManager for sending an InvoiceRequest for an
Offer such that derived keys are used for the payer id. This allows for
stateless verification of any Invoice messages before it is paid.

Also tracks future payments using the given PaymentId such that the
corresponding Invoice is paid only once.
2023-10-20 09:49:56 -05:00
Jeffrey Czyz
34bdf22489
Absolute expiry or timer tick payment expiration
Pending outbound payments use an absolute expiry to determine when they
are considered stale and should be fail. In `no-std`, this may result in
long timeouts as the highest seen block time is used. Instead, allow for
expiration based on timer ticks. This will be use in an upcoming commit
for invoice request expiration.
2023-10-20 09:49:56 -05:00
Jeffrey Czyz
ddfeb3f642
Store OffersMessages for later sending
Upcoming commits will add utilities for sending an InvoiceRequest for an
Offer and an Invoice for a Refund. These messages need to be enqueued so
that they can be released in ChannelManager's implementation of
OffersMessageHandler to OnionMessenger for sending.

These messages do not need to be serialized as they must be resent upon
restart.
2023-10-20 09:49:55 -05:00
Jeffrey Czyz
bc0203d69b
Expand docs on failing expired outbound payments 2023-10-20 09:49:55 -05:00