Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(function(result) {
var bitcoindNetwork;
switch (result.chain) {
case 'main':
bitcoindNetwork = 'bitcoin';
break;
case 'test':
bitcoindNetwork = 'testnet';
break;
default:
// regtest is unsupported
throw new Error('unknown network ' + result.chain);
}
if (bitcoindNetwork !== bitgo.getNetwork()) {
throw new Error('bitcoind using ' + bitcoindNetwork + ', bitgod using ' + bitgo.getNetwork());
}
console.log('Connected to proxy bitcoind at ' + [config.proxyhost, proxyPort].join(':'));
console.dir(result);
})
.catch(function(err) {
.then(function(result) {
var bitcoindNetwork;
switch (result.chain) {
case 'main':
bitcoindNetwork = 'bitcoin';
break;
case 'test':
bitcoindNetwork = 'testnet';
break;
default:
// regtest is unsupported
throw new Error('unknown network ' + result.chain);
}
if (bitcoindNetwork !== bitgo.getNetwork()) {
throw new Error('bitcoind using ' + bitcoindNetwork + ', bitgod using ' + bitgo.getNetwork());
}
console.log('Connected to proxy bitcoind at ' + [config.proxyhost, proxyPort].join(':'));
console.dir(result);
})
.catch(function(err) {
.then(function() {
// If validation is on, ensure that bitcoind has txindex=1
if (self.validate) {
// Random old spent transactions that bitcoind won't have unless in txindex mode
var txid = (bitgo.getNetwork() === 'bitcoin') ?
'c65602d4310c1ca9c560705176ebc01c34a4bac40a3af432be839df1cf8dd87c' :
'44954268b32d386733f64d457bc933bf323f31f3596b90becc718a5b7cbfce8a';
return self.getTransactionLocal(txid)
.catch(function(err) {
throw new Error('bitcoind must have txindex enabled to use validation');
});
}
});
};
BGCL.prototype.handleStatus = function() {
const self = this;
const status = {
env: this.bitgo.getEnv(),
network: bitgo.getNetwork(),
sessionFile: jsonFilename(this.bitgo.getEnv())
};
if (this.bitgo.user()) {
status.user = this.bitgo.user().username;
}
if (this.session.wallet) {
status.wallet = this.session.wallet.id();
}
return self.ensureAuthenticated()
.then(function() {
// JSON output
if (self.args.json) {
return self.printJSON(status);
}
// normal output