CLI lib
This commit is contained in:
parent
050e5701ec
commit
8a8c111827
|
@ -10,11 +10,14 @@ log.level = 'debug';
|
|||
var fs = require('fs')
|
||||
|
||||
var Bitcore = require('bitcore')
|
||||
var SignUtils = require('./lib/signutils');
|
||||
var SignUtils = require('./signutils');
|
||||
|
||||
var BASE_URL = 'http://localhost:3001/copay/api/';
|
||||
|
||||
function getUrl(path) {
|
||||
var cli = {};
|
||||
|
||||
|
||||
function _getUrl(path) {
|
||||
return BASE_URL + path;
|
||||
};
|
||||
|
||||
|
@ -35,7 +38,7 @@ function load() {
|
|||
|
||||
|
||||
|
||||
function createWallet(walletName, copayerName, m, n, cb) {
|
||||
clilib.createWallet = function(walletName, copayerName, m, n, cb) {
|
||||
var data = load();
|
||||
if (!data) {
|
||||
data = {};
|
||||
|
@ -54,7 +57,7 @@ function createWallet(walletName, copayerName, m, n, cb) {
|
|||
|
||||
request({
|
||||
method: 'post',
|
||||
url: getUrl('v1/wallets'),
|
||||
url: _getUrl('v1/wallets'),
|
||||
body: args,
|
||||
json: true,
|
||||
}, function(err, res, body) {
|
||||
|
@ -71,7 +74,7 @@ function createWallet(walletName, copayerName, m, n, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
function joinWallet(secret, copayerName, cb) {
|
||||
clilib.joinWallet = function(secret, copayerName, cb) {
|
||||
var data = load();
|
||||
if (!data) {
|
||||
data = {};
|
||||
|
@ -94,7 +97,7 @@ function joinWallet(secret, copayerName, cb) {
|
|||
|
||||
request({
|
||||
method: 'post',
|
||||
url: getUrl('v1/wallets/' + walletId + '/copayers'),
|
||||
url: _getUrl('v1/wallets/' + walletId + '/copayers'),
|
||||
body: args,
|
||||
json: true,
|
||||
}, function(err, res, body) {
|
||||
|
@ -107,10 +110,10 @@ function joinWallet(secret, copayerName, cb) {
|
|||
});
|
||||
};
|
||||
|
||||
function status(cb) {
|
||||
clilib.status = function(cb) {
|
||||
request({
|
||||
method: 'get',
|
||||
url: getUrl('v1/dump/'),
|
||||
url: _getUrl('v1/dump/'),
|
||||
}, function(err, res, body) {
|
||||
if (err) return cb(err);
|
||||
|
||||
|
@ -119,35 +122,24 @@ function status(cb) {
|
|||
});
|
||||
};
|
||||
|
||||
function send(addressTo, amount, message, cb) {
|
||||
clilib.send = function(addressTo, amount, message, cb) {
|
||||
|
||||
};
|
||||
|
||||
function sign(proposalId, cb) {
|
||||
clilib.sign = function(proposalId, cb) {
|
||||
|
||||
};
|
||||
|
||||
function reject(proposalId, cb) {
|
||||
clilib.reject = function(proposalId, cb) {
|
||||
|
||||
};
|
||||
|
||||
function address(cb) {
|
||||
clilib.address = function(cb) {
|
||||
|
||||
};
|
||||
|
||||
function history(limit, cb) {
|
||||
clilib.history = function(limit, cb) {
|
||||
|
||||
};
|
||||
|
||||
|
||||
// createWallet('test wallet', 'test copayer', 2, 2, function(err, secret) {
|
||||
// if (err) process.exit(err);
|
||||
// var data = load();
|
||||
// console.log('ESTE ES EL SECRET', secret);
|
||||
// console.log('ESTE ES EL STORAGE', data);
|
||||
// });
|
||||
|
||||
|
||||
// joinWallet('1b44f598-ced5-4fe1-bac3-d9f4563c3011|9b483158c271036035ea639a57761247902222784ef03142b552800e35082929', 'otro copayer', function(err) {
|
||||
// if (err) process.exit(err);
|
||||
// });
|
||||
module.exports = clilib;
|
Loading…
Reference in New Issue