-
Notifications
You must be signed in to change notification settings - Fork 292
Description
Now that BigInts are available in node since v10.4, we can stop using https://github.com/chjj/n64.
Since bcoin-org/bufio#3 and some fixes [email protected]
also support BigInts, that we can use to replace serializers.
The value currently in Output.value, ScriptNum, Coin are Numbers which don't allow arithmetic operations after Number.MAX_SAFE_INTEGER and that's the current limit, where it should actually be full u64. Also simplifies the maintenance for the project, as n64 is using nan
for the C implementation and can always break (different from napi which has some guarantees to breaking API).
Output.value is safe because consensus.MAX_MONEY is lower than Number.MAX_SAFE_INTEGER(2^53-1)
.
ScriptNum on the other hand can be anything within the range(-2^63-1 ~ 2^63 - 1) even though operands themselves should be int32 - results can overflow into int64.
https://github.com/bitcoin/bitcoin/blob/7f0b79ea132d22ad5212c1d3ff4325715ca5ac12/src/script/script.h#L222-L231