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; };