Commit Graph

302 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
d38c5e6222
lnwallet: update core coop close logic with custom payer
In this commit, we update the core coop close logic with the new custom
payer param. We also expand the existing unit tests to ensure that the
fee is deducted from the proper party.
2024-12-10 23:07:02 +01:00
Keagan McClelland
ed2989ae33
multi: update to fn v2 2024-12-04 13:19:00 -07:00
Elle Mouton
ab7aae0708
multi: rename nolint:lll to nolint:ll
Find and replace all nolint instances refering to the `lll` linter and
replace with `ll` which is the name of our custom version of the `lll`
linter which can be used to ignore log lines during linting.

The next commit will do the configuration of the custom linter and
disable the default one.
2024-12-02 09:14:21 +02:00
Elle Mouton
9f54ec90aa
multi+refactor: move models package to graph/db
All the structs defined in the `channeldb/models` package are graph
related. So once we move all the graph CRUD code to the graph package,
it makes sense to have the schema structs there too. So this just moves
the `models` package over to `graph/db/models`.
2024-11-28 13:34:33 +02:00
yyforyongyu
b243394049
lnwallet: log the amounts in the same unit 2024-11-21 20:42:47 +08:00
ziggie
5486f32444
multi: introduce an option for resolutions
We don't always need the resolutions in the local force close
summary so we make it an option.
2024-11-20 09:18:24 +01:00
Jonathan Harvey-Buschel
dce80ac9a1
lnwallet: test link quit signal handling 2024-10-17 17:35:29 +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
a0baa8fb41
lnwallet: test aux signer shutdown handling 2024-10-17 17:33:15 +02:00
Jonathan Harvey-Buschel
22deba3d26
lnwallet: refactor test code for HTLC add and recv 2024-10-17 17:33:14 +02:00
Jonathan Harvey-Buschel
b3f953b1c4
multi: allow mock aux signer to customize sig jobs 2024-10-17 17:33:14 +02:00
Keagan McClelland
5307e7a5e4
lnwallet: return balance changes rather than modifying references
Here we return the balance deltas from evaluateHTLCView rather than
passing in references to variables that will be modified. It is a
far cleaner and compositional approach which allows readers of this
code to more effectively reason about the code without having to
keep the whole codebase in their head.
2024-10-14 09:40:47 -06:00
Keagan McClelland
f0eecfa2cd
lnwallet: inline and remove process[Add|Remove]Entry
This commit observes that processAddEntry and processRemoveEntry
are only invoked at a single call-site. Here we inline them at their
call-sites, which will unlock further simplifications of the code
that will allow us to remove pointer mutations in favor of explicit
expression oriented programming.

We also delete the tests associated with these functions, the overall
functionality is implicitly tested by the TestEvaluateHTLCView tests.
2024-10-14 09:33:39 -06:00
Keagan McClelland
51c28496a4
lnwallet: simplify fee calculation in evaluateHTLCView
This commit simplifies how we compute the commitment fee rate based
off of the live updates. Prior to this commit we processed all of
the FeeUpdate paymentDescriptors of both ChannelParty's. Now we only
process the last FeeUpdate of the OpeningParty
2024-10-14 09:33:38 -06:00
Keagan McClelland
4b2a4e36ad
lnwallet: pack htlcView.{OurUpdates|TheirUpdates} into Dual.
This commit moves the collection of updates behind a Dual structure.
This allows us in a later commit to index into it via a ChannelParty
parameter which will simplify the loops in evaluateHTLCView.
2024-10-14 09:33:38 -06:00
Keagan McClelland
1b2cb14254
lnwallet: change bool isIncoming to new lntypes.ChannelParty
This commit removes another raw boolean value and replaces it with
a more clear type/name. This will also assist us when we later try
and consolidate the logic of evaluateHTLCView into a single
coherent computation.
2024-10-14 09:33:38 -06:00
Keagan McClelland
d82d02831d
lnwallet: remove mutateState from evaluateHTLCView
In line with previous commits we are progressively removing the
mutateState argument from this call stack for a more principled
software design approach.

NOTE FOR REVIEWERS:
We take a naive approach to updating the tests here and simply
take the functionality we are removing from evaluateHTLCView and
run it directly after the function in the test suite.

It's possible that we should instead remove this from the test
suite altogether but I opted to take a more conservative approach
with respect to reducing the scope of tests. If you have opinions
here, please make them known.
2024-10-14 09:33:16 -06:00
Keagan McClelland
819239c5c8
lnwallet: inline processUpdateFee and remove the function entirely
In this commit we observe that the previous commit reduced the role
of this function to a single assignment statement with numerous newly
irrelevant parameters. This commit makes the choice of inlining it at
the two call-sites within evaluateHTLCView and removing the funciton
definition entirely. This also allows us to drop a huge portion of
newly irrelevant test code.
2024-10-11 11:25:58 +02:00
Keagan McClelland
05347c8392
lnwallet: bring processFeeUpdate in line with process[Add|Remove]Entry
This commit redoes the API and semantics of processFeeUpdate to make
it consistent with the semantics of it's sister functions. This is
part of an ongoing series of commits to remove mutateState arguments
pervasively from the codebase.

As with the previous commit this makes state mutation the caller's
responsibility. This temporarily increases code duplication at the
call-sites, but this will unlock other refactor opportunities.
2024-10-11 11:25:58 +02:00
Keagan McClelland
49add0f57b
lnwallet: eliminate inner-most layer of evil mutateState nonsense
This commit begins the process of moving towards a more principled
means of state tracking. We eliminate the mutateState argument from
processAddEntry and processRemoveEntry and move the responsibility
of mutating said state to the call-sites.

The current call-sites of these functions still have their *own*
mutateState argument which will be eliminated during upcoming commits.
However, following the principle of micro-commits I opted to break
these changes up to make review simpler.
2024-10-11 11:25:52 +02:00
Keagan McClelland
b457b40f80
lnwallet: pack paymentDescriptor add/remove heights into Duals
The purpose of this commit is to begin the process of packing
symmetric fields into the newly introduced Dual structure. The
reason for this is that the Dual structure has a handy indexing
method where we can supply a ChannelParty and get back a value.
This will cut down on the amount of branching code in the main
lines of the codebase logic, making it easier to follow what is
going on.
2024-10-11 11:10:37 +02:00
Olaoluwa Osuntokun
4619cefc8f
lnwallet: add new aux resolver interface
This will be used by external callers to modify the way we resolve
contracts on chain. For a given contract, we'll store an extra "blob",
that will later be presented during the sweeping phase.
2024-10-02 18:09:50 -07:00
Olaoluwa Osuntokun
117a144f4e
lnwallet: add ability to do custom sort for coop close txn 2024-09-19 10:18:40 +02:00
Olaoluwa Osuntokun
517608ca3b
lnwallet: add ability to add extra co-op close outputs 2024-09-19 10:18:40 +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
Keagan McClelland
4fadbb09bd
htlcswitch+lnwallet: quarantine paymentDescriptor to lnwallet
The objective of this commit is to make paymentDescriptor a private
data structure so we can quarantine it to the lnwallet package.
To accomplish this we had to prevent it from leaking out via the
arguments or return values of the public functions in lnwallet.
This naturally had consequences for the htlcswitch package as we
choose other mechanisms for tracking the data that paymentDescriptor
was responsible for.

Astoundingly, this was highly successful and allowed us to remove
a ton of redundant code. The diff for this commit represents a
substantial reduction in total lines of code as well as extraneous
arguments and return values from key functions.

This also sets the stage for future commits where we actually will
be attempting to rid lnwallet of paymentDescriptor completely.
2024-09-10 13:56:56 -07: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
Olaoluwa Osuntokun
b8e39c2311
lnwallet: expand chan sync tests to cover taproot channels
In this commit, we expand some of the existing chan sync tests to cover
taproot channels (the others already did). Along the way, we always
assert that the `PartialSig` is populated on retransmission. In
addition, we now send the new commit sig rather than the existing
in-memory one to test the new logic that re-signs the commitment.
2024-09-03 17:23:48 -07:00
Keagan McClelland
ce7fcd30f8
lnwallet: pack commitment message indices into Dual
This is yet another commit that packs a symmetric structure into
a Dual. This is the last one needed for the time being to consolidate
Num{X}UpdatesPendingOn{Y} functions into a single one.
2024-08-28 14:02:59 -07:00
Keagan McClelland
2e7fbc446f
lnwallet: pack update logs into Dual
This commit, like the last one packs the update logs into a symmetric
Dual structure. This will allow us to index into them more concisely
in higher order logic.
2024-08-28 13:58:33 -07:00
Keagan McClelland
8077862225
lnwallet: pack commit chains into Dual
This commit packs the LightningChannel's localCommitmentChain and
remoteCommitmentChain into a Dual structure for better symmetric
access. This will be leveraged by an upcoming commit where we want
to more concisely express how we compute the number of pending
updates.
2024-08-28 13:51:23 -07:00
Oliver Gugger
9dfbde7013
lnwallet: thread thru input.AuxTapleaf to all relevant areas
In this commit, we start to thread thru the new aux tap leaf structures to all relevant areas. This includes: commitment outputs, resolution creation, breach handling, and also HTLC scripts.
2024-08-28 13:28:48 +02:00
Oliver Gugger
2ab22b0f0b
lnwallet: refactor commit keys to use lntypes.Dual 2024-08-28 13:26:18 +02:00
Oliver Gugger
b45d72fe59
multi: thread thru the AuxLeafStore everywhere 2024-08-28 13:26:14 +02:00
Olaoluwa Osuntokun
669740c84e
channeldb: add custom blobs to RevocationLog+HTLCEntry
This'll be useful for custom channel types that want to store extra information that'll be useful to help handle channel revocation cases.
2024-08-28 13:23:30 +02:00
Olaoluwa Osuntokun
61f276856a
channeldb: convert RevocationLog to use RecordT 2024-08-28 13:22:48 +02:00
Olaoluwa Osuntokun
1b1e7a6168
channeldb: convert HTLCEntry to use tlv.RecordT 2024-08-28 13:21:46 +02:00
Olaoluwa Osuntokun
c1e641e9d9
lnwallet: add TLV blob to PaymentDescriptor + htlc add
In this commit, we add a TLV blob to the PaymentDescriptor struct. We also now thread through this value from the UpdateAddHTLC message to the PaymentDescriptor mapping, and the other way around.
2024-08-28 13:21:12 +02:00
Olaoluwa Osuntokun
12352d9e6e
lnwallet: export the HtlcView struct
We'll need this later on to ensure we can always interact with the new aux blobs at all stages of commitment transaction construction.
2024-08-28 11:52:32 +02:00
Olaoluwa Osuntokun
8588c9bfd7
lnwallet: add initial unit tests for musig2+tapscript root chans 2024-08-28 11:52:31 +02:00
Oliver Gugger
cf2174fc2d
lnwallet: export AnchorSize 2024-08-23 10:58:13 +02:00
Keagan McClelland
935e7f1bee
lnwallet: remove unused parameters in LightningChannel methods 2024-08-05 18:14:11 -07:00
Oliver Gugger
6e63dcd6f9
Merge pull request #8952 from ProofOfKeags/refactor/lnwallet-channel-typed-list
[MICRO]: lnwallet: refactor channel to use new typed List
2024-08-05 02:07:50 -06: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
Keagan McClelland
04c37344ae
lnwallet: refactor channel to use new typed List 2024-07-31 13:03:34 -07: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
yyforyongyu
8da68bb7db
multi: apply the new type lntypes.WeightUnit 2024-05-25 13:37:13 +08:00
Carla Kirk-Cohen
7fd9c2a7f8
multi: use some record for payment descriptor blinding point 2024-04-02 15:44:05 -04:00
Carla Kirk-Cohen
f090a64142
multi: add blinding point to payment descriptor and persist
This commit adds an optional blinding point to payment descriptors and
persists them in our HTLC's extra data. A get/set pattern is used to
populate the ExtraData on our disk representation of the HTLC so that
callers do not need to worry about the underlying storage detail.
2024-03-27 09:38:56 -04:00
Carla Kirk-Cohen
e4f90ec593
lnwire: add blinding point to update_add_htlc TLVs
Add blinding points to update_add_htlc. This TLV will be set for
nodes that are relaying payments in blinded routes that are _not_
the introduction node.
2024-03-27 09:38:50 -04:00