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:
9 files changed
+342
-322
No files matched your search
@@ -356,10 +356,10 @@ func testVectors(t *testing.T, chanType channeldb.ChannelType, test testCase) {
|
||||
|
||||
// Execute commit dance to arrive at the point where the local node has
|
||||
// received the test commitment and the remote signature.
|
||||
localSig, localHtlcSigs, _, err := localChannel.SignNextCommitment()
|
||||
localNewCommit, err := localChannel.SignNextCommitment()
|
||||
require.NoError(t, err, "local unable to sign commitment")
|
||||
|
||||
err = remoteChannel.ReceiveNewCommitment(localSig, localHtlcSigs)
|
||||
err = remoteChannel.ReceiveNewCommitment(localNewCommit.CommitSigs)
|
||||
require.NoError(t, err)
|
||||
|
||||
revMsg, _, _, err := remoteChannel.RevokeCurrentCommitment()
|
||||
@@ -368,18 +368,22 @@ func testVectors(t *testing.T, chanType channeldb.ChannelType, test testCase) {
|
||||
_, _, _, _, err = localChannel.ReceiveRevocation(revMsg)
|
||||
require.NoError(t, err)
|
||||
|
||||
remoteSig, remoteHtlcSigs, _, err := remoteChannel.SignNextCommitment()
|
||||
remoteNewCommit, err := remoteChannel.SignNextCommitment()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, test.RemoteSigHex,
|
||||
hex.EncodeToString(remoteSig.ToSignatureBytes()))
|
||||
require.Equal(
|
||||
t, test.RemoteSigHex,
|
||||
hex.EncodeToString(remoteNewCommit.CommitSig.ToSignatureBytes()),
|
||||
)
|
||||
|
||||
for i, sig := range remoteHtlcSigs {
|
||||
require.Equal(t, test.HtlcDescs[i].RemoteSigHex,
|
||||
hex.EncodeToString(sig.ToSignatureBytes()))
|
||||
for i, sig := range remoteNewCommit.HtlcSigs {
|
||||
require.Equal(
|
||||
t, test.HtlcDescs[i].RemoteSigHex,
|
||||
hex.EncodeToString(sig.ToSignatureBytes()),
|
||||
)
|
||||
}
|
||||
|
||||
err = localChannel.ReceiveNewCommitment(remoteSig, remoteHtlcSigs)
|
||||
err = localChannel.ReceiveNewCommitment(remoteNewCommit.CommitSigs)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, _, _, err = localChannel.RevokeCurrentCommitment()
|
||||
|
||||
Reference in new issue
Block a user