I was looking for answer everywhere. Basically is there any way of calculate multi-sig transaction size when the transaction is creating, before the signing procedure? I was trying to find any pattern for that, with no results.

Informations I have:

  • num of inputs;
  • num of outputs;
  • num of required signatures

I will appreciate any clue to solve this problem.

  • Are you asking about transactions with several inputs or about input/output from/to msig-address? – amaclin Sep 18 '14 at 14:19
  • About transaction from multisig address. So I have few transactions belonging to multisig address and I want to send money to whatever address. Before broadcast to the network multisig transaction require signing, in my case two signatures. The base transaction after calling './bitcoin-cli createrawtransaction trans_list recipients' is quite small, after first sign becoming around 1000 bytes and after second 2000 bytes it also depending from how many transactions is coming as input – Mr.Coffee Sep 18 '14 at 14:57
  • OK, next question is: bare multisig output or p2sh multisig? – amaclin Sep 18 '14 at 15:00
  • It is p2sh script, created by './bitcoin-cli createmultisig <num required> <addresses|pubkeys>' – Mr.Coffee Sep 18 '14 at 15:11

SizeOfRedeemScript = 1+n*pubkeySize+1+1
SizeOfScriptSig = 1+m*(1+sigSize)+SizeOfVarIntFor(RedeemScript)+SizeOfRedeemScript
sizeOf(input) = 32+4+SizeOfVarIntFor(SizeOfScriptSig) + SizeOfScriptSig + 4

SizeOfScriptPubKey = SizeOfVarIntFor(lengthOfScript) + len(script)
sizeOf(output) = 8 + SizeOfScriptPubKey

sizeOf(tx) = 4 + SizeOfVarIntFor(numInputs) + sum(SizeOfInputsArray) + SizeOfVarIntFor(numOutputs) + sum(SizeOfOutputsArray) + 4

Basically, once you know m & n (for your multisig), whether public keys are compressed (pubkeySize), plus the number of inputs and outputs, plus the types of outputs, you can come up with a pretty accurate figure for the size.

  • I've added "sum(SizeOfOutputsArray)" to the last line, because it seemed to be missing. – Murch Aug 2 '17 at 18:25
  • @karimkorun what means SizeOfVarIntFor – Goko Gorgiovski Aug 30 '17 at 16:06
  • en.bitcoin.it/wiki/… it's documented here. scripts and vectors are both data-types with variable length, so we prefix them with the length the parser should try to read. They have variable size also, and so are relevant to size estimation :) – karimkorun Jan 14 '18 at 22:20
  • what is len(script) here ? should SizeOfVarIntFor(RedeemScript) be SizeOfVarIntFor(SizeOfRedeemScript) ? is lengthOfScript the same as SizeOfScriptSig? If not, how is lengthOfScript generated? – tipu Dec 26 '18 at 19:15

I stepped over this while trying to solve a similiar question: "how much tx fees do I need to prepare?"... Though this is an older question, I thought it would be good still be ok to reply, so that others might benefit from the same research.


... Signatures are either 73, 72, or 71 bytes long, with probabilities approximately 25%, 50% and 25% respectively, although sizes even smaller than that are possible with exponentially decreasing probability.

Behind the Sigs there is normally the pubkey in hex, adding 33 Bytes for compressed, and 65 Bytes for uncompressed keys. So I calculate for a standard TX roughly 100 Bytes per sig. You already have your figures for inputs and outputs. My std 2 inputs/2 outputs TX is roughly 400Bytes. The Inputs part of a TX depends on the number of

  • 2
    Since the low-S rules was introduced, signature are 50% of the time 72 bytes and 50% of the time 71. – Pieter Wuille Jul 10 '17 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.