How do you find out the requirements to spend an output script?
Do you decode the hash?
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.Sign up to join this community
I'm assuming you're talking about P2SH addresses here, since that's really the only time this matters.
For standard P2SH addresses, you cannot find the spending requirements by just looking at the address. Let's look at 3DzSVk4veMCkNbNT9CdETeE26uWxmNbBnD from a recent block as an example.
The output script of this address is
a91486ed17bfa7bd80cf87cf7e80abd9289079b78c5b87. This alone simply amounts to
HASH160 PUSHDATA(20)[86ed17bfa7bd80cf87cf7e80abd9289079b78c5b] EQUAL. This means that to spend the tx, you need to provide some input, that once run through HASH160 equals
This is the general format for any P2SH output script. To actually know what kind of script it is, you need the redeem script, which can be found in your wallet. If the address is not one of your own, the redeemscript is revealed when an output to that address is first spent.
Looking at this tx for the above address, we can find the redeemscript as
5221038934160de8ad1dd529329f5bf51e3086cc0f6d19e10fb4120385f23d871c0c1d21021659435e23e3891d39ec2b0266b3c14a68cb4e45adb8543f31508310c98722d952ae (the final push in the script for the input).
Running the above redeemscript through the
decodescript command gives us:
2 038934160de8ad1dd529329f5bf51e3086cc0f6d19e10fb4120385f23d871c0c1d 021659435e23e3891d39ec2b0266b3c14a68cb4e45adb8543f31508310c98722d9 2 OP_CHECKMULTISIG
This identifies the script as a 2of2 multisig.
This could very easily have been any other form of script, such as 2of3 multisig, or not multisig at all. It could even be a segwit address wrapped in a p2sh address. However, just by looking at the address, you cannot determine the type of script. You must have the redeemscript to determine the spending requirements.