Browse Source

includeExtendedInfo switch

activeAddress
Ivan Socolsky 10 years ago
parent
commit
1007ad1b05
  1. 13
      lib/server.js
  2. 28
      test/integration/server.js

13
lib/server.js

@ -275,17 +275,30 @@ WalletService.prototype.getWallet = function(opts, cb) {
/**
* Retrieves wallet status.
* @param {Object} opts
* @param {Object} opts.includeExtendedInfo - Include PKR info & address managers for wallet & copayers
* @returns {Object} status
*/
WalletService.prototype.getStatus = function(opts, cb) {
var self = this;
opts = opts || {};
var status = {};
async.parallel([
function(next) {
self.getWallet({}, function(err, wallet) {
if (err) return next(err);
var walletExtendedKeys = ['publicKeyRing', 'pubKey', 'addressManager'];
var copayerExtendedKeys = ['xPubKey', 'requestPubKey', 'signature', 'addressManager'];
if (!opts.includeExtendedInfo) {
wallet = _.omit(wallet, walletExtendedKeys);
wallet.copayers = _.map(wallet.copayers, function(copayer) {
return _.omit(copayer, copayerExtendedKeys);
});
}
status.wallet = wallet;
next();
});

28
test/integration/server.js

@ -1140,6 +1140,34 @@ describe('Wallet service', function() {
should.exist(status.preferences);
should.exist(status.pendingTxps);
status.pendingTxps.should.be.empty;
should.not.exist(status.wallet.publicKeyRing);
should.not.exist(status.wallet.pubKey);
should.not.exist(status.wallet.addressManager);
should.not.exist(status.wallet.copayers[0].xPubKey);
should.not.exist(status.wallet.copayers[0].requestPubKey);
should.not.exist(status.wallet.copayers[0].signature);
should.not.exist(status.wallet.copayers[0].requestPubKey);
should.not.exist(status.wallet.copayers[0].addressManager);
done();
});
});
it('should get status including extended info', function(done) {
server.getStatus({
includeExtendedInfo: true
}, function(err, status) {
should.not.exist(err);
should.exist(status);
should.exist(status.wallet.publicKeyRing);
should.exist(status.wallet.pubKey);
should.exist(status.wallet.addressManager);
should.exist(status.wallet.copayers[0].xPubKey);
should.exist(status.wallet.copayers[0].requestPubKey);
should.exist(status.wallet.copayers[0].signature);
should.exist(status.wallet.copayers[0].requestPubKey);
should.exist(status.wallet.copayers[0].addressManager);
done();
});
});

Loading…
Cancel
Save