lnwallet+htlcswitch: add NewCommitState struct, modify send/recv sig to accept

In this commit, we add a new NewCommitState struct. This preps us for
the future change wherein a partial signature is also added to the mix.
All related tests and type signatures have also been updated
accordingly.
This commit is contained in:
Olaoluwa Osuntokun
2023-01-19 18:27:07 -08:00
parent 72d41ae408
commit 11c62e3951
9 changed files with 342 additions and 322 deletions

View File

@@ -495,11 +495,12 @@ func calcStaticFee(chanType channeldb.ChannelType, numHTLCs int) btcutil.Amount
// pending updates. This method is useful when testing interactions between two
// live state machines.
func ForceStateTransition(chanA, chanB *LightningChannel) error {
aliceSig, aliceHtlcSigs, _, err := chanA.SignNextCommitment()
aliceNewCommit, err := chanA.SignNextCommitment()
if err != nil {
return err
}
if err = chanB.ReceiveNewCommitment(aliceSig, aliceHtlcSigs); err != nil {
err = chanB.ReceiveNewCommitment(aliceNewCommit.CommitSigs)
if err != nil {
return err
}
@@ -507,7 +508,7 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error {
if err != nil {
return err
}
bobSig, bobHtlcSigs, _, err := chanB.SignNextCommitment()
bobNewCommit, err := chanB.SignNextCommitment()
if err != nil {
return err
}
@@ -515,7 +516,7 @@ func ForceStateTransition(chanA, chanB *LightningChannel) error {
if _, _, _, _, err := chanA.ReceiveRevocation(bobRevocation); err != nil {
return err
}
if err := chanA.ReceiveNewCommitment(bobSig, bobHtlcSigs); err != nil {
if err := chanA.ReceiveNewCommitment(bobNewCommit.CommitSigs); err != nil {
return err
}