diff --git a/accounts/support-rest-api.js b/accounts/support-rest-api.js index 8b18b5d..34cf985 100644 --- a/accounts/support-rest-api.js +++ b/accounts/support-rest-api.js @@ -312,20 +312,11 @@ class SupportRestApi { */ async getPairingExplorer(req, res) { try { - let url = '' - if (process.env.EXPLORER_INSTALL == 'on') { - try { - url = fs.readFileSync('/var/lib/tor/hsv3explorer/hostname', 'utf8') - url = url.replace('\n', '') - } catch(e) { - Logger.error(e, 'API : SupportRestApi.getPairing() : Cannot read explorer onion address') - } - } const ret = { 'pairing': { - 'type': 'explorer.btcRpcExplorer', - 'url': url, - 'key': process.env.EXPLORER_KEY + 'type': `explorer.${keys.explorer.active}`, + 'url': keys.explorer.uri, + 'key': keys.explorer.password } } HttpServer.sendRawData(res, JSON.stringify(ret, null, 2)) diff --git a/docker/my-dojo/node/keys.index.js b/docker/my-dojo/node/keys.index.js index 3c2ca42..e37a1f3 100644 --- a/docker/my-dojo/node/keys.index.js +++ b/docker/my-dojo/node/keys.index.js @@ -2,11 +2,27 @@ * keys/index-example.js * Copyright (c) 2016-2018, Samourai Wallet (CC BY-NC-ND 4.0 License). */ +const fs = require('fs') + +// Retrieve active bitcoin network from conf files const bitcoinNetwork = (process.env.COMMON_BTC_NETWORK == 'testnet') ? 'testnet' : 'bitcoin' +// Retrieve explorer config from conf files +let explorerActive = 'oxt' +let explorerUrl = 'https://oxt.me' +let explorerPassword = '' +if (process.env.EXPLORER_INSTALL == 'on') { + try { + explorerUrl = fs.readFileSync('/var/lib/tor/hsv3explorer/hostname', 'utf8').replace('\n', '') + explorerPassword = process.env.EXPLORER_KEY + explorerActive = 'btc_rpc_explorer' + } catch(e) {} +} + + /** * Desired structure of /keys/index.js, which is ignored in the repository. */ @@ -180,6 +196,18 @@ module.exports = { // Esplora (testnet) esplora: process.env.NODE_URL_ESPLORA_API, }, + /* + * Explorer recommended by this Dojo + */ + explorer: { + // Active explorer + // Values: oxt | btc_rpc_explorer + active: explorerActive, + // URI of the explorer + uri: explorerUrl, + // Password (value required for btc_rpc_explorer) + password: explorerPassword + }, /* * Max number of transactions per address * accepted during fast scan diff --git a/keys/index-example.js b/keys/index-example.js index cd72820..b001627 100644 --- a/keys/index-example.js +++ b/keys/index-example.js @@ -174,6 +174,18 @@ module.exports = { // OXT oxt: 'https://api.oxt.me' }, + /* + * Explorer recommended by this Dojo + */ + explorer: { + // Active explorer + // Values: oxt | btc_rpc_explorer + active: 'oxt', + // URI of the explorer + uri: 'https://oxt.me', + // Password (value required for btc_rpc_explorer) + password: '' + }, /* * Max number of transactions per address * accepted during fast scan @@ -295,6 +307,11 @@ module.exports = { socks5Proxy: null, esplora: 'https://blockstream.info/testnet' }, + explorer: { + active: 'none', + uri: '', + password: '' + }, addrFilterThreshold: 1000, addrDerivationPool: { minNbChildren: 1,