|
|
@ -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; |