send wip
This commit is contained in:
parent
8afe0009ec
commit
f979cd7376
|
@ -227,6 +227,48 @@ CliLib.prototype.status = function(cb) {
|
|||
};
|
||||
|
||||
CliLib.prototype.send = function(addressTo, amount, message, cb) {
|
||||
var self = this;
|
||||
|
||||
var data = this._loadAndCheck();
|
||||
|
||||
var url = '/v1/wallets/';
|
||||
var signature = _signRequest(url, {}, data.signingPrivKey);
|
||||
|
||||
request({
|
||||
headers: {
|
||||
'x-identity': data.copayerId,
|
||||
'x-signature': signature,
|
||||
},
|
||||
method: 'get',
|
||||
url: _getUrl(url),
|
||||
json: true,
|
||||
}, function(err, res, body) {
|
||||
if (err) return cb(err);
|
||||
if (res.statusCode != 200) {
|
||||
_parseError(body);
|
||||
return cb('Request error');
|
||||
}
|
||||
var wallet = body;
|
||||
|
||||
if (wallet.n > 1 && wallet.status === 'complete' && !data.verified) {
|
||||
var fake = [];
|
||||
_.each(wallet.copayers, function(copayer) {
|
||||
// TODO
|
||||
// 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