cli: improve wallet support.
This commit is contained in:
parent
11ac46e051
commit
37fdc7c08b
37
bin/cli
37
bin/cli
@ -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()) {
|
||||
|
||||
@ -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')
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user