From 0f2a69bb6a9d51c0c38562f1b82516fcb91074e6 Mon Sep 17 00:00:00 2001 From: Stefan Thomas Date: Fri, 4 Jan 2013 09:46:41 +0100 Subject: [PATCH] More robust input type handling for Uint160.from_json(). --- src/js/amount.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/amount.js b/src/js/amount.js index 0c1387b0..7af56b99 100644 --- a/src/js/amount.js +++ b/src/js/amount.js @@ -263,9 +263,13 @@ UInt160.from_generic = function (j) { // Return a new UInt160 from j. UInt160.from_json = function (j) { - return 'string' === typeof j - ? (new UInt160()).parse_json(j) - : j.clone(); + if ('string' === typeof j) { + return (new UInt160()).parse_json(j); + } else if (j instanceof Uint160) { + return j.clone(); + } else { + return new UInt160(); + } }; UInt160.is_valid = function (j) {