Browse Source

add address verification

activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
1507df1bac
  1. 6
      lib/client/API.js

6
lib/client/API.js

@ -283,14 +283,14 @@ API.prototype.createAddress = function(cb) {
var data = this._loadAndCheck();
var url = '/v1/addresses/';
this._doPostRequest(url, {}, data, function(err, res) {
this._doPostRequest(url, {}, data, function(err, address) {
if (err) return cb(err);
if (data.publicKeyRing.length != data.n)
return cb('Wallet Incomplete, cannot derive address.')
var address = BitcoinUtils.deriveAddress(data.publicKeyRing, res.path, data.m, data.network);
if (address != address.address)
var local = BitcoinUtils.deriveAddress(data.publicKeyRing, address.path, data.m, data.network);
if (local.address != address.address || JSON.stringify(local.publicKeys)!= JSON.stringify(address.publicKeys))
return cb('Server sent a fake address.');

Loading…
Cancel
Save