Bit-Wasp/bitcoin-lib-php

Unnecessary cast in toBTC()

hlynx opened this issue · 0 comments

hlynx commented

/src/BitcoinLib.php [1011]

public static function toBTC($satoshi)
{
    return bcdiv((int)(string)$satoshi, 100000000, 8);
}

Looks like it will silently fail on type overflow with 32-bit integer.
bcdiv works with strings. So omiting that cast looks apropriate:

bcdiv((string)$satoshi, 100000000, 8);