chain-node
Advanced tools
Comparing version 3.0.0-pre3 to 3.0.0-pre4
16
index.js
@@ -111,5 +111,3 @@ var bitcoin = require('bitcoinjs-lib'); | ||
Chain.prototype.signTemplate = function(template, keys) { | ||
var keys = keys.map(function(key) { | ||
return bitcoin.ECKey.fromWIF(key.private_key); | ||
}); | ||
var keys = Signer.keysFromStrings(keys); | ||
return Signer(this.blockChainConfig, template, keys); | ||
@@ -140,8 +138,8 @@ }; | ||
var keys = args.inputs.map(function(input) { | ||
return bitcoin.ECKey.fromWIF(input.private_key); | ||
}); | ||
var keys = Signer.keysFromStrings(args.inputs.map(function(inp) { | ||
return inp.private_key | ||
})); | ||
args.inputs = keys.map(function(key) { | ||
return {address: key.pub.getAddress(blockChainConfig).toString()} | ||
args.inputs = args.inputs.map(function(input) { | ||
return {address: input.address}; | ||
}); | ||
@@ -151,3 +149,3 @@ | ||
if(err == null) { | ||
var signedTemplate = that.signTemplate(resp, keys); | ||
var signedTemplate = Signer(this.blockChainConfig, resp, keys); | ||
that.sendTransaction(signedTemplate, cb); | ||
@@ -154,0 +152,0 @@ } else { |
{ | ||
"name": "chain-node", | ||
"version": "3.0.0-pre3", | ||
"version": "3.0.0-pre4", | ||
"description": "The Official Node.js SDK for Chain's Bitcoin API", | ||
@@ -25,3 +25,4 @@ "main": "index.js", | ||
"request": "2.36.0", | ||
"bitcoinjs-lib": "1.2.0" | ||
"bitcoinjs-lib": "1.2.0", | ||
"bigi": "^1.1.0" | ||
}, | ||
@@ -28,0 +29,0 @@ "files": [ |
@@ -0,1 +1,4 @@ | ||
var BigInteger = require('bigi'); | ||
var bitcoin = require('bitcoinjs-lib'); | ||
module.exports = Sign; | ||
@@ -33,1 +36,15 @@ | ||
}; | ||
Sign.keysFromStrings = function(kstrs) { | ||
var keys = []; | ||
kstrs.forEach(function(kstr) { | ||
if(/^[A-Z0-9]{64}$/i.test(kstr)) { | ||
var big = BigInteger.fromHex(kstr); | ||
keys.push(new bitcoin.ECKey(big, true)); | ||
keys.push(new bitcoin.ECKey(big, false)); | ||
} else { | ||
keys.push(bitcoin.ECKey.fromWIF(kstr)); | ||
} | ||
}); | ||
return keys; | ||
}; |
13113
215
3
+ Addedbigi@^1.1.0