Browse Source

add export to text and qr

activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
705773aa37
  1. 1
      bit-wallet/bit
  2. 28
      bit-wallet/bit-export
  3. 15
      lib/client/api.js
  4. 1
      package.json

1
bit-wallet/bit

@ -15,6 +15,7 @@ program
.command('reject <txpId> [reason]', 'reject a transaction proposal')
.command('broadcast <txpId>', 'broadcast a transaction proposal to the Bitcoin network')
.command('rm <txpId>', 'remove a transaction proposal')
.command('export', 'export wallet critical data')
.parse(process.argv);

28
bit-wallet/bit-export

@ -0,0 +1,28 @@
#!/usr/bin/env node
var program = require('commander');
var qr = require('qr-image');
var Client = require('../lib/client');
var utils = require('./cli-utils');
program
.version('0.0.1')
.option('-c, --config [file]', 'Wallet config filename')
.option('-v, --verbose', 'be verbose')
.option('-q, --qr')
.parse(process.argv);
var args = program.args;
var client = utils.getClient(program);
client.export(function(err, x) {
utils.die(err);
if (program.qr) {
var filename = program.config + '.svg';
var qr_svg = qr.image(x, { type: 'svg' });
qr_svg.pipe(require('fs').createWriteStream(filename));
} else {
console.log('Wallet Critical Data:\n', x);
}
});

15
lib/client/api.js

@ -309,12 +309,20 @@ API.prototype.getBalance = function(cb) {
});
};
API.prototype.export = function(cb) {
var self = this;
this._loadAndCheck( function(err, data) {
if (err) return cb(err);
var x = _.pick(data,['publicKeyRing','xPrivKey', 'copayerId', 'signingPrivKey'])
return cb(null, JSON.stringify(x));
});
}
API.prototype.getTxProposals = function(opts, cb) {
var self = this;
this._loadAndCheck(
function(err, data) {
this._loadAndCheck(function(err, data) {
if (err) return cb(err);
var url = '/v1/txproposals/';
self._doGetRequest(url, data, cb);
@ -324,8 +332,7 @@ API.prototype.getTxProposals = function(opts, cb) {
API.prototype.signTxProposal = function(txp, cb) {
var self = this;
this._loadAndCheck(
function(err, data) {
this._loadAndCheck(function(err, data) {
if (err) return cb(err);
if (!Verifier.checkTxProposal(data, txp)) {

1
package.json

@ -31,6 +31,7 @@
"npmlog": "^0.1.1",
"preconditions": "^1.0.7",
"request": "^2.53.0",
"qr-image": "*",
"uuid": "*"
},
"devDependencies": {

Loading…
Cancel
Save