Bit-Wasp/bitcoin-lib-php

RawTransaction::_decode_script error calculation sctipts

mrsol opened this issue · 1 comments

In block

} else if ($code <= 78) {
                // In this range, 2^($code-76) is the number of bytes to take for the *next* number onto the stack.
                $szsz = 2 ^ ($code - 76); // decimal number of bytes.
                $sz = hexdec(substr($script, $pos, ($szsz * 2))); // decimal number of bytes to load and push.
                $pos += $szsz;
                $push = substr($script, $pos, ($pos + $sz * 2)); // Load the data starting from the new position.
                $pos += $sz * 2;
            }

$szsz = 2 ^ ($code - 76); ^ is not function as pow, this is binary operation, nead use function pow
write code
$szsz = pow(2, ($code - 76));
and
$pos += $szsz; wrong set new position
nead
$pos += $szsz *2;

afk11 commented

This has been fixed (0522e1d), apologies for leaving this open so long.