lnwallet: use channel type to derive keys

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.
This commit is contained in:
Johan T. Halseth
2020-01-06 11:42:04 +01:00
parent 4fde31229c
commit 5e3718a1b5
8 changed files with 44 additions and 52 deletions

View File

@ -206,9 +206,14 @@ func CreateTestChannels(tweaklessCommits bool) (
}
aliceCommitPoint := input.ComputeCommitmentPoint(aliceFirstRevoke[:])
chanType := channeldb.SingleFunderTweaklessBit
if !tweaklessCommits {
chanType = channeldb.SingleFunderBit
}
aliceCommitTx, bobCommitTx, err := CreateCommitmentTxns(
channelBal, channelBal, &aliceCfg, &bobCfg, aliceCommitPoint,
bobCommitPoint, *fundingTxIn, tweaklessCommits,
bobCommitPoint, *fundingTxIn, chanType,
)
if err != nil {
return nil, nil, nil, err
@ -275,7 +280,7 @@ func CreateTestChannels(tweaklessCommits bool) (
IdentityPub: aliceKeys[0].PubKey(),
FundingOutpoint: *prevOut,
ShortChannelID: shortChanID,
ChanType: channeldb.SingleFunderTweaklessBit,
ChanType: chanType,
IsInitiator: true,
Capacity: channelCapacity,
RemoteCurrentRevocation: bobCommitPoint,
@ -293,7 +298,7 @@ func CreateTestChannels(tweaklessCommits bool) (
IdentityPub: bobKeys[0].PubKey(),
FundingOutpoint: *prevOut,
ShortChannelID: shortChanID,
ChanType: channeldb.SingleFunderTweaklessBit,
ChanType: chanType,
IsInitiator: false,
Capacity: channelCapacity,
RemoteCurrentRevocation: aliceCommitPoint,
@ -305,11 +310,6 @@ func CreateTestChannels(tweaklessCommits bool) (
Packager: channeldb.NewChannelPackager(shortChanID),
}
if !tweaklessCommits {
aliceChannelState.ChanType = channeldb.SingleFunderBit
bobChannelState.ChanType = channeldb.SingleFunderBit
}
aliceSigner := &input.MockSigner{Privkeys: aliceKeys}
bobSigner := &input.MockSigner{Privkeys: bobKeys}