From bitcoin-cli help decodescript
:
{
"asm":"asm", (string) Script public key
"type":"type", (string) The output type (e.g. nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_scripthash, witness_v0_keyhash, witness_unknown)
"reqSigs": n, (numeric) The required signatures
"addresses": [ (json array of string)
"address" (string) bitcoin address
,...
],
"p2sh":"str" (string) address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH).
"segwit": { (json object) Result of a witness script public key wrapping this redeem script (not returned if the script is a P2SH or witness).
"asm":"str", (string) String representation of the script public key
"hex":"hexstr", (string) Hex string of the script public key
"type":"str", (string) The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)
"reqSigs": n, (numeric) The required signatures (always 1)
"addresses": [ (json array of string) (always length 1)
"address" (string) segwit address
,...
],
"p2sh-segwit":"str" (string) address of the P2SH script wrapping this witness redeem script.
}
Additional explanation, using your example:
n35oDVMPNkHRzBKy7q9RDB7r5e8qbVa9SW
: this is a "legacy" pay-to-pubkey-hash address. Coins sent to this address are locked with the asm
script you see in the output. They can be unlocked with a scriptSig
that contains the public key that matches the hash, followed by a signature matching the public key.
p2sh: 2NFyoZJJuWpvyiHFirFqsQnPXXna6mtf4Li
: This one is a bit confusing. It is still a "legacy" (not segwit) address, and it is a pay-to-script-hash address. Coins sent to this address are locked with a hash of the entire script you see above in asm
. They are spent by pushing a scriptSig
with the entire serialized script (DUP/HASH/EQUAL/CHECKSIG) followed by the public key and finally the signature.
segwit: tb1qajgv52xqasczaxglk8ypwxl5nsxn6pd7307tfg
: Here is a segwit address. BIP141 defines a few segwit address types and this one, as you can see, is a pay-to-witness-pubkey-hash or witness_v0_keyhash
or p2wpkh address. Coins sent to this address are locked with a hash of a public key only (along with a specific byte that indicates segregated witness). They are spent by pushing an EMPTY scriptSig
and providing a witness
stack that has the public key and signature.
p2sh-segwit: 2MwgL2byHmKdRvfGhufKpJkpAvtDLpo1REs
: Another segwit address. This one, as you can see, is a NESTED pay-to-witness-pubkey-hash or p2wpkh-p2sh address. Coins sent to this address are locked with a hash of the witness program seen in the asm
section of the segwit
section. They are spent by providing the serialized witness program in a scriptSig
and ALSO including a witness stack with public key and signature.
Summary
If you have one private key, you can spend coins sent to any of these four addresses.