watchtower/wtclient/backup_task: correct txweight + update test vectors

This commit is contained in:
Conner Fromknecht
2019-02-06 18:19:58 -08:00
parent 9cd88a04b7
commit fe9f703b5b
2 changed files with 14 additions and 8 deletions

View File

@@ -130,9 +130,6 @@ func (t *backupTask) bindSession(session *wtdb.SessionInfo,
// the watchtower is taking a reward.
var weightEstimate input.TxWeightEstimator
// All justice transactions have a p2wkh output paying to the victim.
weightEstimate.AddP2WKHOutput()
// Next, add the contribution from the inputs that are present on this
// breach transaction.
if t.toLocalInput != nil {
@@ -142,6 +139,15 @@ func (t *backupTask) bindSession(session *wtdb.SessionInfo,
weightEstimate.AddWitnessInput(input.P2WKHWitnessSize)
}
// All justice transactions have a p2wkh output paying to the victim.
weightEstimate.AddP2WKHOutput()
// If the justice transaction has a reward output, add the output's
// contribution to the weight estimate.
if session.Policy.BlobType.Has(blob.FlagReward) {
weightEstimate.AddP2WKHOutput()
}
// Now, compute the output values depending on whether FlagReward is set
// in the current session's policy.
outputs, err := session.Policy.ComputeJusticeTxOuts(
@@ -152,8 +158,8 @@ func (t *backupTask) bindSession(session *wtdb.SessionInfo,
return err
}
t.outputs = outputs
t.blobType = session.Policy.BlobType
t.outputs = outputs
return nil
}