verify locally that all copayers knew the wallet secret
This commit is contained in:
parent
cb8658d9e3
commit
ecf1e03480
|
@ -1 +0,0 @@
|
|||
{"xPrivKey":"xprv9s21ZrQH143K3bZBVBCEw79fV8AbKQw322xoH8eBdtVu6CdSzSwEkHcry1778QuUdCsedtuD69dNiTT3qmAd3uCMNyybY4wBjieFJPd6NT9","m":1,"secret":"867853bb-b85c-437d-be9c-53024c0c6961:f3fc633bc79bd4e5bff931288d0053cdf9227b69937c56c2fdccc67c7f1229c5","copayerId":"717039bd-80ce-41a7-85db-dc8d838bef9b","signingPrivKey":"23aaf9b8eec6c007710d87892b9a81c9df24fbce26dc931fcefc7cfa299118cf","n":1,"publicKeyRing":["xpub661MyMwAqRbcG5debCjFJF6Q3A15isetPFtQ5X3oCE2sxzxbXzFVJ5wLpJDhRRC5DxTkDpX3Y857LBGBoVXUJ9eQCB2cxPcj1U2BqDfoBnD"]}
|
|
@ -61,6 +61,10 @@ CliLib.prototype._loadAndCheck = function() {
|
|||
log.error('Wallet file not found.');
|
||||
process.exit(1);
|
||||
}
|
||||
if (data.verified == 'corrupt') {
|
||||
log.error('The wallet is tagged as corrupt. Some of the copayers cannot be verified to have known the wallet secret.');
|
||||
process.exit(1);
|
||||
}
|
||||
if (data.n > 1) {
|
||||
var pkrComplete = data.publicKeyRing && data.m && data.publicKeyRing.length === data.n;
|
||||
if (!pkrComplete) {
|
||||
|
@ -198,8 +202,25 @@ CliLib.prototype.status = function(cb) {
|
|||
_parseError(body);
|
||||
return cb('Request error');
|
||||
}
|
||||
var wallet = body;
|
||||
|
||||
return cb(null, body);
|
||||
if (wallet.n > 1 && wallet.status === 'complete' && !data.verified) {
|
||||
var fake = [];
|
||||
_.each(wallet.copayers, function(copayer) {
|
||||
if (!SignUtils.verify(copayer.xPubKey, copayer.xPubKeySignature, data.pubKey)) {
|
||||
fake.push(copayer);
|
||||
}
|
||||
});
|
||||
if (fake.length > 0) {
|
||||
log.error('Some copayers in the wallet could not be verified to have known the wallet secret');
|
||||
data.verified = 'corrupt';
|
||||
} else {
|
||||
data.verified = 'ok';
|
||||
}
|
||||
self._save(data);
|
||||
}
|
||||
|
||||
return cb(null, wallet);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue