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:
parent
d440cc4024
commit
a0e54a9650
@ -284,8 +284,13 @@ func (p *JusticeDescriptor) CreateJusticeTxn() (*wire.MsgTx, error) {
|
|||||||
// An older ToLocalPenaltyWitnessSize constant used to underestimate the
|
// An older ToLocalPenaltyWitnessSize constant used to underestimate the
|
||||||
// size by one byte. The diferrence in weight can cause different output
|
// size by one byte. The diferrence in weight can cause different output
|
||||||
// values on the sweep transaction, so we mimic the original bug to
|
// values on the sweep transaction, so we mimic the original bug to
|
||||||
// avoid invalidating signatures by older clients.
|
// avoid invalidating signatures by older clients. For anchor channels
|
||||||
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize - 1)
|
// we correct this and use the correct witness size.
|
||||||
|
if p.JusticeKit.BlobType.IsAnchorChannel() {
|
||||||
|
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize)
|
||||||
|
} else {
|
||||||
|
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize - 1)
|
||||||
|
}
|
||||||
|
|
||||||
sweepInputs = append(sweepInputs, toLocalInput)
|
sweepInputs = append(sweepInputs, toLocalInput)
|
||||||
|
|
||||||
|
@ -192,8 +192,13 @@ func testJusticeDescriptor(t *testing.T, blobType blob.Type) {
|
|||||||
// An older ToLocalPenaltyWitnessSize constant used to underestimate the
|
// An older ToLocalPenaltyWitnessSize constant used to underestimate the
|
||||||
// size by one byte. The diferrence in weight can cause different output
|
// size by one byte. The diferrence in weight can cause different output
|
||||||
// values on the sweep transaction, so we mimic the original bug and
|
// values on the sweep transaction, so we mimic the original bug and
|
||||||
// create signatures using the original weight estimate.
|
// create signatures using the original weight estimate. For anchor
|
||||||
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize - 1)
|
// channels we fix this and use the correct witness size.
|
||||||
|
if isAnchorChannel {
|
||||||
|
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize)
|
||||||
|
} else {
|
||||||
|
weightEstimate.AddWitnessInput(input.ToLocalPenaltyWitnessSize - 1)
|
||||||
|
}
|
||||||
|
|
||||||
if isAnchorChannel {
|
if isAnchorChannel {
|
||||||
weightEstimate.AddWitnessInput(input.ToRemoteConfirmedWitnessSize)
|
weightEstimate.AddWitnessInput(input.ToRemoteConfirmedWitnessSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user