signature – Can somebody clarify easy methods to get from SigScript to one thing readable

0
50


Bitcoin bases its logic of fee (locking) and spending (unlocking) funds on a scripting language and a stack. Every byte inside uncooked sigScript has its personal that means. Bytes will be divided into two main varieties. Bytes that point out which operation ought to be carried out on the stack and bytes that point out information. The primary sort represents opcodes. For instance, the byte 0xae has a particular that means and signifies the OP_CHECKMULTISIG opcode. You’ll find a listing of all opcodes right here.

Wanting on the instance you supplied, the uncooked scriptSig appears like this (opcodes are in daring, the remaining is information):

0047304402201c45383cc6e43202ed069e36184a97bf5dd489c6bea1372629540dea154c424902200a950b3557bba9ae9531237d46e6eb1afffd01eba989c3e53adaac443e5e2a2e01473044022032a681fb77589ce1a29a84494a6f9cb19630fcd65480ff646f30d8b826980390022006dc71baba1142abb275bbf3613b2a13b347bac4d09d41ccd9b69b02c270d8c2014c69522103745aaaf364030720b2d14de50a3310eef521c91e36353dca20813713535c005a2102db8911b3989b43c43d8dd6e50459bd85c38faf3b2862eb78ef297002775a10bd210351e3f71b7cf9a5f5f86c1908fee02ebf5a1ed77b6748f7486505d155833645f253ae

Due to this fact, the primary byte (0x00) represents one of many opcodes and signifies the operation OP_0, i.e. that it’s essential to push an empty array onto the stack. The subsequent byte (0x47) additionally has a particular that means (opcode) which signifies that the following 71 bytes characterize the information to be pushed onto the stack. After the information (the earlier 71 bytes), the byte 0x47 (opcode) follows once more, indicating the pushing of the following 71 bytes. This information is adopted by the byte 0x4c. The given byte signifies the opcode OP_PUSHDATA1. Based on that opcode, the following byte signifies the size of the information (on this case 0x69; 105 decimal), adopted by the information of the given size that ought to be pushed onto the stack.

Primarily based on every thing beforehand written, scriptSig in human readable kind appears like this:

OP_0
OP_PUSHBYTES_71
304402201c45383cc6e43202ed069e36184a97bf5dd489c6bea1372629540dea154c424902200a950b3557bba9ae9531237d46e6eb1afffd01eba989c3e53adaac443e5e2a2e01
OP_PUSHBYTES_71
3044022032a681fb77589ce1a29a84494a6f9cb19630fcd65480ff646f30d8b826980390022006dc71baba1142abb275bbf3613b2a13b347bac4d09d41ccd9b69b02c270d8c201
OP_PUSHDATA1
69
522103745aaaf364030720b2d14de50a3310eef521c91e36353dca20813713535c005a2102db8911b3989b43c43d8dd6e50459bd85c38faf3b2862eb78ef297002775a10bd210351e3f71b7cf9a5f5f86c1908fee02ebf5a1ed77b6748f7486505d155833645f253ae

Lastly, it ought to be famous that for the reason that P2SH output is consumed, the final push in scriptSig represents the redeem script. Due to this fact, the content material of that final push (redeem script) isn’t solely handled as information pushed onto the stack, however the content material can also be handled as a script with its opcodes and information.

Exactly due to this, the next content material (the final push in scriptSig – redeem script)

522103745aaaf364030720b2d14de50a3310eef521c91e36353dca20813713535c005a2102db8911b3989b43c43d8dd6e50459bd85c38faf3b2862eb78ef297002775a10bd210351e3f71b7cf9a5f5f86c1908fee02ebf5a1ed77b6748f7486505d155833645f253ae

doesn’t solely point out information, however is itself a script with opcodes and information. The best way this was decoded, that’s, offered in human readable format is as follows (taken from the positioning mempool.house):

OP_PUSHNUM_2
OP_PUSHBYTES_33
03745aaaf364030720b2d14de50a3310eef521c91e36353dca20813713535c005a
OP_PUSHBYTES_33
02db8911b3989b43c43d8dd6e50459bd85c38faf3b2862eb78ef297002775a10bd
OP_PUSHBYTES_33
0351e3f71b7cf9a5f5f86c1908fee02ebf5a1ed77b6748f7486505d155833645f2
OP_PUSHNUM_3
OP_CHECKMULTISIG

Every little thing beforehand written represents the best way wherein the uncooked scriptSig is decoded right into a human readable format, and the best way wherein bitcoin nodes know easy methods to correctly execute the script.

LEAVE A REPLY

Please enter your comment!
Please enter your name here