Skip to content

Remove tweakless#3864

Closed
halseth wants to merge 15 commits into
lightningnetwork:masterfrom
halseth:remove-tweakless
Closed

Remove tweakless#3864
halseth wants to merge 15 commits into
lightningnetwork:masterfrom
halseth:remove-tweakless

Conversation

@halseth
Copy link
Copy Markdown
Contributor

@halseth halseth commented Dec 20, 2019

Builds on #3829

halseth and others added 15 commits December 19, 2019 15:14
It was incorrectly stated that the commitment balance was before
subctracting the commit fee, which led to some confusion.
It has no dependency on LightningWallet
Instead of passing delays and dustlimits separately, we pass the correct
channel config to CreateCommitTx from the POV of the local party that
owns the commit tx.

To make it more clear which commitment we are actually creating, we
rename variables to denote local and remote, to prepare for the case
when both outputs might be delayed.
PURE CODE MOVE:
Moving createCommitmentTx, CreateCommitTx, createStateHintObfuscator,
CommitmentKeyRing, DeriveCommitmentKeys, addHTLC, genHtlcScripts

We move the methods and structs to a new file commitment.go in
preparation for defining all the logic that is dependent on the channel
type in this new file.
We define a new struct CommitmentBuilder that will be used to craft the
final commitment transaction based on the current active channel type.
createCommitmentTx would earlier mutate the passed commitment struct
after evaluating the htlc view and calculating the final balances, which
was confusing since the balances are supposed to only be *after*
subtracting fees.

Instead we take the needed parameters as arguments, and return the final
balances, tx and fee to populate the commitment struct in a proper way.
Since both parties are going to have their ouputs delayed, we move way
from the DelayKey naming, and instead use LocalKey and RemoteKey.
We abstract away how keys are generated for the different channel types
types (currently tweak(less)).

Intention is that more of the logic that is unique for each commitment
type lives in commitment.go, making the channel state machine oblivious
to the keys and outputs being created on the commitment tx for a given
channel state.
To make the channel state machine less concerned about the type of
commitment, we nil the local tweak when creating the keyring, depending
on the commitment type.
Based on the current channel type, we derive the script used for the
to_remote output. Currently only the unencumbered p2wkh type is used,
but that will change with upcoming channel types.
Also update the WitnessScript doc to note it should be set also for
p2wkh.
Now that whether or not a the key is tweakless or not is entirely
determined by the channel type and derived keys, we don't have to
specify whether it is tweakless or not. This information is carried by
the sign descriptor.

Co-authored-by: Joost Jager <joost.jager@gmail.com>
@Roasbeef Roasbeef added commitments Commitment transactions containing the state of the channel database Related to the database/storage of LND incomplete WIP PR, not fully finalized, but light review possible labels Jan 7, 2020
@Roasbeef Roasbeef closed this May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commitments Commitment transactions containing the state of the channel database Related to the database/storage of LND incomplete WIP PR, not fully finalized, but light review possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants