|
|
@ -94,9 +94,13 @@ API.prototype._tryToComplete = function(data, cb) { |
|
|
|
if (wallet.status != 'complete') |
|
|
|
return cb('Wallet Incomplete'); |
|
|
|
|
|
|
|
if (!Verifier.checkCopayers(wallet.copayers, data.walletPrivKey, data.xPrivKey, data.n)) |
|
|
|
if (!Verifier.checkCopayers(wallet.copayers, data.walletPrivKey, |
|
|
|
data.xPrivKey, data.n)) { |
|
|
|
|
|
|
|
console.log('[api.js.99]'); //TODO
|
|
|
|
return cb(new ServerCompromisedError( |
|
|
|
'Copayers in the wallet could not be verified to have known the wallet secret')); |
|
|
|
} |
|
|
|
|
|
|
|
data.publicKeyRing = _.pluck(wallet.copayers, 'xPubKey') |
|
|
|
|
|
|
@ -140,8 +144,13 @@ API.prototype._doRequest = function(method, url, args, data, cb) { |
|
|
|
var reqSignature; |
|
|
|
data = data || {}; |
|
|
|
|
|
|
|
if (data.signingPrivKey) |
|
|
|
reqSignature = _signRequest(method, url, args, data.signingPrivKey); |
|
|
|
if (method == 'get') { |
|
|
|
if (data.roPrivKey) |
|
|
|
reqSignature = _signRequest(method, url, args, data.roPrivKey); |
|
|
|
} else { |
|
|
|
if (data.rwPrivKey) |
|
|
|
reqSignature = _signRequest(method, url, args, data.rwPrivKey); |
|
|
|
} |
|
|
|
|
|
|
|
var absUrl = this.baseUrl + url; |
|
|
|
var args = { |
|
|
@ -185,8 +194,9 @@ API.prototype._doGetRequest = function(url, data, cb) { |
|
|
|
|
|
|
|
API.prototype._initData = function(network, walletPrivKey, m, n) { |
|
|
|
var xPrivKey = new Bitcore.HDPrivateKey(network); |
|
|
|
var xPubKey = (new Bitcore.HDPublicKey(xPrivKey)).toString(); |
|
|
|
var signingPrivKey = (new Bitcore.HDPrivateKey(xPrivKey)).derive('m/1/0').privateKey; |
|
|
|
var xPubKey = xPrivKey.toString(); |
|
|
|
var roPrivKey = xPrivKey.derive('m/1/0').privateKey; |
|
|
|
var rwPrivKey = xPrivKey.derive('m/1/1').privateKey; |
|
|
|
var sharedEncryptingKey = Bitcore.crypto.Hash.sha256(walletPrivKey.toBuffer()).slice(0, 16).toString('base64'); |
|
|
|
var copayerId = WalletUtils.xPubToCopayerId(xPubKey); |
|
|
|
|
|
|
@ -197,7 +207,8 @@ API.prototype._initData = function(network, walletPrivKey, m, n) { |
|
|
|
network: network, |
|
|
|
m: m, |
|
|
|
n: n, |
|
|
|
signingPrivKey: signingPrivKey.toWIF(), |
|
|
|
roPrivKey: roPrivKey.toWIF(), |
|
|
|
rwPrivKey: rwPrivKey.toWIF(), |
|
|
|
walletPrivKey: walletPrivKey.toWIF(), |
|
|
|
sharedEncryptingKey: sharedEncryptingKey, |
|
|
|
}; |
|
|
|