Skip to content

Commit

Permalink
Add Loping.net block explorers, add TestNet4 / ScaleNet explorer list
Browse files Browse the repository at this point in the history
Uses `networks.net.__name__` class name to decide which explorers to use.
  • Loading branch information
EchterAgo committed Nov 8, 2020
1 parent bd181ce commit 8f53e1e
Showing 1 changed file with 40 additions and 8 deletions.
48 changes: 40 additions & 8 deletions electroncash/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block'}),
'Bitcoin Unlimited': ('https://explorer.bitcoinunlimited.info',
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
'Loping.net': ('https://bch.loping.net',
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
}

DEFAULT_EXPLORER_TESTNET = 'Bitcoin.com'
Expand All @@ -82,13 +85,37 @@
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block'}),
'Bitcoin Unlimited': ('https://texplorer.bitcoinunlimited.info',
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
'Loping.net': ('https://tbch.loping.net',
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
}

DEFAULT_EXPLORER_TESTNET4 = 'Loping.net'

testnet4_block_explorers = {
'Loping.net': ('https://tbch4.loping.net',
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
}

DEFAULT_EXPLORER_SCALENET = 'Loping.net'

scalenet_block_explorers = {
'Loping.net': ('https://sbch.loping.net',
Address.FMT_CASHADDR,
{'tx': 'tx', 'addr': 'address', 'block': 'block-height'}),
}

def BE_info():
if networks.net.TESTNET:
netname = networks.net.__name__
if netname == 'TestNet':
return testnet_block_explorers
elif netname == 'TestNet4':
return testnet4_block_explorers
elif netname == 'ScaleNet':
return scalenet_block_explorers
return mainnet_block_explorers

def BE_tuple(config):
Expand All @@ -98,9 +125,14 @@ def BE_tuple(config):
)

def BE_default_explorer():
return (DEFAULT_EXPLORER
if not networks.net.TESTNET
else DEFAULT_EXPLORER_TESTNET)
netname = networks.net.__name__
if netname == 'TestNet':
return DEFAULT_EXPLORER_TESTNET
elif netname == 'TestNet4':
return DEFAULT_EXPLORER_TESTNET4
elif netname == 'ScaleNet':
return DEFAULT_EXPLORER_SCALENET
return DEFAULT_EXPLORER

def BE_from_config(config):
return config.get('block_explorer', BE_default_explorer())
Expand Down

0 comments on commit 8f53e1e

Please sign in to comment.