4

I am trying to understand the output from bitcoin-cli. The sample transaction's txid is 061959f1a3360d3781a870b2d43f73f7105b194b22f3765fcb9b8f545f9c8317, from block 222,222.

The asm section of scriptPubKey (i.e., OP_DUP OP_HASH160 28dce60cf7ba4d749afce5fd9781a403d293b74a OP_EQUALVERIFY OP_CHECKSIG) is more understandable, it decodes hex and shows the assembly in a (sort of) human-readable format:

"vout": [
    {
      "value": 0.63918136,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 28dce60cf7ba4d749afce5fd9781a403d293b74a OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a91428dce60cf7ba4d749afce5fd9781a403d293b74a88ac",
        "address": "14j4eyoxaAwA4SHj9YcEyVJ7FsqyWvUh9B",
        "type": "pubkeyhash"
      }
    },
...
]

The question arises when it comes to the asm section of scriptSig:

{
  "txid": "b66e78c919e36a6c563ceb1b29cfec26f7dec3c3fc1b3631c84056f3ae147f2f",
  "vout": 1,
  "scriptSig": {
    "asm": "3045022100dceb566dec99cf195aba5d6313f1e95eb7bfc74c93a794c4bfd6dd9f4082d8a002203b495b70b917b3dffdcbe70fc6ff7de910d1697efccc14f3eea6944bda87d21c[ALL] 0445554717c4d3240d818f400ab66fd4de438f2fd9174641ea76480b95cd6e883ec274a10b0691d85ac2cb87dcb9eef58b3abb8ee4bd277c8d6fea09eace2bc24a",
    "hex": "483045022100dceb566dec99cf195aba5d6313f1e95eb7bfc74c93a794c4bfd6dd9f4082d8a002203b495b70b917b3dffdcbe70fc6ff7de910d1697efccc14f3eea6944bda87d21c01410445554717c4d3240d818f400ab66fd4de438f2fd9174641ea76480b95cd6e883ec274a10b0691d85ac2cb87dcb9eef58b3abb8ee4bd277c8d6fea09eace2bc24a"
}

As you can see, it is 304502206ee08c76923816e4ba287142e9f147fe9cd0f26e6bd58b9a43f2283b1c614f46022100d5de298b627407bc7d5ac0a40259cafb865c30c6a67db926c7284da96ff71abd[ALL] 040841958a405ca1c05de4dcf04dfdfd6e7de5e7cb106744977e3d99eab3e59a2b5bc2441e0ad179055c14200745feb2da2d1b4485087e3a9a2a88a6531a6d6b02, which is not decoded at all.

I checked the same transaction from blockstream.info. It's result is: OP_PUSHBYTES_72 304502206ee08c76923816e4ba287142e9f147fe9cd0f26e6bd58b9a43f2283b1c614f46022100d5de298b627407bc7d5ac0a40259cafb865c30c6a67db926c7284da96ff71abd01 OP_PUSHBYTES_65 040841958a405ca1c05de4dcf04dfdfd6e7de5e7cb106744977e3d99eab3e59a2b5bc2441e0ad179055c14200745feb2da2d1b4485087e3a9a2a88a6531a6d6b02 which looks more readable and I can understand that this scriptSig pushes two bytes arrays into the Bitcoin's stack.

So the questions are:

  1. Why bitcoin-cli's output is like this?
  2. How to interpret it? Especially, how to understand the [ALL] part in its asm?

EDIT:

While the answer below is quite informative, the issue I raised on Bitcoin Core's Github is worth taking a look as well.

1 Answer 1

2

The asm section is a symbolic representation of a Bitcoin script. For inputs, the scriptSig is the "unlocking script," proving that the input can be spent in this transaction.

In your specific example, the scriptSig asm can be broken down as follows:

  • 304..abd is the DER encoding of an ECDSA signature. You can find more information about this structure here: What are the DER signature and SEC format
  • [ALL] is the sighash flag, indicating the signature is for all inputs and outputs. This is the most common sighash flag
  • 044...24a is the public key of the input

bitcoin-cli does not give the human-readable OP_CODE names when translating from hex to asm, but different block explorers may do so. This explains why you saw a different representation when looking up the transaction with https://blockstream.info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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