Refactored pukkeyToScript for clarity

This commit is contained in:
Matt 2014-04-01 11:18:31 -06:00
parent e049c413ba
commit bbb759cf37

View File

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