Skip to content

Commit 70f0513

Browse files
committed
channeld: be more accurate with the weight of commitment txs.
We didn't add the weight of the two sigs! The BOLT defines that to be a worst-case 73 byte sig, but that turns out to be an overestimate (and this is not required for consensus) so we assume everyone grinds. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 65a145f commit 70f0513

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

channeld/channeld.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,10 @@ static u8 *send_commit_part(const tal_t *ctx,
11991199
*anchor = tal(ctx, struct local_anchor_info);
12001200
bitcoin_txid(txs[0], &(*anchor)->anchor_point.txid);
12011201
(*anchor)->anchor_point.n = local_anchor_outnum;
1202-
(*anchor)->commitment_weight = bitcoin_tx_weight(txs[0]);
1202+
/* Actual weight will include witnesses! Note: this assumes
1203+
* 73 byte sigs (worst case as per BOLT), whereas we grind to
1204+
* 71, and so does everyone else. */
1205+
(*anchor)->commitment_weight = bitcoin_tx_weight(txs[0]) + bitcoin_tx_2of2_input_witness_weight() - 4;
12031206
(*anchor)->commitment_fee = bitcoin_tx_compute_fee(txs[0]);
12041207
}
12051208

0 commit comments

Comments
 (0)