bitcore-payment-protocol
bitcore-payment-protocol copied to clipboard
Fix parsing uint64 fields with values >= 2^32
The amount field in an Output message is 64 bits long and is represented in the JavaScript side using a Long object. When its value is get through the PaymentProtocol interface, it is parsed using the toInt(). toInt() interprets the Long object as 32 bit so amounts larger than 2^32 will be incorrectly parsed i.e. when an output has an amount larger than 42.9 BTC.
The same issue applies to the PaymentDetails/PaymentRequest messages as time and expires fields are uint64 too. If time or expires are larger than 2^32, get operations on those fields will return incorrect values.