Bit-Wasp / bitcoin-lib-php

PHP libraries implementing bitcoin key functions, as well as BIP32 and electrum.
The Unlicense
136 stars 86 forks source link

RawTransaction::_decode_script error calculation sctipts #78

Closed mrsol closed 9 years ago

mrsol commented 9 years ago

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 9 years ago

This has been fixed (https://github.com/Bit-Wasp/bitcoin-lib-php/commit/0522e1d854bed2dd4f7b585e825918f5c269f783), apologies for leaving this open so long.