Script - OP_SIZE

2

Does the OP_SIZE operation in Script push one item onto the stack (length of the string), or two (string and its length)?

ThePiachu

Posted 2011-12-26T15:34:07.597

Reputation: 41 594

Answers

3

It pushes one item onto the stack, the size of the item on the top of the stack. The item whose size it pushes onto the stack is not consumed, it becomes the second item on the stack.

Here's the source code:

            case OP_SIZE:
            {
                // (in -- in size)
                if (stack.size() < 1)
                    return false;
                CBigNum bn(stacktop(-1).size());
                stack.push_back(bn.getvch());
            }
            break

David Schwartz

Posted 2011-12-26T15:34:07.597

Reputation: 46 931