Skip to content
Permalink
Browse files

feat(wallet): ability to select block explorer

fix #2211
  • Loading branch information...
mrfelton committed May 30, 2019
1 parent 184d041 commit daa25afa3193c2395d87516a94bdf1ee20c08823
@@ -95,6 +95,9 @@ module.exports = {
litecoin: 'lits',
},

// Default block explorer (blockstream|blockcypher|smartbit|insight)
blockExplorer: 'blockstream',

// Default invoice settings
invoices: {
expire: 86400,
@@ -25,11 +25,15 @@ const fsRimraf = promisify(rimraf)
* @type {Array}
*/
const WHITELISTED_DOMAINS = [
'blockstream.info',
'coinfaucet.eu',
'insight.litecore.io',
'live.blockcypher.com',
'ln-zap.github.io',
'blockstream.info',
'testnet.litecore.io',
'testnet.smartbit.com.au',
'litecore.io',
'www.smartbit.com.au',
]

/**
@@ -14,6 +14,16 @@ const addressMessageMapper = key => {
return filters[key]
}

const blockExplorerItems = [{ key: 'blockstream' }, { key: 'blockcypher' }, { key: 'smartbit' }]
const blockExplorerMessageMapper = key => {
const filters = {
blockstream: messages.blockExplorer_option_blockstream,
blockcypher: messages.blockExplorer_option_blockcypher,
smartbit: messages.blockExplorer_option_smartbit,
}
return filters[key]
}

const SettingsFieldsWallet = ({ currentConfig }) => {
const renderNumberDataRow = path => (
<DataRow
@@ -39,6 +49,21 @@ const SettingsFieldsWallet = ({ currentConfig }) => {

<Bar variant="light" />

<DataRow
left={<FieldLabel itemKey="blockExplorer" />}
right={
<Select
field="blockExplorer"
highlightOnValid={false}
initialSelectedItem={currentConfig.blockExplorer}
items={blockExplorerItems}
messageMapper={blockExplorerMessageMapper}
/>
}
/>

<Bar variant="light" />

{renderNumberDataRow('lndTargetConfirmations.fast')}

<Bar variant="light" />
@@ -23,6 +23,11 @@ export default defineMessages({
address_description: 'Your preferred receiving address format.',
address_option_p2wkh: 'Bech32',
address_option_np2wkh: 'Segwit',
blockExplorer_label: 'Block explorer',
blockExplorer_description: 'Your preferred block explorer.',
blockExplorer_option_blockstream: 'Blockstream',
blockExplorer_option_blockcypher: 'BlockCypher',
blockExplorer_option_smartbit: 'Smartbit',
lndTargetConfirmations_slow_label: 'Target confirmations (slow)',
lndTargetConfirmations_slow_description: 'Number of blocks to target for "slow" sending speed.',
lndTargetConfirmations_medium_label: 'Target confirmations (medium)',
@@ -5,6 +5,7 @@ import { grpcService } from 'workers'
import { initAddresses } from './address'
import { putWallet, walletSelectors } from './wallet'
import { receiveCryptocurrency } from './ticker'
import { settingsSelectors } from './settings'

// ------------------------------------
// Constants
@@ -18,14 +19,22 @@ const networkInfo = {
mainnet: {
id: 'mainnet',
name: 'Mainnet',
explorerUrl: 'https://blockstream.info',
explorerUrls: {
blockstream: 'https://blockstream.info',
blockcypher: 'https://live.blockcypher.com/btc',
smartbit: 'https://www.smartbit.com.au',
},
bitcoinJsNetwork: networks.bitcoin.mainnet,
unitPrefix: '',
},
testnet: {
id: 'testnet',
name: 'Testnet',
explorerUrl: 'https://blockstream.info/testnet',
explorerUrls: {
blockstream: 'https://blockstream.info/testnet',
blockcypher: 'https://live.blockcypher.com/btc-testnet',
smartbit: 'https://testnet.smartbit.com.au',
},
bitcoinJsNetwork: networks.bitcoin.testnet,
unitPrefix: 't',
},
@@ -34,14 +43,22 @@ const networkInfo = {
mainnet: {
id: 'mainnet',
name: 'Mainnet',
explorerUrl: 'https://insight.litecore.io',
explorerUrls: {
blockstream: 'https://insight.litecore.io', // not supported, default to insight.
blockcypher: 'https://live.blockcypher.com/ltc',
smartbit: 'https://insight.litecore.io', // not supported, default to insight.
},
bitcoinJsNetwork: networks.litecoin.mainnet,
unitPrefix: '',
},
testnet: {
id: 'testnet',
name: 'Testnet',
explorerUrl: 'https://testnet.litecore.io',
explorerUrls: {
blockstream: 'https://testnet.litecore.io', // not supported, default to insight.
blockcypher: 'https://testnet.litecore.io', // not supported, default to insight.
smartbit: 'https://testnet.litecore.io', // not supported, default to insight.
},
bitcoinJsNetwork: networks.litecoin.testnet,
unitPrefix: 't',
},
@@ -159,6 +176,7 @@ infoSelectors.networksSelector = state => state.info.networks
infoSelectors.infoLoading = state => state.info.infoLoading
infoSelectors.infoLoaded = state => state.info.infoLoaded
infoSelectors.hasSynced = state => state.info.hasSynced

infoSelectors.nodePub = state => {
const parseFromDataUri = () => {
const uri = get(state.info, 'data.uris[0]')
@@ -171,7 +189,12 @@ infoSelectors.networkInfo = createSelector(
infoSelectors.chainSelector,
infoSelectors.networkSelector,
infoSelectors.networksSelector,
(chain, network, networks) => get(networks, `${chain}.${network}`)
settingsSelectors.currentConfig,
(chain, network, networks, currentConfig) => {
const networkInfo = get(networks, `${chain}.${network}`, {})
networkInfo.explorerUrl = networkInfo.explorerUrls[currentConfig.blockExplorer]
return networkInfo
}
)

export { infoSelectors }
@@ -55,7 +55,11 @@ Object {
},
"wif": 128,
},
"explorerUrl": "https://blockstream.info",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/btc",
"blockstream": "https://blockstream.info",
"smartbit": "https://www.smartbit.com.au",
},
"id": "mainnet",
"name": "Mainnet",
"unitPrefix": "",
@@ -102,7 +106,11 @@ Object {
},
"wif": 239,
},
"explorerUrl": "https://blockstream.info/testnet",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/btc-testnet",
"blockstream": "https://blockstream.info/testnet",
"smartbit": "https://testnet.smartbit.com.au",
},
"id": "testnet",
"name": "Testnet",
"unitPrefix": "t",
@@ -151,7 +159,11 @@ Object {
},
"wif": 176,
},
"explorerUrl": "https://insight.litecore.io",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/ltc",
"blockstream": "https://insight.litecore.io",
"smartbit": "https://insight.litecore.io",
},
"id": "mainnet",
"name": "Mainnet",
"unitPrefix": "",
@@ -187,7 +199,11 @@ Object {
},
"wif": 239,
},
"explorerUrl": "https://testnet.litecore.io",
"explorerUrls": Object {
"blockcypher": "https://testnet.litecore.io",
"blockstream": "https://testnet.litecore.io",
"smartbit": "https://testnet.litecore.io",
},
"id": "testnet",
"name": "Testnet",
"unitPrefix": "t",
@@ -260,7 +276,11 @@ Object {
},
"wif": 128,
},
"explorerUrl": "https://blockstream.info",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/btc",
"blockstream": "https://blockstream.info",
"smartbit": "https://www.smartbit.com.au",
},
"id": "mainnet",
"name": "Mainnet",
"unitPrefix": "",
@@ -307,7 +327,11 @@ Object {
},
"wif": 239,
},
"explorerUrl": "https://blockstream.info/testnet",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/btc-testnet",
"blockstream": "https://blockstream.info/testnet",
"smartbit": "https://testnet.smartbit.com.au",
},
"id": "testnet",
"name": "Testnet",
"unitPrefix": "t",
@@ -356,7 +380,11 @@ Object {
},
"wif": 176,
},
"explorerUrl": "https://insight.litecore.io",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/ltc",
"blockstream": "https://insight.litecore.io",
"smartbit": "https://insight.litecore.io",
},
"id": "mainnet",
"name": "Mainnet",
"unitPrefix": "",
@@ -392,7 +420,11 @@ Object {
},
"wif": 239,
},
"explorerUrl": "https://testnet.litecore.io",
"explorerUrls": Object {
"blockcypher": "https://testnet.litecore.io",
"blockstream": "https://testnet.litecore.io",
"smartbit": "https://testnet.litecore.io",
},
"id": "testnet",
"name": "Testnet",
"unitPrefix": "t",
@@ -457,7 +489,11 @@ Object {
},
"wif": 128,
},
"explorerUrl": "https://blockstream.info",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/btc",
"blockstream": "https://blockstream.info",
"smartbit": "https://www.smartbit.com.au",
},
"id": "mainnet",
"name": "Mainnet",
"unitPrefix": "",
@@ -504,7 +540,11 @@ Object {
},
"wif": 239,
},
"explorerUrl": "https://blockstream.info/testnet",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/btc-testnet",
"blockstream": "https://blockstream.info/testnet",
"smartbit": "https://testnet.smartbit.com.au",
},
"id": "testnet",
"name": "Testnet",
"unitPrefix": "t",
@@ -553,7 +593,11 @@ Object {
},
"wif": 176,
},
"explorerUrl": "https://insight.litecore.io",
"explorerUrls": Object {
"blockcypher": "https://live.blockcypher.com/ltc",
"blockstream": "https://insight.litecore.io",
"smartbit": "https://insight.litecore.io",
},
"id": "mainnet",
"name": "Mainnet",
"unitPrefix": "",
@@ -589,7 +633,11 @@ Object {
},
"wif": 239,
},
"explorerUrl": "https://testnet.litecore.io",
"explorerUrls": Object {
"blockcypher": "https://testnet.litecore.io",
"blockstream": "https://testnet.litecore.io",
"smartbit": "https://testnet.litecore.io",
},
"id": "testnet",
"name": "Testnet",
"unitPrefix": "t",

0 comments on commit daa25af

Please sign in to comment.
You can’t perform that action at this time.