Skip to content

Commit 5dac1bc

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 2db1153 commit 5dac1bc

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
@@ -1200,7 +1200,10 @@ static u8 *send_commit_part(const tal_t *ctx,
12001200
*anchor = tal(ctx, struct local_anchor_info);
12011201
bitcoin_txid(txs[0], &(*anchor)->anchor_point.txid);
12021202
(*anchor)->anchor_point.n = local_anchor_outnum;
1203-
(*anchor)->commitment_weight = bitcoin_tx_weight(txs[0]);
1203+
/* Actual weight will include witnesses! Note: this assumes
1204+
* 73 byte sigs (worst case as per BOLT), whereas we grind to
1205+
* 71, and so does everyone else. */
1206+
(*anchor)->commitment_weight = bitcoin_tx_weight(txs[0]) + bitcoin_tx_2of2_input_witness_weight() - 4;
12041207
(*anchor)->commitment_fee = bitcoin_tx_compute_fee(txs[0]);
12051208
}
12061209

0 commit comments

Comments
 (0)