watchtower/lookout: use correct to-local-penalty size for anchors

This commit fixes the to-local-witness estimate to use the correct
witness size estimate for anchor channels. We retain the off-by-one bug
from the original constant otherwise.
This commit is contained in:
Conner Fromknecht
2020-09-15 12:48:23 -04:00
parent d440cc4024
commit a0e54a9650
2 changed files with 14 additions and 4 deletions

View File

@@ -192,8 +192,13 @@ func testJusticeDescriptor(t *testing.T, blobType blob.Type) {
// An older ToLocalPenaltyWitnessSize constant used to underestimate the
// size by one byte. The diferrence in weight can cause different output
// values on the sweep transaction, so we mimic the original bug and
// create signatures using the original weight estimate.
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize - 1)
// create signatures using the original weight estimate. For anchor
// channels we fix this and use the correct witness size.
if isAnchorChannel {
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize)
} else {
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize - 1)
}
if isAnchorChannel {
weightEstimate.AddWitnessInput(input.ToRemoteConfirmedWitnessSize)