Commit Graph

1032 Commits

Author SHA1 Message Date
Carla Kirk-Cohen
2029a06918
multi: return parsed types from payload
To separate blinded route parsing from payload parsing, we need to
return the parsed types map so that we can properly validate blinded
data payloads against what we saw in the onion.
2024-04-03 08:52:25 -04:00
Carla Kirk-Cohen
1e6fae37f7
htlcswitch: add blinding point to sphinx iterator for decoding 2024-04-03 08:52:25 -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
ca6d414308
multi: validate contents in blinded data against payload 2024-04-03 08:38:23 -04:00
Carla Kirk-Cohen
03f6c5cd0a
htlcswitch: add blinding kit to handle encrypted data in blinded routes
This commit introduces a blinding kits which abstracts over the
operations required to decrypt, deserialize and reconstruct forwarding
data from an encrypted blob of data included for nodes in blinded
routes.
2024-04-03 08:38:22 -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
Carla Kirk-Cohen
019b8fa8aa
hop: add function for calculating forwarding amount
Co-authored-by: Calvin Zachman <calvin.zachman@protonmail.com>
2024-04-02 15:44:06 -04:00
Carla Kirk-Cohen
7fd9c2a7f8
multi: use some record for payment descriptor blinding point 2024-04-02 15:44:05 -04:00
Joost Jager
e8c97deaef htlcswitch: add receiver-side inbound fee support 2024-03-31 16:49:19 +02:00
Carla Kirk-Cohen
4a93f4d8d3
multi: pass blinding point through to reconstruction 2024-03-27 09:38:59 -04: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
Carla Kirk-Cohen
d8979d3086
multi: add validation of blinded route encrypted data
Co-authored-by: Calvin Zachman <calvin.zachman@protonmail.com>
2024-03-27 09:36:40 -04:00
Carla Kirk-Cohen
42069ef2f8
htlcswitch: remove unused decode hop iterator 2024-03-27 09:36:37 -04:00
Oliver Gugger
5cb4811e86
Merge pull request #8425 from ProofOfKeags/refactor/lnwallet/chan-point-leaks
[EZ Review]: avoid leaking pointers to authoritative ChannelPoint
2024-03-11 00:55:41 -06: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
cuinix
60bc30dd08 remove repetitive words
Signed-off-by: cuinix <915115094@qq.com>
2024-03-07 14:05:47 +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
Keagan McClelland
38db17b8cc htlcswitch: remove redundant field from channelLink 2024-02-27 17:06:35 -08:00
ffranr
cd566eb097
multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Elle Mouton
5de7792520
htlcswitch: ability to start link in shutdown mode
In this commit, we add the ability to start a link in shutdown mode.
This means that we immediately disable any new HTLC adds in the outgoing
direction and that we queue up a Shutdown message after the next
CommitSig message is sent (or immediately if no CommitSig message is
owed).
2024-02-21 11:57:47 +02:00
Elle Mouton
972f57e9a7
peer+htlcswitch: update Enable/DisableAdds API
In this commit, the `ChannelUpdateHandler`'s `EnableAdds` and
`DisableAdds` methods are adjusted to return booleans instead of errors.
This is done becuase currently, any error returned by these methods is
treated by just logging the error since today all it means is that the
proposed update has already been done. And so all we do today is log the
error. But in future, if these methods are updated to return actual
errors that need to be handled, then we might forget to handle them
correctly at the various call sights. So we instead change the signature
of the function to just return a boolean. In future, if we do need to
return any error, we will have to go inspect every call sight in any
case to fix compliation & then we can be sure we are handling the errors
correctly.
2024-02-21 11:35:11 +02:00
Elle Mouton
71753af8ee
multi: fix various typos 2024-02-21 11:35:10 +02:00
Keagan McClelland
94373bd96f htlcswitch: placate confused linter 2024-01-23 12:25:06 -08:00
Keagan McClelland
ec55831229 htlcswitch+peer: remove ShutdownIfChannelClean 2024-01-22 16:08:59 -08:00
Keagan McClelland
64fda6ca65 htlcswitch: implement flush and commit lifecycle hooks for channelLink 2024-01-22 16:08:55 -08:00
Keagan McClelland
601afaf1b2 htlcswitch: implement flush api for channelLink 2024-01-22 12:19:58 -08:00
Keagan McClelland
891b00d473 htlcswitch: drop the connection when receiving an invalid add
When the link is flushing in the incoming direction, it means
adds are invalid. The best chance we have at dealing with this
is to drop the connection. This should roll back the channel
state to the last CommitSig. If the remote has already sent a
CommitSig we haven't received yet, channel state will be
re-synchronized with a ChannelReestablish message upon
reconnection and the protocol state that caused us to flush
the link will be rolled back. In the event that there was some
non-deterministic behavior in the remote that caused them to
violate the protocol, we have a decent shot at correcting it
this way, since reconnecting will put us in the cleanest
possible state to try again.
2024-01-22 12:19:58 -08:00
Keagan McClelland
a9d5235c62 htlcswitch: bounce downstream adds when flushing 2024-01-22 12:19:58 -08:00
Keagan McClelland
70292253d1 htlcswitch: make link forward eligibility flush aware 2024-01-22 12:19:58 -08:00
Keagan McClelland
9b2d1018f2 htlcswitch+peer: add flush api and lifecycle hooks to ChannelUpdateHandler
We also add dummy implementations to channelLink and various mocks.
2024-01-22 12:19:58 -08:00
Matt Morehouse
0f5ee7cc1e
htlcswitch: update fuzzPayload for route blinding
Route blinding added some new fields to hop.Payload and route.Hop, which
we need to copy over to the fuzzPayload tests.
2024-01-16 11:12:11 -06:00
ziggie
0b63989f3a
lnwallet+htlcswitch: Introduce a fee buffer.
We take into account a fee buffer of twice the current fee rate
of the commitment transaction plus an additional htlc output
when we are the opener of the channel hence pay when publishing the
commitment transaction. This buffer is not consensus critical
because we only consider it when we are in control of adding a
new htlc to the state. The goal is to prevent situations
where we push our local balance below our channel reserve due to
parallel adding of htlcs to the state. Its not a panacea for these
situations but until we have __option_simplified_update__ deployed
widely on the network its a good precaution to protect against
fee spikes and parallel adding of htlcs to the update log.

Moreover the way the available balance for a channel changed.
We now need to account for a fee buffer when we are the channel
opener. Therefore all the tests had to be adopted.
2024-01-06 20:52:46 +01:00
Carla Kirk-Cohen
af4fdcc1fd
htlcswitch/test: allow missing field errors in payload decode 2023-12-18 11:27:56 -05:00
Carla Kirk-Cohen
69d5496e7c
multi: update payload validation to account for blinded routes 2023-12-18 11:27:55 -05:00
Carla Kirk-Cohen
343a6ed831
hltcswitch/hop: add next hop to intermediate hop with custom records
Fix our existing test to have a valid intermediate hop that will pass
stricter validation. Previously, we did not specify a next channel for
an intermediate hop (which violates bolt4).
2023-12-18 11:27:53 -05:00
Carla Kirk-Cohen
585f28c5f5
multi: explicitly signal final hop in pack hop payload
Previously, we'd use the value of nextChanID to infer whether a payload
was for the final hop in a route. This commit updates our packing logic
to explicitly signal to account for blinded routes, which allow zero
value nextChanID in intermediate hops. This is a preparatory commit
that allows us to more thoroughly validate payloads.
2023-12-18 11:27:52 -05:00
Carla Kirk-Cohen
b5afd905d1
htlcswitch/hop: explicitly signal final hop from sphinx packet
Previously, we were using nextChanID to determine whether a hop
payload is for the final recipient. This is no longer suitable in a
route-blinding world where intermediate hops are allowed to have zero
nextChanID TLVs (as this information is provided to forwarding nodes
in their encrypted data). This commit updates payload reading to use
the signal provided by sphinx that we are on the last packet, rather
than implying it from the contents of a hop.
2023-12-18 11:27:51 -05:00
Carla Kirk-Cohen
2f8587341a
htlcswitch/test: do not set amount and cltv for blinded test cases 2023-12-18 11:27:50 -05:00
Carla Kirk-Cohen
fa78d21975
htlcswitch/test: add sphinx action to decoding test
Update test to include the sphinx action to more closely represent
reality. This will be required when we add more validation to the
presence of a nextChanID field. A MoreHops action is chose because
we're testing the case with a payload that contains forwarding info.
2023-12-18 11:27:48 -05:00
Carla Kirk-Cohen
b0870ea2ed
htlcswitch/test: add encrypted data to blinded intermediate hop
Blinding points will always be accompanied by encrypted data, so
update the test to more accurately represent reality.
2023-12-12 10:01:26 -05:00
Elle
4fa483f1bc
Merge pull request #7702 from ellemouton/towerClientMux
wtclient: Tower Client Multiplexer
2023-12-05 12:27:05 +02:00
Elle Mouton
fcfdf699e3
multi: move BackupState and RegisterChannel to Manager
This commit moves over the last two methods, `RegisterChannel` and
`BackupState` from the `Client` to the `Manager` interface. With this
change, we no longer need to pass around the individual clients around
and now only need to pass the manager around.

To do this change, all the goroutines that handle channel closes,
closable sessions needed to be moved to the Manager and so a large part
of this commit is just moving this code from the TowerClient to the
Manager.
2023-11-28 10:59:40 +02:00
yyforyongyu
85f4b13632
multi: enhance logging around channel reestablishment 2023-11-28 14:06:53 +08:00
yyforyongyu
09a5d235ec
routing: fail attempt when no shard is found or circuit generation fails 2023-11-13 16:09:11 +08:00
Oliver Gugger
e1fb1e484a
Merge pull request #7967 from morehouse/fuzz_onion
htlcswitch: fuzz onion encoding/decoding
2023-10-19 15:30:03 +00:00
Oliver Gugger
82838e4a62
Merge pull request #8090 from ziggie1984/add-additional-log-chan-closure
Add more information when a co-op close is failing.
2023-10-17 10:27:21 +00:00