Clean up block explorer handling. Add menu item to go to block explorer for an address.
Block explorer code is data-driven now. Put block explorer defaulting in one place. Fix URLs for insight.is and blockr.io. Add tradeblock.com explorer. Add menu item to view address on block explorer provided only one is selected.
This commit is contained in:
@@ -21,7 +21,7 @@ import webbrowser
|
||||
|
||||
from util import *
|
||||
from electrum.i18n import _
|
||||
from electrum.util import format_satoshis, format_time
|
||||
from electrum.util import block_explorer_URL, format_satoshis, format_time
|
||||
from electrum.plugins import run_hook
|
||||
|
||||
|
||||
@@ -78,24 +78,18 @@ class HistoryWidget(MyTreeWidget):
|
||||
def create_menu(self, position):
|
||||
self.selectedIndexes()
|
||||
item = self.currentItem()
|
||||
be = self.config.get('block_explorer', 'Blockchain.info')
|
||||
if be == 'Blockchain.info':
|
||||
block_explorer = 'https://blockchain.info/tx/'
|
||||
elif be == 'Blockr.io':
|
||||
block_explorer = 'https://blockr.io/tx/info/'
|
||||
elif be == 'Insight.is':
|
||||
block_explorer = 'http://live.insight.is/tx/'
|
||||
elif be == "Blocktrail.com":
|
||||
block_explorer = 'https://www.blocktrail.com/BTC/tx/'
|
||||
if not item:
|
||||
return
|
||||
tx_hash = str(item.data(0, Qt.UserRole).toString())
|
||||
if not tx_hash:
|
||||
return
|
||||
tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
|
||||
if not tx_URL:
|
||||
return
|
||||
menu = QMenu()
|
||||
menu.addAction(_("Copy ID to Clipboard"), lambda: self.parent.app.clipboard().setText(tx_hash))
|
||||
menu.addAction(_("Details"), lambda: self.parent.show_transaction(self.wallet.transactions.get(tx_hash)))
|
||||
menu.addAction(_("Edit description"), lambda: self.edit_label(item))
|
||||
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(block_explorer + tx_hash))
|
||||
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
|
||||
menu.exec_(self.viewport().mapToGlobal(position))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user