lnwallet/channel: don't accept immediately on empty htlc sigs
This commit fixes an issue where we would blindly accept a commitment which came without any accompanying HTLC signatures. A test exercising the scenario is added.
This commit is contained in:
2 files changed
+24
-6
No files matched your search
@@ -1530,6 +1530,30 @@ func TestHTLCSigNumber(t *testing.T) {
|
||||
t.Fatalf("Expected Bob to reject signatures")
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
// Test that Bob will reject a commitment if Alice doesn't send any
|
||||
// HTLC signatures.
|
||||
// ===================================================================
|
||||
aliceChannel, bobChannel, cleanUp = createChanWithHTLC(aboveDust)
|
||||
defer cleanUp()
|
||||
|
||||
aliceSig, aliceHtlcSigs, err = aliceChannel.SignNextCommitment()
|
||||
if err != nil {
|
||||
t.Fatalf("Error signing next commitment: %v", err)
|
||||
}
|
||||
|
||||
if len(aliceHtlcSigs) != 1 {
|
||||
t.Fatalf("expected 1 htlc sig, instead got %v",
|
||||
len(aliceHtlcSigs))
|
||||
}
|
||||
|
||||
// Now just give Bob an empty htlcSig slice. He should reject the
|
||||
// commitment because of this.
|
||||
err = bobChannel.ReceiveNewCommitment(aliceSig, []lnwire.Sig{})
|
||||
if err == nil {
|
||||
t.Fatalf("Expected Bob to reject signatures")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TestChannelBalanceDustLimit tests the condition when the remaining balance
|
||||
|
||||
Reference in new issue
Block a user