Commit graph

4053 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Matt Corallo
70b18663f4 Don't send init closing_signed too early after final HTLC removal
If we remove an HTLC (or fee update), commit, and receive our
counterparty's `revoke_and_ack`, we remove all knowledge of said
HTLC (or fee update). However, the latest local commitment
transaction that we can broadcast still contains the HTLC (or old
fee), thus we are not eligible for initiating the `closing_signed`
negotiation if we're shutting down and are generally expecting a
counterparty `commitment_signed` immediately.

Because we don't have any tracking of these updates in the `Channel`
(only the `ChannelMonitor` is aware of the HTLC being in our latest
local commitment transaction), we'd previously send a
`closing_signed` too early, causing LDK<->LDK channels with an HTLC
pending towards the channel initiator at the time of `shutdown` to
always fail to cooperatively close.

To fix this race, we add an additional unpersisted bool to
`Channel` and use that to gate sending the initial `closing_signed`.
2023-11-11 20:24:58 +00:00
Matt Corallo
d30d599a2f Drop non-anchor channel fee upper bound limit entirely
Quite a while ago we added checks for the total current dust
exposure on a channel to explicitly limit dust inflation attacks.
When we did this, we kept the existing upper bound on the channel's
feerate in place. However, these two things are redundant - the
point of the feerate upper bound is to prevent dust inflation, and
it does so in a crude way that can cause spurious force-closures.

Here we simply drop the upper bound entirely, relying on the dust
inflation limit to prevent dust inflation instead.
2023-11-11 17:32:31 +00:00
Matt Corallo
7a951b1bf7 Stop writing signer data as a part of channels
This breaks backwards compatibility with versions of LDK prior to
0.0.113 as they expect to always read signer data.

This also substantially reduces allocations during `ChannelManager`
serialization, as we currently don't pre-allocate the `Vec` that
the signer gets written in to. We could alternatively pre-allocate
that `Vec`, but we've been set up to skip the write entirely for a
while, and 0.0.113 was released nearly a year ago. Users
downgrading to LDK 0.0.112 and before at this point should not be
expected.
2023-11-09 22:28:08 +00:00
Matt Corallo
a8d4cfa811 Avoid allocating when checking gossip message signatures
When we check gossip message signatures, there's no reason to
serialize out the full gossip message before hashing, and it
generates a lot of allocations during the initial startup when we
fetch the full gossip from peers.
2023-11-09 22:28:08 +00:00
Matt Corallo
969085bf1e Avoid re-allocating to encrypt gossip messages when forwarding
When we forward gossip messages, we store them in a separate buffer
before we encrypt them (and commit to the order in which they'll
appear on the wire). Rather than storing that buffer encoded with
no headroom, requiring re-allocating to add the message length and
two MAC blocks, we here add the headroom prior to pushing it into
the gossip buffer, avoiding an allocation.
2023-11-09 22:28:08 +00:00
benthecarman
55da9c434e
Fix potential cases where max_dust_htlc_exposure_msat overflows 2023-11-09 14:51:44 -06:00
Matt Corallo
589a88e749 Fix data_loss_protect test to actually test DLP
The data loss protect test was panicking in a message assertion
which should be passing, but because the test was marked only
`#[should_panic]` it was being treated as a successful outcome.
Instead, we use `catch_unwind` on exactly the line we expect to
panic to ensure we are hitting the right one.
2023-11-09 00:05:23 +00:00
Valentine Wallace
0edd645ba8
Link to LSP spec in accept_underpaying_htlcs config 2023-11-07 15:14:27 -05:00
Valentine Wallace
1926c82b9e
Include counterparty skimmed fees in PaymentClaimed event. 2023-11-07 15:08:55 -05:00
Matt Corallo
0503df88c7 Use VecDeque, rather than LinkedList in peer message buffering
When buffering outbound messages for peers, `LinkedList` adds
rather substantial allocation overhead, which we avoid here by
swapping for a `VecDeque`.
2023-11-07 18:13:23 +00:00
Matt Corallo
48edd01d02 Avoid unnecessarily alloc'ing a new buffer when decrypting messages
When decrypting P2P messages, we already have a read buffer that we
read the message into. There's no reason to allocate a new `Vec` to
store the decrypted message when we can just overwrite the read
buffer and call it a day.
2023-11-07 18:13:23 +00:00
Matt Corallo
5e34bc4404 Add an option to in-place decrypt with ChaCha20Poly1305
In the next commit we'll use this to avoid an allocation when
deserializing messages from the wire.
2023-11-07 18:13:23 +00:00
optout
649129ddab Add Splicing (and Quiescence) wire message definitions 2023-11-07 12:13:58 +01:00
Matt Corallo
1aa5210c2f Avoid an unnecessary allocation in TaggedHash
A well-formed tag is always a constant, so allocating to store it
is unnecessary when we can just make the tag a `&'static str`.
2023-11-07 05:08:16 +00:00
Matt Corallo
96e7d7a258
Merge pull request #2687 from orbitalturtle/signature-data-enum
Expose more granular data in TaggedHash struct
2023-11-07 05:04:48 +00:00
Matt Corallo
2e33acbd9c
Merge pull request #2677 from Evanfeenstra/public-onion-utils
public create_payment_onion in onion_utils
2023-11-07 04:41:03 +00:00
Matt Corallo
e4c6b70e8e Pre-allocate the full Vec prior to serializing as a Vec<u8>
We end up generating a substantial amount of allocations just
doubling `Vec`s when serializing to them, and our
`serialized_length` method is generally rather effecient, so we
just rely on it and allocate correctly up front.
2023-11-07 04:12:30 +00:00
Orbital
caafcedf3f
expose more granular data in TaggedHash struct
Expose tag and merkle root fields in the TaggedHash struct.
2023-11-06 21:36:54 -06:00
Orbital
38dfbf99db
refactor to remove message_digest
We change the Bolt12Invoice struct to carry a tagged hash. Because
message_digest is then only used in one place, we can inline it in
the TaggedHash constructor.
2023-11-06 21:29:50 -06:00
Evan Feenstra
0c7b6479b0 export create_onion_message and peel_onion_message from ln::onion_message 2023-11-06 10:42:50 -08:00
Evan Feenstra
c126f0b187 public create_payment_onion in onion_utils 2023-11-06 10:41:35 -08:00
Matt Corallo
e09afafc43 Avoid unnecessarily overriding serialized_length
...as LLVM will handle it just fine for us, in most cases.
2023-11-04 16:21:29 +00:00
Matt Corallo
1455452177 Pre-allocate send buffer when forwarding gossip
When forwarding gossip, rather than relying on Vec doubling,
pre-allocate the message encoding buffer.
2023-11-04 16:20:51 +00:00
Matt Corallo
abee51b10c Prefer Writeable.encode() over VecWriter use
It does the same thing and its much simpler.
2023-11-04 16:20:24 +00:00