update rm

This commit is contained in:
Ivan Socolsky 2015-02-15 12:46:38 -03:00
parent f439f23b61
commit eca7d55afb
3 changed files with 6 additions and 52 deletions

View File

@ -2,7 +2,7 @@
var _ = require('lodash');
var program = require('commander');
var ClientLib = require('../lib/clientlib.js');
var Client = require('../lib/client');
var common = require('./common');
program
@ -18,11 +18,11 @@ if (!args[0])
var txpid = args[0];
var cli = new ClientLib({
var cli = new Client({
filename: program.config
});
cli.txProposals({}, function(err, x) {
cli.getTxProposals({}, function(err, x) {
common.die(err);
if (program.verbose)
@ -41,7 +41,7 @@ cli.txProposals({}, function(err, x) {
}).join(' '));;
var txp = txps[0];
cli.rm(txp, function(err, x) {
cli.removeTxProposal(txp, function(err, x) {
common.die(err);
if (program.verbose)

30
cli.js
View File

@ -1,30 +0,0 @@
var _ = require('lodash');
var async = require('async');
var log = require('npmlog');
var fs = require('fs');
var CliLib = require('./lib/clilib');
try {
fs.unlinkSync('copay.dat');
} catch (e) {}
var cli = new CliLib({
filename: 'copay.dat'
});
cli.createWallet('my wallet', 'me', 1, 1, 'testnet', function(err, secret) {
if (err) {
console.log(err);
process.exit();
}
cli.status(function(err, status) {
if (err) {
console.log(err);
process.exit();
}
console.log(status);
})
});

View File

@ -359,29 +359,13 @@ API.prototype.rejectTxProposal = function(txp, reason, cb) {
this._doPostRequest(url, args, data, cb);
};
ClientLib.prototype.rm = function(txp, cb) {
ClientLib.prototype.removeTxProposal = function(txp, cb) {
var self = this;
var data = this._loadAndCheck();
var url = '/v1/txproposals/' + txp.id;
var reqSignature = _signRequest(url, {}, data.signingPrivKey);
request({
headers: {
'x-identity': data.copayerId,
'x-signature': reqSignature,
},
method: 'delete',
url: _getUrl(url),
json: true,
}, function(err, res, body) {
if (err) return cb(err);
if (res.statusCode != 200) {
_parseError(body);
return cb('Request error');
}
return cb(null, body);
});
this._doRequest('delete', url, {}, data, cb);
};
module.exports = API;