From 3e06a244ddd81e9d0c9e0db0018b3bf55568502e Mon Sep 17 00:00:00 2001 From: Sam Lanning Date: Thu, 11 May 2017 14:37:18 -0700 Subject: [PATCH 1/2] utils: Add clarification to util.isFloat() jsdoc --- lib/utils/util.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/utils/util.js b/lib/utils/util.js index 248e6e42..18fa796f 100644 --- a/lib/utils/util.js +++ b/lib/utils/util.js @@ -392,6 +392,11 @@ util.isHex256 = function isHex256(hash) { /** * Test whether a string qualifies as a float. + * + * This is stricter than checking if the result of parseFloat() is NaN + * as, e.g. parseFloat successfully parses the string '1.2.3' as 1.2, and + * we also check that the value is a string. + * * @param {String?} value * @returns {Boolean} */ From 7379482c32d4c46e12c2c930cb6f16a09c3af9fc Mon Sep 17 00:00:00 2001 From: Sam Lanning Date: Thu, 11 May 2017 15:55:19 -0700 Subject: [PATCH 2/2] btc: remove unneeded radix parameter for parseFloat() --- lib/btc/amount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/btc/amount.js b/lib/btc/amount.js index f0df4f39..0e93a48d 100644 --- a/lib/btc/amount.js +++ b/lib/btc/amount.js @@ -488,7 +488,7 @@ Amount.parse = function parse(value, exp, num) { Amount.parseUnsafe = function parseUnsafe(value, exp, num) { if (typeof value === 'string') { assert(util.isFloat(value), 'Non-BTC value for conversion.'); - value = parseFloat(value, 10); + value = parseFloat(value); } else { assert(util.isNumber(value), 'Non-BTC value for conversion.'); assert(num, 'Cannot parse number.');