Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding export functionality for regtest wallet #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions bin/wallet-bdb2jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,38 @@ var program = require('commander');
var exporter = require('..');
var EventEmitter = require('events').EventEmitter;
var PublicKey = require('bitcore-lib').PublicKey;
var PublicKeyBCH = require('bitcore-lib-cash').PublicKey;

program
.version('0.1.0', '-v, --version')
.description('Emit a JSONL stream of wallet keys.')
.option('-t, --testnet', 'interpret as a testnet wallet')
.option('-r --regtest', 'interpret as a regtest address')
.option('-f, --file <wallet-file>', 'a BerkeleyDB wallet.dat file')
.option('-b, --bch', 'if wallet.dat is from ABC')
.option('-o, --readonly', 'export a read-only wallet')
.parse(process.argv);

var network = program.testnet ? 'testnet' : 'livenet';
var network = program.testnet ? 'testnet' : program.regtest ? 'regtest' : 'livenet';
if (!program.file) {
program.help();
}

function processOutput(json) {
var obj = JSON.parse(json);
if (obj.pubKey) {
var pk = new PublicKey(obj.pubKey);
obj.address = pk.toAddress(network).toString();
var pk;
if (program.bch) {
pk = new PublicKeyBCH(obj.pubKey);
obj.address = pk.toAddress(network).toString();
} else {
pk = new PublicKey(obj.pubKey);
obj.address = pk.toAddress(network).toString();
}
}
if (program.readonly) {
delete obj.cipherText;
delete obj.pubKey;
}
console.log(JSON.stringify(obj));
}
Expand Down
35 changes: 35 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"dependencies": {
"nan": "^2.14.0",
"commander": "*",
"bitcore-lib": "^8.5.1"
"bitcore-lib": "^8.5.1",
"bitcore-lib-cash": "^8.5.1"
},
"devDependencies": {
"chai": "^3.5.0",
Expand Down