From 335d0dcd9688a3a46ed99d2c27473ef43be0d2d4 Mon Sep 17 00:00:00 2001 From: vub Date: Mon, 21 Oct 2013 15:27:50 -0400 Subject: [PATCH] bugfix --- src/address.js | 6 +++++- src/script.js | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/address.js b/src/address.js index 97df02a..9f701c8 100644 --- a/src/address.js +++ b/src/address.js @@ -14,7 +14,11 @@ var p2sh_types = { }; var Address = function (bytes, version) { - if (typeof bytes === 'string') { + if (arguments[0] instanceof Address) { + this.hash = arguments[0].hash; + this.version = arguments[0].version; + } + else if (typeof bytes === 'string') { this.hash = bytes.length <= 34 ? base58.checkDecode(bytes) : bytes.length <= 40 ? conv.hexToBytes(bytes) diff --git a/src/script.js b/src/script.js index 865e9ac..224ec79 100644 --- a/src/script.js +++ b/src/script.js @@ -296,6 +296,7 @@ Script.prototype.writeBytes = function (data) Script.createOutputScript = function (address) { var script = new Script(); + address = new Address(address); // Standard pay-to-pubkey-hash if (!address.version) { script.writeOp(Opcode.map.OP_DUP);