On bitcoin wiki site I cant found this specification:

*The stacks hold byte vectors. When used as numbers, byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative 0). Positive 0 is represented by a null-length vector. Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero. *


But on bitcoins source code test scripts I have found this:

["0x02 0x417a", "'Az' EQUAL", "P2SH,STRICTENC"],

["0x4b 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a",
"'Azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' EQUAL", "P2SH,STRICTENC", "push 75 bytes"],


So, as I understand this is test for script module of bitcoin core, and this few tests put numbers into stack, then put byte string into stack and process EQUAL opcode. But in case if numbers should stored in stack as little endian variable int with sign bit (bitcoin wiki) number 0x417a is stored as b'zA' and not as 'Az'.

Number 0x417a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a

will be


What type of numbers representation in stack we have to use?

  • varint little endian with sign bit ? (bitcoin wiki)
  • big endian ?
  • 4 byte big endian ? (found on bitcoin source codes class CScriptNum github.com/bitcoin/bitcoin/blob/master/src/script/script.h#L187)

Where I can read exactly specification ?

Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.