Browse Source

rn clientLib

activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
a3abc3b8ff
  1. 1
      bit-wallet/bit
  2. 4
      bit-wallet/bit-address
  3. 4
      bit-wallet/bit-addresses
  4. 4
      bit-wallet/bit-balance
  5. 4
      bit-wallet/bit-create
  6. 4
      bit-wallet/bit-join
  7. 4
      bit-wallet/bit-send
  8. 4
      bit-wallet/bit-status
  9. 34
      lib/clientlib.js

1
bit-wallet/bit

@ -1,7 +1,6 @@
#!/usr/bin/env node
var program = require('commander');
var cli = require('../lib/clilib.js');
program
.version('0.0.1')

4
bit-wallet/bit-address

@ -1,7 +1,7 @@
#!/usr/bin/env node
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
@ -11,7 +11,7 @@ program
.parse(process.argv);
var args = program.args;
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});

4
bit-wallet/bit-addresses

@ -2,8 +2,8 @@
var _ = require('lodash');
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var common = require('./common');
var ClientLib = require('../lib/clientlib.js');
program
.version('0.0.1')
@ -12,7 +12,7 @@ program
.parse(process.argv);
var args = program.args;
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});

4
bit-wallet/bit-balance

@ -1,7 +1,7 @@
#!/usr/bin/env node
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
@ -11,7 +11,7 @@ program
.parse(process.argv);
var args = program.args;
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});

4
bit-wallet/bit-create

@ -1,7 +1,7 @@
#!/usr/bin/env node
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
@ -21,7 +21,7 @@ var network = program.network;
var mn = common.parseMN(args[1]);
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});
cli.createWallet(walletName, copayerName, mn[0], mn[1], network, function(err, secret) {

4
bit-wallet/bit-join

@ -1,7 +1,7 @@
#!/usr/bin/env node
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
@ -17,7 +17,7 @@ if (!args[0])
var secret = args[0];
var copayerName = args[1] || process.env.USER;
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});

4
bit-wallet/bit-send

@ -1,7 +1,7 @@
#!/usr/bin/env node
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
@ -19,7 +19,7 @@ if (!args[0] || !args[1] || !args[2])
var amount = args[1];
var message = args[2];
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});

4
bit-wallet/bit-status

@ -1,7 +1,7 @@
#!/usr/bin/env node
var program = require('commander');
var CliLib = require('../lib/clilib.js');
var ClientLib = require('../lib/clientlib.js');
var common = require('./common');
program
@ -11,7 +11,7 @@ program
.parse(process.argv);
var args = program.args;
var cli = new CliLib({
var cli = new ClientLib({
filename: program.config
});

34
lib/clilib.js → lib/clientlib.js

@ -47,7 +47,7 @@ function _createXPrivKey() {
return new Bitcore.HDPrivateKey().toString();
};
function CliLib(opts) {
function ClientLib(opts) {
if (!opts.filename) {
throw new Error('Please set the config filename');
}
@ -55,17 +55,17 @@ function CliLib(opts) {
};
CliLib.prototype._save = function(data) {
ClientLib.prototype._save = function(data) {
fs.writeFileSync(this.filename, JSON.stringify(data));
};
CliLib.prototype._load = function() {
ClientLib.prototype._load = function() {
try {
return JSON.parse(fs.readFileSync(this.filename));
} catch (ex) {}
};
CliLib.prototype._loadAndCheck = function() {
ClientLib.prototype._loadAndCheck = function() {
var data = this._load();
if (!data) {
log.error('Wallet file not found.');
@ -85,7 +85,7 @@ CliLib.prototype._loadAndCheck = function() {
return data;
};
CliLib.prototype.createWallet = function(walletName, copayerName, m, n, network, cb) {
ClientLib.prototype.createWallet = function(walletName, copayerName, m, n, network, cb) {
var self = this;
var data = this._load();
@ -136,7 +136,7 @@ CliLib.prototype.createWallet = function(walletName, copayerName, m, n, network,
});
};
CliLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
ClientLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
var self = this;
var secretSplit = secret.split(':');
@ -180,7 +180,7 @@ CliLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
});
};
CliLib.prototype.joinWallet = function(secret, copayerName, cb) {
ClientLib.prototype.joinWallet = function(secret, copayerName, cb) {
var self = this;
var data = this._load();
@ -193,7 +193,7 @@ CliLib.prototype.joinWallet = function(secret, copayerName, cb) {
self._joinWallet(data, secret, copayerName, cb);
};
CliLib.prototype.status = function(cb) {
ClientLib.prototype.status = function(cb) {
var self = this;
var data = this._loadAndCheck();
@ -253,7 +253,7 @@ CliLib.prototype.status = function(cb) {
* @param inArgs.amount
* @param inArgs.message
*/
CliLib.prototype.send = function(inArgs, cb) {
ClientLib.prototype.send = function(inArgs, cb) {
var self = this;
var data = this._loadAndCheck();
@ -282,16 +282,16 @@ CliLib.prototype.send = function(inArgs, cb) {
};
// TODO check change address
CliLib.prototype.sign = function(proposalId, cb) {
ClientLib.prototype.sign = function(proposalId, cb) {
};
CliLib.prototype.reject = function(proposalId, cb) {
ClientLib.prototype.reject = function(proposalId, cb) {
};
// Get addresses
CliLib.prototype.addresses = function(cb) {
ClientLib.prototype.addresses = function(cb) {
var self = this;
var data = this._loadAndCheck();
@ -320,7 +320,7 @@ CliLib.prototype.addresses = function(cb) {
// Creates a new address
// TODO: verify derivation!!
CliLib.prototype.address = function(cb) {
ClientLib.prototype.address = function(cb) {
var self = this;
var data = this._loadAndCheck();
@ -346,11 +346,11 @@ CliLib.prototype.address = function(cb) {
});
};
CliLib.prototype.history = function(limit, cb) {
ClientLib.prototype.history = function(limit, cb) {
};
CliLib.prototype.balance = function(cb) {
ClientLib.prototype.balance = function(cb) {
var self = this;
var data = this._loadAndCheck();
@ -377,7 +377,7 @@ CliLib.prototype.balance = function(cb) {
};
CliLib.prototype.txProposals = function(cb) {
ClientLib.prototype.txProposals = function(cb) {
var self = this;
var data = this._loadAndCheck();
@ -404,4 +404,4 @@ CliLib.prototype.txProposals = function(cb) {
};
module.exports = CliLib;
module.exports = ClientLib;
Loading…
Cancel
Save