Commit graph

6291 commits

Author SHA1 Message Date
Matt Corallo
3b6d6937bb Update docs on HTLC and DelayedPayment keys for clarity
This also adds required linebreaks to keep the docs to a reasonable
width.
2024-01-09 22:24:59 +00:00
Matt Corallo
c5e3f5fa82 Drop the unused PaymentKey type
935a716cc6 added new wrappers for the
various channel keys, including a payment_key. However, the
`payment_key` has been unused in lightning since the introduction
(and broad requiring) of the `static_remotekey` feature.

Thus, we simply remove it (and an incredibly stale TODO) here.
2024-01-09 22:24:59 +00:00
Matt Corallo
bc273a2939 Update docs for slightly more clarity on channel key derivation 2024-01-09 22:24:59 +00:00
Matt Corallo
e4f690cd4c Change RevocationKey args to make clear one side is a countersig
935a716cc6 changed the parameter
names to `RevocationKey` derivation to remove the naming which made
clear one of the two parameters is a countersignatory key, which is
restored here.
2023-11-27 18:59:30 +00:00
Matt Corallo
029448a613 Update docs on RevocationKey for clarity and to provide more info
This also adds required linebreaks to keep the docs to a reasonable
width.
2023-11-27 18:59:30 +00:00
Matt Corallo
83fe0b8260 Fix space and execss indentation in channel_keys.rs 2023-11-27 18:59:30 +00:00
Matt Corallo
74078c4bef
Merge pull request #2675 from yellowred/delayed_payment_key_types
Implement struct wrappers for Payment, DelayedPayment, HTLC and Revocation channel keys
2023-11-27 18:57:37 +00:00
olegkubrakov
935a716cc6 Implement struct wrappers for channel key types to avoid confusion.
Currently all channel keys and their basepoints exist uniformly as
`PublicKey` type, which not only makes in harder for a developer to
distinguish those entities, but also does not engage the language
type system to check if the correct key is being used in any
particular function.

Having struct wrappers around keys also enables more nuanced
semantics allowing to express Lightning Protocol rules in language.
For example, the code allows to derive `HtlcKey` from
`HtlcBasepoint` and not from `PaymentBasepoint`.

This change is transparent for channel monitors that will use the
internal public key of a wrapper.

Payment, DelayedPayment, HTLC and Revocation basepoints and their
derived keys are now wrapped into a specific struct that make it
distinguishable for the Rust type system. Functions that require a
specific key or basepoint should not use generic Public Key, but
require a specific key wrapper struct to engage Rust type
verification system and make it more clear for developers which
key is used.
2023-11-27 17:52:12 +00:00
Matt Corallo
fa0d015d1f
Merge pull request #2685 from tnull/2022-12-add-electrum-sync
Add electrum support to `lightning-transaction-sync`
2023-11-27 17:10:00 +00:00
Elias Rohrer
a0183d7ef1
Merge pull request #2741 from shaavan/issue-2215
Explicitly reject routes that double-back
2023-11-27 13:13:08 +01:00
Elias Rohrer
8bd4a8f303
Merge pull request #2746 from TheBlueMatt/2023-11-bitcoin-0.30-followups
Drop panic if rust-bitcoin adds a new Network
2023-11-27 12:53:17 +01:00
Matt Corallo
a41954d841 Remove now-redundant checks in BOLT12 Invoice fallback addresses
Now that we use the `rust-bitcoin` `WitnessProgram` to check our
addresses, we can just rely on it, rather than checking the program
length and version.
2023-11-26 19:09:06 +00: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
shaavan
a06d15826f Add test for PathParameterError introduced in previous commit
- Also modify the unwrap_send_err!() macro to handle the
  PathParameterError
2023-11-24 18:51:56 +05:30
Elias Rohrer
31ea90eba2
Use esplora-client's async-https-rustls feature
Now that we upgraded `esplora-client` to 0.6 we can use
`async-https-rustls` instead of manually overriding the `reqwest`
dependency.
2023-11-24 12:48:22 +01:00
Elias Rohrer
c2e81fbb82
DRY up Esplora/Electrum integration_tests 2023-11-23 09:30:58 +01:00
Elias Rohrer
28c14cd884
Add Electrum integration test 2023-11-23 09:30:58 +01:00
Elias Rohrer
4dd5ccbe49
Implement ElectrumSyncClient 2023-11-23 09:30:57 +01:00
Elias Rohrer
d2ecf0766c
Set pending_sync when last-minute check fails in Esplora 2023-11-23 09:30:57 +01:00
Elias Rohrer
82f4c10e18
Move sync_ methods to SyncState 2023-11-23 09:30:57 +01:00
Elias Rohrer
e14e2c3fba
Improve EsploraSyncClient test coverage
In particular, we now test `register_output` functionality, too.
2023-11-23 09:30:57 +01:00
Elias Rohrer
48c46bf772
Improve EsploraSyncClient logging
We give some more information while reducing the log levels to make the
logging less spammy.

We also convert one safe-to-unwrap case from returning an error to
unwrapping the value.
2023-11-23 09:30:57 +01:00
Elias Rohrer
5b7c1d511b
Use upstream TestLogger util in tx sync tests 2023-11-23 09:30:57 +01:00
Elias Rohrer
c8ff32197a
Return confirmation height via Confirm::get_relevant_txids
We previously included the block hash, but it's also useful to include
the height under which we expect the respective transaction to be
confirmed.
2023-11-23 09:30:56 +01:00
Elias Rohrer
70ea110864
Merge pull request #2740 from wpaulino/rust-bitcoin-30-update
Update to rust-bitcoin v0.30.2
2023-11-23 09:28:41 +01: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
shaavan
9bd1cc7660 Explicitly reject routes that double-back
- If a path within a route passes through the same channelID twice,
  that shows the path is looped and will be rejected by nodes.
- Add a check to explicitly reject such payment before trying to send
  them.
2023-11-22 18:34:44 +05:30
Matt Corallo
870a0f14ba
Merge pull request #2700 from Evanfeenstra/pub-htlc-routing
peel_payment_onion static fn in channelmanager
2023-11-16 17:02:05 +00: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
Evan Feenstra
192fe05147 InboundOnionErr fields public 2023-11-15 13:08:56 -08: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
Elias Rohrer
fb670c8faa
Merge pull request #2696 from TheBlueMatt/2023-10-no-chan-feerate-upper-bound
Drop non-anchor channel fee upper bound limit entirely
2023-11-15 10:25:06 +01:00
Gursharan Singh
0456b0e311
Merge pull request #2727 from TheBlueMatt/2023-11-better-bolt11-utils
Replace maze of BOLT11 payment utilities with parameter generators
2023-11-14 13:37:29 -08:00
Evan Feenstra
378885d8db remove obsolete comment 2023-11-14 11:56:31 -08:00
Evan Feenstra
4b5db8c3ce peel_payment_onion static fn in channelmanager 2023-11-14 11:54:23 -08:00
Matt Corallo
5d187f65b9
Merge pull request #2529 from TheBlueMatt/2023-08-shutdown-remove-early-sign
Don't send init `closing_signed` too early after final HTLC removal
2023-11-14 19:09:46 +00:00
Matt Corallo
185fbc1765
Merge pull request #2726 from shaavan/issue2712
Log the error, when trying to forward the intercepted HTLC, but the channel is not found
2023-11-14 17:57:19 +00:00
shaavan
dce514e912 Log the error, when trying to forward the intercepted HTLC, but the
channel is not found
2023-11-14 15:11:09 +05:30
Elias Rohrer
04b16e74d5
Merge pull request #2716 from TheBlueMatt/2023-11-hash-if-eq
`derive(Hash)` for P2P messages
2023-11-14 08:50:38 +01:00
Matt Corallo
26c00ad751 derive(Hash) for P2P messages
In other languages (Java and C#, notably), overriding `Eq` without
overriding `Hash` can lead to surprising or broken behavior. Even
in Rust, its usually the case that you actually want both. Here we
add missing `Hash` derivations for P2P messages, to at least
address the first pile of warnings the C# compiler dumps.
2023-11-14 00:40:30 +00:00
Matt Corallo
eb23c1e43b Rely on const generic big arrays for PartialEq in msgs
Implementation of standard traits on arrays longer than 32 elements
was shipped in rustc 1.47, which is below our MSRV of 1.48 and we
can use to remove some unnecessary manual implementation of
`PartialEq` on `OnionPacket`.
2023-11-14 00:40:30 +00:00
Matt Corallo
c852ce6139
Merge pull request #2544 from optout21/splicing-msgs0
Add Splicing (and Quiescence) wire message definitions
2023-11-13 22:38:51 +00:00
Matt Corallo
a025c7ca88
Merge pull request #2732 from arik-so/2023/11/update-musig2-dep
Update MuSig2 dependency for Hash trait derivation.
2023-11-13 17:29:39 +00:00
Matt Corallo
103180df8f
Merge pull request #2708 from TheBlueMatt/2023-11-less-graph-memory-frag
Reduce common allocations across the codebase
2023-11-13 16:45:26 +00:00
Arik Sosman
2feae7bc58
Update MuSig2 dependency for Hash trait derivation. 2023-11-13 11:07:07 -05:00
Matt Corallo
d5a0eb4270
Merge pull request #2715 from valentinewallace/2023-11-skimmed-fees
Complete underpaying HTLCs support
2023-11-12 20:27:25 +00: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
Matt Corallo
98544772e2
Merge pull request #2722 from benthecarman/dust-overflow
Fix potential cases where max_dust_htlc_exposure_msat overflows
2023-11-12 17:03:09 +00:00