Bitcoin `required_signatures` field

Hi there-- Is it possible to retrieve required_signatures from the standard bitcoin RPC you all offer? I’m looking through the getrawtransaction method and I cant seem to find this metric anywhere. Is this in a different method perhaps?

Google BigQuery has this in their bitcoin tables (pictured) and was wondering if you all can provide the same data via RPC

Docs reference: getrawtransaction RPC Method | Bitcoin Documentation (edited)

Hi @brandon,

You are on the right path, but you’ll need a few more things to get that info.

Once you get the raw transaction hash using getrawtransaction, you’ll have to use that hash to send another RPC decoderawtransaction

In the output, look for, result → vout → scriptPubKey → asm

The first value in the asm field will tell you the number of required signatures.

Hey @sahil!

Thanks for the response. I’m relatively new to bitcoin data, so I am still trying to figure things out.

I can now see that the asm field contains some information related to the number of required signatures. This is especially easy to see when the type field is multisig – The number of required signatures is the first digit like you mentioned.

What about transactions where there are 1 or zero required signatures? Taking the transaction hash 07919cc746d81a573df5eddecf60318d8b14cbbfb763a2d713a900800be23093 as an example, is it fair to say this transaction has 1 required signature because the asm field contains one hash (ed2df340433f6f48b5a66c9844092223c87ceeaf)?

// asm field for index 0 of vout
OP_DUP OP_HASH160 ed2df340433f6f48b5a66c9844092223c87ceeaf OP_EQUALVERIFY OP_CHECKSIG

The asm field for the other output is

// asm field for index 1 of vout
0 ffcd71d2a8532742d1b72c55e376253b50b98c86

so I’m assuming index 1 doesn’t tell us anything about the number of signatures? It has zero as the first digit, but this transaction has 1 required signature according to BigQuery.

Also-- is there a way to systematically determine the number of required signatures? Perhaps the type field in asm? Seems like anything with the multisig type will have the number of required signatures as the first digit and then anything with OP_DUP has 1 required signature.

Thanks again for your help! Really appreciate it.

You could also look at the type field check for the following details

The type field in the decoded transaction output data is indeed a good indicator of how many signatures are required:

  • pubkeyhash or witness_v0_keyhash: Requires one signature (as in P2PKH or P2WPKH).
  • multisig: The number of required signatures will be explicitly stated as the first digit in the asm (as in M-of-N multisig scripts).
  • scripthash or witness_v0_scripthash: Could require more than one signature if it wraps a multisig script. You would need to look at the redeemScript or witnessScript to determine the exact number.
1 Like

Good to know – thank you for the help!

1 Like