Skip to content

Commit

Permalink
onchain: Document how the expected witness weight for the close tx
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Nov 9, 2022
1 parent 2e4a58e commit 2ac6e48
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bitcoin/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2ac6e48

Please sign in to comment.