bip21 icon indicating copy to clipboard operation
bip21 copied to clipboard

Add support to schemes with amounts of 15+ digits

Open maribies opened this issue 7 years ago • 4 comments

This PR provides additional support for URN schemes that need to support more than 15 digits, like Ethereum.

maribies avatar Jan 25 '19 18:01 maribies

NACK. This library shouldn't bring in an bignum / bigint library as a dep. Ultimately it should just be a dumb parser and return a string for the number.

jprichardson avatar Jan 25 '19 20:01 jprichardson

The reason I didn't suggest using a dumb parser and simply returning a string was to ensure the precision of the numbers returned for values greater than 15 digits. A bignum 7 bigint lib is a safe way to ensure the larger digit values stay precise, which could be necessary for other urn schemes.

maribies avatar Jan 29 '19 09:01 maribies

returning a string was to ensure the precision of the numbers returned for values greater than 15 digits.

The input data is a string. The output number would be a string. No precision would be lost. This way the consumer of this library and my proposed change can use their favorite big number library and no precision would be lost.

Stated another way, my proposal is just to return options.amount in its string form.

jprichardson avatar Jan 29 '19 13:01 jprichardson

@jprichardson - Got it now. Makes sense. Since it comes in as a string, you're right, and a bignum lib isn't necessary. I removed it from the PR, and only updated to return options.amount as the original parsed string.

maribies avatar Jan 31 '19 00:01 maribies