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 program
.option('-t, --testnet', 'Create a Testnet Wallet') .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]') .usage('[options] <walletName> <m-n> [copayerName]')
.parse(process.argv); .parse(process.argv);

1
bit-wallet/bit-join

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

24
bit-wallet/bit-status

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

18
bit-wallet/cli-utils.js

@ -2,6 +2,7 @@ var _ = require('lodash');
var Client = require('../lib/client'); var Client = require('../lib/client');
var FileStorage = require('./filestorage'); var FileStorage = require('./filestorage');
var read = require('read') var read = require('read')
var log = require('npmlog');
var Utils = function() {}; var Utils = function() {};
@ -50,10 +51,19 @@ Utils.getClient = function(args, cb) {
}); });
storage.load(function(err, walletData) { storage.load(function(err, walletData) {
if (err && err.code != 'ENOENT') die(err); if (err && err.code != 'ENOENT') die(err);
if (walletData) { if (!walletData) return cb(client);
client.import(walletData);
} client.import(walletData);
return cb(client); 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) { API.prototype.getStatus = function(cb) {
$.checkState(this.credentials && this.credentials.isComplete()); $.checkState(this.credentials);
var self = this; var self = this;
self._doGetRequest('/v1/wallets/', function(err, result) { 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() { describe('Address Creation', function() {

Loading…
Cancel
Save