Browse Source

fix bit client: create, join, status

activeAddress
Ivan Socolsky 10 years ago
parent
commit
c0b7970ff6
  1. 1
      bit-wallet/bit-create
  2. 1
      bit-wallet/bit-join
  3. 24
      bit-wallet/bit-status
  4. 18
      bit-wallet/cli-utils.js
  5. 2
      lib/client/api.js
  6. 1
      test/integration/client.js

1
bit-wallet/bit-create

@ -8,7 +8,6 @@ program = utils.configureCommander(program);
program
.option('-t, --testnet', 'Create a Testnet Wallet')
.option('-n, --nopasswd [level]', 'Set access for no password usage: none(default), readonly, readwrite, full', 'none')
.usage('[options] <walletName> <m-n> [copayerName]')
.parse(process.argv);

1
bit-wallet/bit-join

@ -7,7 +7,6 @@ program = utils.configureCommander(program);
program
.usage('[options] <secret> [copayerName]')
.option('-n, --nopasswd [level]', 'Set access for no password usage: none(default), readonly, readwrite, full', 'none')
.parse(process.argv);
var args = program.args;

24
bit-wallet/bit-status

@ -9,20 +9,20 @@ program
.parse(process.argv);
var args = program.args;
var client = utils.getClient(program);
utils.getClient(program, function (client) {
client.getStatus(function(err, res) {
utils.die(err);
client.getStatus(function(err, res) {
utils.die(err);
var x = res.wallet;
console.log('* Wallet %s [%s]: %d-%d %s ', x.name, x.network, x.m, x.n, x.status);
var x = res.wallet;
console.log('* Wallet %s [%s]: %d-%d %s ', x.name, x.network, x.m, x.n, x.status);
if (x.status != 'complete')
console.log(' Missing copayers:', x.n - x.copayers.length);
console.log('* Copayers:', _.pluck(x.copayers,'name').join(', '));
if (x.status != 'complete')
console.log(' Missing copayers:', x.n - x.copayers.length);
console.log('* Copayers:', _.pluck(x.copayers,'name').join(', '));
var x = res.balance;
console.log('* Balance %s (Locked: %s)', utils.renderAmount(x.totalAmount), utils.renderAmount(x.lockedAmount));
var x = res.balance;
console.log('* Balance %s (Locked: %s)', utils.renderAmount(x.totalAmount), utils.renderAmount(x.lockedAmount));
utils.renderTxProposals(res.pendingTxps);
utils.renderTxProposals(res.pendingTxps);
});
});

18
bit-wallet/cli-utils.js

@ -2,6 +2,7 @@ var _ = require('lodash');
var Client = require('../lib/client');
var FileStorage = require('./filestorage');
var read = require('read')
var log = require('npmlog');
var Utils = function() {};
@ -50,10 +51,19 @@ Utils.getClient = function(args, cb) {
});
storage.load(function(err, walletData) {
if (err && err.code != 'ENOENT') die(err);
if (walletData) {
client.import(walletData);
}
return cb(client);
if (!walletData) return cb(client);
client.import(walletData);
client.openWallet(function(err, justCompleted) {
if (client.isComplete() && justCompleted) {
Utils.saveClient(args, client, function() {
log.info('Your wallet has just been completed. Please backup your wallet file or use the export command.');
return cb(client);
});
} else {
return cb(client);
}
});
});
};

2
lib/client/api.js

@ -329,7 +329,7 @@ API.prototype.joinWallet = function(secret, copayerName, cb) {
};
API.prototype.getStatus = function(cb) {
$.checkState(this.credentials && this.credentials.isComplete());
$.checkState(this.credentials);
var self = this;
self._doGetRequest('/v1/wallets/', function(err, result) {

1
test/integration/client.js

@ -324,6 +324,7 @@ describe('client API ', function() {
});
});
});
it.skip('should return wallet status even if wallet is not yet complete', function(done) {});
});
describe('Address Creation', function() {

Loading…
Cancel
Save