Browse Source

default bit.dat file;

activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
9e724cabee
  1. 5
      bit-wallet/bit-address
  2. 5
      bit-wallet/bit-addresses
  3. 5
      bit-wallet/bit-balance
  4. 5
      bit-wallet/bit-broadcast
  5. 6
      bit-wallet/bit-confirm
  6. 4
      bit-wallet/bit-create
  7. 5
      bit-wallet/bit-export
  8. 5
      bit-wallet/bit-import
  9. 4
      bit-wallet/bit-join
  10. 4
      bit-wallet/bit-recreate
  11. 5
      bit-wallet/bit-reject
  12. 6
      bit-wallet/bit-rm
  13. 6
      bit-wallet/bit-send
  14. 5
      bit-wallet/bit-sign
  15. 5
      bit-wallet/bit-status
  16. 11
      bit-wallet/cli-utils.js
  17. 2
      lib/client/api.js
  18. 5
      lib/client/filestorage.js

5
bit-wallet/bit-address

@ -3,12 +3,9 @@
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.parse(process.argv);
var args = program.args;

5
bit-wallet/bit-addresses

@ -4,12 +4,9 @@ var _ = require('lodash');
var program = require('commander');
var utils = require('./cli-utils');
var Client = require('../lib/client');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.parse(process.argv);
var args = program.args;

5
bit-wallet/bit-balance

@ -3,12 +3,9 @@
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.parse(process.argv);
var args = program.args;

5
bit-wallet/bit-broadcast

@ -4,12 +4,9 @@ var _ = require('lodash');
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v,--verbose', 'be verbose')
.usage('[options] <txpid>')
.parse(process.argv);

6
bit-wallet/bit-confirm

@ -4,13 +4,11 @@ var _ = require('lodash');
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.parse(process.argv);
var client = utils.getClient(program);
client.getStatus(function(err, x, myCopayerId) {

4
bit-wallet/bit-create

@ -4,11 +4,9 @@ var _ = require('lodash');
var program = require('commander');
var ClientLib = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-t, --testnet', 'Create a Testnet Wallet')
.usage('[options] <walletName> <m-n> [copayerName]')
.parse(process.argv);

5
bit-wallet/bit-export

@ -5,12 +5,9 @@ var qr = require('qr-image');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.option('-q, --qr')
.parse(process.argv);

5
bit-wallet/bit-import

@ -2,14 +2,13 @@
var program = require('commander');
var Client = require('../lib/client');
var fs = require('fs');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
var fs = require('fs');
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-v, --verbose', 'be verbose')
.usage('import [options] <file>')
.parse(process.argv);

4
bit-wallet/bit-join

@ -3,11 +3,9 @@
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.usage('[options] <secret> [copayerName]')
.parse(process.argv);

4
bit-wallet/bit-recreate

@ -4,11 +4,9 @@ var _ = require('lodash');
var program = require('commander');
var ClientLib = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.usage('[options] walletname')
.description('Creates a wallet on the remove server given the local information')
.parse(process.argv);

5
bit-wallet/bit-reject

@ -4,12 +4,9 @@ var _ = require('lodash');
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-v,--verbose', 'be verbose')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.usage('[options] <txpid> [reason]')
.parse(process.argv);

6
bit-wallet/bit-rm

@ -4,12 +4,10 @@ var _ = require('lodash');
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-v,--verbose', 'be verbose')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.usage('[options] <txpid>')
.parse(process.argv);

6
bit-wallet/bit-send

@ -3,12 +3,9 @@
var program = require('commander');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.usage('[options] <address> <amount> [note]')
.description('Create a proposal for sending bitcoins to a destination address.\n The amount can be specified in bit, btc or sat (the default).');
@ -19,7 +16,6 @@ program.on('--help', function(){
console.log(' $ bit-send mgWeRvUC6d1LRPKtdDbvYEpaUEmApS4XrY 0.2btc "dinner with friends"');
console.log('');
});
program.parse(process.argv);
var args = program.args;

5
bit-wallet/bit-sign

@ -3,12 +3,9 @@
var _ = require('lodash');
var program = require('commander');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c,--config [file]', 'Wallet config filename')
.option('-v,--verbose', 'be verbose')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.usage('[options] <txpid>')
.parse(process.argv);

5
bit-wallet/bit-status

@ -3,12 +3,9 @@
var _ = require('lodash');
var program = require('commander');
var utils = require('./cli-utils');
program = utils.configureCommander(program);
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
.parse(process.argv);
var args = program.args;

11
bit-wallet/cli-utils.js

@ -36,7 +36,7 @@ Utils.confirmationId = function(copayer) {
Utils.getClient = function(args) {
var storage = new Client.FileStorage({
filename: args.config || process.env['BIT_FILE'],
filename: args.file || process.env['BIT_FILE'],
});
return new Client({
storage: storage,
@ -89,5 +89,14 @@ Utils.parseAmount = function(text) {
return amountSat;
};
Utils.configureCommander = function(program) {
program
.version('0.0.1')
.option('-f, --file [filename]', 'Wallet file', 'bit.dat')
.option('-h, --host [host]', 'Bitcore Wallet Service URL (eg: http://localhost:3001/copay/api')
.option('-v, --verbose', 'be verbose')
return program;
};
module.exports = Utils;

2
lib/client/api.js

@ -227,7 +227,7 @@ API.prototype.createWallet = function(walletName, copayerName, m, n, network, cb
this.storage.load(function(err, data) {
if (data)
return cb('Storage already contains a wallet');
return cb(self.storage.getName() + ' already contains a wallet');
var walletPrivKey = new Bitcore.PrivateKey();
var args = {

5
lib/client/filestorage.js

@ -3,12 +3,15 @@ var fs = require('fs')
function FileStorage(opts) {
if (!opts.filename) {
throw new Error('Please set the config filename');
throw new Error('Please set wallet filename');
}
this.filename = opts.filename;
this.fs = opts.fs || fs;
};
FileStorage.prototype.getName = function() {
return this.filename;
};
FileStorage.prototype.save = function(data, cb) {
this.fs.writeFile(this.filename, JSON.stringify(data), cb);

Loading…
Cancel
Save