From 2ac6e48f7b31f8df6e838fa132caa96e2edb1596 Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Tue, 18 Oct 2022 16:58:54 +0200 Subject: [PATCH] onchain: Document how the expected witness weight for the close tx --- bitcoin/tx.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bitcoin/tx.c b/bitcoin/tx.c index 401c5464619d..26fdbb9751f4 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -886,12 +886,15 @@ size_t bitcoin_tx_simple_input_weight(bool p2sh) size_t bitcoin_tx_2of2_input_witness_weight(void) { - /* witness[0] = "" - * witness[1] = sig - * witness[2] = sig - * witness[3] = 2 key key 2 CHECKMULTISIG - */ - return 1 + (1 + 0) + (1 + 72) + (1 + 72) + (1 + 1 + 33 + 33 + 1 + 1); + return 1 + /* Prefix: 4 elements to push on stack */ + (1 + 0) + /* [0]: witness-marker-and-flag */ + (1 + 72) + /* [1] Party A signature and length prefix */ + (1 + 72) + /* [2] Party B signature and length prefix */ + (1 + 1 + /* [3] length prefix and numpushes (2) */ + 33 + /* pubkey A (missing prefix) */ + 33 + /* pubkey B (missing prefix) */ + 1 + 1 /* num sigs required and checkmultisig */ + ); } struct amount_sat change_amount(struct amount_sat excess, u32 feerate_perkw,