Commit Graph

438 Commits

Author SHA1 Message Date
Elle Mouton
9d0cd3ff4f
multi: update more loggers to the v2 type 2024-10-22 17:03:56 +02:00
Jonathan Harvey-Buschel
77ae7afe78
multi: link quit can interrupt commitment signing
In this commit, we make sig job handling when singing a next commitment
non-blocking by allowing the shutdown of a channel link to prevent
further waiting on sig jobs by the channel state machine. This addresses
possible cases where the aux signer may be shut down via a separate quit
signal, so the state machine could block indefinitely on receiving an
update on a sig job.
2024-10-17 17:35:29 +02:00
Jonathan Harvey-Buschel
cd14c52ecd
htlcswitch: pass quit chans as unidirectional
This is a requirement for replacing the quit channel with a Context.
The Done() channel of a Context is always recv-only, so all users of
that channel must not expect a bidirectional channel.
2024-10-17 17:33:15 +02:00
ffranr
bbae7148aa
multi: pass UpdateAddHtlc message custom records to invoice modifier 2024-09-19 09:21:38 +02:00
Oliver Gugger
cdad5d988d
Merge pull request #9072 from lightningnetwork/extract-part3-from-staging-branch
[custom channels 3/5]: Extract PART3 from mega staging branch
2024-09-19 01:20:55 -06:00
Oliver Gugger
52e50d807d
htlcswitch: override amount check on custom records 2024-09-18 19:07:27 +02:00
Olaoluwa Osuntokun
83fdbda2fa
multi: obtain+verify aux sigs for all second level HTLCs
In this commit, we start to use the new AuxSigner to obtain+verify aux sigs for all second level HTLCs. This is similar to the existing SigPool, but we'll only attempt to do this if the AuxSigner is present (won't be for most channels).
2024-09-18 19:04:53 +02:00
Elle Mouton
60f331edb1
multi: rename ChannelUpdate to ChannelUpdate1
In preparation for adding a new ChannelUpdate2 message and a
ChannelUpdate interface, we rename the existing message to
ChannelUpdate1.
2024-09-18 16:13:17 +02:00
Keagan McClelland
957557a937
htlcswitch+lnwallet: remove PaymentDescriptor from ReceiveRevocation returns
This is part of a systematic removal of PaymentDescriptor from the public
API of the lnwallet package. This marks the last change needed before we
make the PaymentDescriptor structure private.
2024-09-09 20:59:22 -06:00
Keagan McClelland
1ae5705954
htlcswitch: remove PaymentDescriptor from processRemoteSettleFails call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 17:15:31 -06:00
Keagan McClelland
aa38041240
htlcswitch: remove PaymentDescriptor from processRemoteAdds call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 17:15:30 -06:00
Keagan McClelland
d881809a4d
htlcswitch: remove PaymentDescriptor from hodlHtlc
This is part of a systematic removal of PaymentDescriptor from the
mechanics of the htlcswitch package.
2024-09-09 16:53:11 -06:00
Keagan McClelland
a0818a0d16
htlcswitch: remove PaymentDescriptor from the processExitHop's call signature
This is part of a systematic removal of PaymentDescriptor from the mechanics
of the htlcswitch package.
2024-09-09 16:53:10 -06:00
Keagan McClelland
07647fe53a
htlcswitch: remove PaymentDescriptor from settleHTLC's call signature
This is done as part of a systematic removal of PaymentDescriptor from
the mechanics of the htlcswitch package.
2024-09-09 16:53:10 -06:00
Keagan McClelland
877d29c717
htlcswitch: remove PaymentDescriptor from sendHTLCError's call signature
This is done as part of a systematic removal of PaymentDescriptor from
the mechanics of the htlcswitch package.
2024-09-09 16:53:10 -06:00
Keagan McClelland
721a0c5edc
lnwire+htlcswitch: change NewInvalidBlinding to use array instead of slice 2024-09-09 16:26:41 -06:00
Keagan McClelland
5505b6daff
htlcswitch: change sendMalformedHTLCError to take array instead of slice 2024-09-09 16:26:41 -06:00
Keagan McClelland
5deb4c253a
htlcswitch+lnwallet: fix OnionBlob to 1366 bytes 2024-09-09 16:26:41 -06:00
George Tsagkarelis
5dcda25881
htlcswitch: expose custom channel blob from link 2024-09-05 18:00:49 +02:00
George Tsagkarelis
878f964a33
multi: use wire records on payment and intercept flows 2024-09-05 11:18:16 +02:00
Keagan McClelland
1422729f80
lnwallet+htlcswitch: define expanded NumPendingUpdates
This commit squashes the below operations for a net result where
we have an expanded capability of assessing pending updates. This
is made possible by packing the components into Duals in the prior
commits. We squash the operations to simplify review.

htlcswitch+lnwallet: rename PendingLocalUpdateCount

lnwallet: complete pending update queries API for LightningChannel

lnwallet+htlcswitch: consolidate NumPendingUpdates using ChannelParty

This commit makes the observation that we can cleanly define the
NumPendingUpdates function using a single expression by taking
advantage of the relevant fields being properly packed into Duals.
2024-08-28 14:03:00 -07:00
Keagan McClelland
a0515a16db
htlcswitch: extract error handling for syncChanStates 2024-08-28 13:46:52 -07:00
Oliver Gugger
e99e6662cf
multi: update linter, fix new issues 2024-08-20 19:14:44 +02:00
yyforyongyu
3b6e28d19b
channeldb+htlcswitch: make sure circuit is not nil in teardownCircuit 2024-08-07 22:17:59 +08:00
Olaoluwa Osuntokun
4a3c4e4ba7
Merge pull request #8497 from ziggie1984/shutdown-bugfix
routing: shutdown chanrouter correctly.
2024-08-01 16:48:50 -07:00
Keagan McClelland
f54c9ea8f7
htlcswitch: replace errors package implementation 2024-07-31 17:54:21 -07:00
Keagan McClelland
1f9cac5f80
htlcswitch: refactor dust handling to use ChannelParty 2024-07-31 14:50:27 -07:00
Keagan McClelland
0996e4f163
multi: refactor lnwallet/channel.go to use ChannelParty in select places
We also include changes to contractcourt, htlcswitch and peer to stitch the
boundaries together.
2024-07-31 14:50:26 -07:00
ziggie
02c1264c53
multi: prevent nil panics in stop methods.
With this PR we might call the stop method even when the start
method of a subsystem did not successfully finish therefore we
need to make sure we guard the stop methods for potential panics
if some variables are not initialized in the contructors of the
subsystems.
2024-07-31 14:43:34 +02:00
Oliver Gugger
ac4ef28926
Merge pull request #8824 from Crypt-iQ/precise_dust_limit
multi: include commitment fees in dust calculation
2024-07-31 03:13:31 -06:00
Eugene Siegel
d6001d033b
htlcswitch+lnwallet: calculate fee exposure as commit fees + dust
This commit expands the definition of the dust limit to take into
account commitment fees as well as dust HTLCs. The dust limit is now
known as a fee exposure threshold. Dust HTLCs are fees anyways so it
makes sense to account for commitment fees as well. The link has
been modified slightly to calculate dust. In the future, the switch
dust calculations can be removed.
2024-07-29 14:13:21 -04:00
Elle Mouton
b0d3e4dc0d
multi: extract path ID and total amt from received payment
We've covered all the logic for building a blinded path to ourselves and
putting that into an invoice - so now we start preparing to actually be
able to recognise the incoming payment as one from a blinded path we
created.

The incoming update_add_htlc will have an `encrypted_recipient_data`
blob for us that we would have put in the original invoice. From this we
extract the PathID which we wrote. We consider this the payment address
and we use this to derive the associated invoice location.

Blinded path payments will not include MPP records, so the payment
address and total payment amount must be gleaned from the pathID and new
totalAmtMsat onion field respectively.

This commit only covers the final hop payload of a hop in a blinded
path. Dummy hops will be handled in the following commit.
2024-07-26 09:54:18 +02:00
yyforyongyu
d992cf94d6
multi: add SpewLogClosure to avoid code repetition 2024-07-25 22:18:49 +08:00
yyforyongyu
b6049ff94b
multi: add NewLogClosure in lnutils to avoid repetition
And replaces all usage of `logClosure` with `lnutils.LogClosure`.
2024-07-25 21:25:23 +08:00
Tom Kirkpatrick
3837c3f12e
lnwallet: add configurable cache for web fee estimator
Add fee.min-update-timeout and fee.max-update-timeout config options to
allow configuration of the web fee estimator cache.
2024-05-04 14:41:41 +08:00
Carla Kirk-Cohen
43687181f7
htlcswitch: convert blinded failures for blinded payments 2024-04-25 09:47:13 -04:00
Carla Kirk-Cohen
72260adddb
htlcswitch: create error obfuscator with wrapped type for blinded
Create our error encrypter with a wrapped type if we have a blinding
point present. Doing this in the iterator allows us to track this
information when we have both pieces of information available to us,
compared to trying to handle this later down the line:
- Downstream link on failure: we know that we've set a blinding point
  for out outgoing HTLC, but not whether we're introduction or not
- Upstream link on failure: once the failure packet has been sent
  through the switch, we no longer know whether we were the introduction
  point (without looking it up / examining our payload again /
  propagating this information through the switch).
2024-04-25 09:47:11 -04:00
Carla Kirk-Cohen
776c889267
multi: return route role from HopPayload
We need to know what role we're playing to be able to handle errors
correctly, but the information that we need for this is held by our
iterator:
- Whether we had a blinding point in update add (blinding kit)
- Whether we had a blinding point in payload

As we're now going to use the route role return value even when our
err!=nil, we rename the error to signal that we're using less
canonical golang here.

An alternative to this approach is to attach a RouteRole to our
ErrInvalidPayload. The downside of that approach is:
- Propagate context through parsing (whether we had updateAddHtlc)
- Clumsy handling for errors that are not of type ErrInvalidPayload
2024-04-25 09:46:31 -04:00
Carla Kirk-Cohen
c2c0158c84
htlcswitch: handle malformed HTLC with invalid onion blinding code
This commit adds handling for malformed HTLC errors related to blinded
paths. We expect to receive these errors _within_ a blinded path,
because all non-introduction nodes are instructed to return malformed
errors for failures.

Note that we may actually switch back to a malformed error later on if
we too are a relaying node in the route, but we handle that case the
incoming link.
2024-04-25 09:15:56 -04:00
Carla Kirk-Cohen
7e4f3d3b1d
htlcswitch: reject HTLCs that use use as introduction if disabled
Reject any HTLCs that use us as an introduction point in a blinded
route if we have disabled route blinding. We have to do this after
we've processed the payload, because we only know we're an introduction
point once we've processed the payload itself.
2024-04-03 09:19:39 -04:00
Carla Kirk-Cohen
da76d05fa5
htlcswitch: add NextBlinding to ForwardingInfo and set in UpdateAddHtlc
When we have a HTLC that is part of a blinded route, we need to include
the next ephemeral blinding point in UpdateAddHtlc for the next hop. The
way that we handle the addition of this key is the same for introduction
nodes and relaying nodes within the route.
2024-04-03 08:38:24 -04:00
Carla Kirk-Cohen
040fcb0f92
multi: add option to disable route blinding, rejecting at link
Add an option to disable route blinding, failing back any HTLC with
a blinding point set when we haven't got the feature enabled.

Note that this commit only handles the case where we're chosen as the
relaying node (where the blinding point is in update_add_htlc), we'll
add handling for the introduction node case once we get to handling of
blinded payloads).
2024-04-03 08:35:41 -04:00
Joost Jager
e8c97deaef htlcswitch: add receiver-side inbound fee support 2024-03-31 16:49:19 +02:00
Carla Kirk-Cohen
7265e4c9b0
htlcswitch: add incoming amount and to decode hop iterator request
When we have payments inside of a blinded route, we need to know
the incoming amount to be able to back-calculate the amount that
we need to forward using the forwarding parameters provided in the
blinded route encrypted data. This commit adds the payment amount
to our DecodeHopIteratorRequest so that it can be threaded down to
payment forwarding information creation in later commits.
2024-03-27 09:38:58 -04:00
Carla Kirk-Cohen
7bf1daaade
htlcswitch: add blinding point to decode hop iterator request 2024-03-27 09:38:57 -04:00
Keagan McClelland
16be46c1e5 htlcswitch: prevent ChannelLink from leaking ChannelPoint pointer 2024-03-08 15:48:02 -08:00
Keagan McClelland
db39a905cb multi: make NewChanIDFromOutpoint accept value instead of pointer 2024-03-08 15:47:55 -08:00
Keagan McClelland
fd1cd315ce multi: don't leak underlying pointer to LightningChannel.ChannelPoint() 2024-03-08 15:27:19 -08:00
Keagan McClelland
3761912680 htlcswitch: avoid leaking peer interface from link
Here we notice that the only use of the Peer call on the link is
to find out what the peer's pubkey is. To avoid leaking handles to
IO actions outside the interface we reduce the surface area to
just return the peer's public key.
2024-03-06 11:59:09 -08:00
Keagan McClelland
be69b022d9 htlcswitch: remove Switch reference from channelLink 2024-03-05 16:43:29 -08:00