cli: improve wallet support.

This commit is contained in:
Christopher Jeffrey 2017-10-26 16:46:59 -07:00
parent 11ac46e051
commit 37fdc7c08b
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 29 additions and 14 deletions

37
bin/cli
View File

@ -5,13 +5,20 @@
const Config = require('../lib/node/config');
const {NodeClient, WalletClient} = require('bclient');
const ports = {
const nports = {
main: 8332,
testnet: 18332,
regtest: 48332,
simnet: 18556
};
const wports = {
main: 8334,
testnet: 18334,
regtest: 48334,
simnet: 18558
};
const ANTIREPLAY = ''
+ '6a2e426974636f696e3a204120506565722d746f2d5065657'
+ '220456c656374726f6e696320436173682053797374656d';
@ -20,7 +27,15 @@ function CLI() {
this.config = new Config('bcoin', {
suffix: 'network',
fallback: 'main',
alias: { 'n': 'network' }
alias: {
'n': 'network',
'u': 'url',
'uri': 'url',
'k': 'api-key',
's': 'ssl',
'h': 'httphost',
'p': 'httpport'
}
});
this.config.load({
@ -538,13 +553,16 @@ CLI.prototype.rpc = async function rpc() {
};
CLI.prototype.handleWallet = async function handleWallet() {
const network = this.config.str('network', 'main');
this.wallet = new WalletClient({
url: this.config.str(['url', 'uri']),
url: this.config.str('url'),
apiKey: this.config.str('api-key'),
ssl: this.config.bool('ssl'),
host: this.config.str('http-host'),
port: this.config.uint('http-port')
|| ports[this.config.str('network', '')]
|| ports.main,
|| wports[network]
|| wports.main,
id: this.config.str('id', 'primary'),
token: this.config.str('token')
});
@ -704,13 +722,16 @@ CLI.prototype.handleWallet = async function handleWallet() {
};
CLI.prototype.handleNode = async function handleNode() {
const network = this.config.str('network', 'main');
this.client = new NodeClient({
url: this.config.str(['url', 'uri']),
url: this.config.str('url'),
apiKey: this.config.str('api-key'),
ssl: this.config.bool('ssl'),
host: this.config.str('http-host'),
port: this.config.uint('http-port')
|| ports[this.config.str('network', '')]
|| ports.main
|| nports[network]
|| nports.main
});
switch (this.argv.shift()) {

View File

@ -46,12 +46,6 @@ function WalletNode(options) {
checkpoints: this.config.bool('checkpoints'),
startHeight: this.config.uint('start-height'),
wipeNoReally: this.config.bool('wipe-no-really'),
apiKey: this.config.str('api-key'),
walletAuth: this.config.bool('auth'),
noAuth: this.config.bool('no-auth'),
ssl: this.config.str('ssl'),
host: this.config.str('host'),
port: this.config.uint('port'),
spv: this.config.bool('spv')
});