From bbb759cf37e6581591fabcd2d7c9da41c8d16b11 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 1 Apr 2014 11:18:31 -0600 Subject: [PATCH] Refactored pukkeyToScript for clarity --- lib/util.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/util.js b/lib/util.js index f98bcd3..6ebad6f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -243,15 +243,14 @@ exports.getVersionByte = function(addr){ For POS coins - used to format wallet address for use in generation transaction's output */ exports.pubkeyToScript = function(key){ - if (key.length === 66) key = new Buffer(key, 'hex'); - if (key.length !== 33){ + if (key.length !== 66) { console.error('Invalid pubkey: ' + key); throw new Error(); } var pubkey = new Buffer(35); pubkey[0] = 0x21; pubkey[34] = 0xac; - key.copy(pubkey, 1); + new Buffer(key, 'hex').copy(pubkey, 1); return pubkey; };