core: Fix bug when converting OP_0 to long (#5948)

This commit is contained in:
Chris Stewart 2025-03-03 06:32:14 -06:00 committed by GitHub
parent c6d83199bf
commit ed66937d01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -54,7 +54,10 @@ trait ScriptNumberUtil {
*/
def toLong(bytes: ByteVector): Long = {
val reversedBytes = bytes.reverse
if (bytes.size == 1 && bytes.head == -128) {
if (bytes.isEmpty) {
0
} else if (bytes.size == 1 && bytes.head == -128) {
// the case for negative zero
0
} else if (isPositive(bytes)) {