onchain: Document how the expected witness weight for the close tx

This commit is contained in:
Christian Decker 2022-10-18 16:58:54 +02:00
parent 7b12d3eb60
commit 5cbd5220d9
1 changed files with 9 additions and 6 deletions

View File

@ -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,