wallet: introduce namedtuples TxMinedStatus and VerifiedTxInfo
This commit is contained in:
@@ -131,8 +131,8 @@ class HistoryScreen(CScreen):
|
||||
d = LabelDialog(_('Enter Transaction Label'), text, callback)
|
||||
d.open()
|
||||
|
||||
def get_card(self, tx_hash, height, conf, timestamp, value, balance):
|
||||
status, status_str = self.app.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
||||
def get_card(self, tx_hash, tx_mined_status, value, balance):
|
||||
status, status_str = self.app.wallet.get_tx_status(tx_hash, tx_mined_status)
|
||||
icon = "atlas://electrum/gui/kivy/theming/light/" + TX_ICONS[status]
|
||||
label = self.app.wallet.get_label(tx_hash) if tx_hash else _('Pruned transaction outputs')
|
||||
ri = {}
|
||||
@@ -141,7 +141,7 @@ class HistoryScreen(CScreen):
|
||||
ri['icon'] = icon
|
||||
ri['date'] = status_str
|
||||
ri['message'] = label
|
||||
ri['confirmations'] = conf
|
||||
ri['confirmations'] = tx_mined_status.conf
|
||||
if value is not None:
|
||||
ri['is_mine'] = value < 0
|
||||
if value < 0: value = - value
|
||||
@@ -158,7 +158,6 @@ class HistoryScreen(CScreen):
|
||||
return
|
||||
history = reversed(self.app.wallet.get_history())
|
||||
history_card = self.screen.ids.history_container
|
||||
count = 0
|
||||
history_card.data = [self.get_card(*item) for item in history]
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import datetime
|
||||
from electrum.address_synchronizer import TX_HEIGHT_LOCAL
|
||||
from .util import *
|
||||
from electrum.i18n import _
|
||||
from electrum.util import block_explorer_URL, profiler, print_error
|
||||
from electrum.util import block_explorer_URL, profiler, print_error, TxMinedStatus
|
||||
|
||||
try:
|
||||
from electrum.plot import plot_history, NothingToPlotException
|
||||
@@ -237,7 +237,8 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop):
|
||||
value = tx_item['value'].value
|
||||
balance = tx_item['balance'].value
|
||||
label = tx_item['label']
|
||||
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
||||
tx_mined_status = TxMinedStatus(height, conf, timestamp, None)
|
||||
status, status_str = self.wallet.get_tx_status(tx_hash, tx_mined_status)
|
||||
has_invoice = self.wallet.invoices.paid.get(tx_hash)
|
||||
icon = self.icon_cache.get(":icons/" + TX_ICONS[status])
|
||||
v_str = self.parent.format_amount(value, is_diff=True, whitespaces=True)
|
||||
@@ -304,10 +305,11 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop):
|
||||
label = self.wallet.get_label(txid)
|
||||
item.setText(3, label)
|
||||
|
||||
def update_item(self, tx_hash, height, conf, timestamp):
|
||||
def update_item(self, tx_hash, tx_mined_status):
|
||||
if self.wallet is None:
|
||||
return
|
||||
status, status_str = self.wallet.get_tx_status(tx_hash, height, conf, timestamp)
|
||||
conf = tx_mined_status.conf
|
||||
status, status_str = self.wallet.get_tx_status(tx_hash, tx_mined_status)
|
||||
icon = self.icon_cache.get(":icons/" + TX_ICONS[status])
|
||||
items = self.findItems(tx_hash, Qt.UserRole|Qt.MatchContains|Qt.MatchRecursive, column=1)
|
||||
if items:
|
||||
@@ -332,7 +334,7 @@ class HistoryList(MyTreeWidget, AcceptFileDragDrop):
|
||||
column_title = self.headerItem().text(column)
|
||||
column_data = item.text(column)
|
||||
tx_URL = block_explorer_URL(self.config, 'tx', tx_hash)
|
||||
height, conf, timestamp, header_hash = self.wallet.get_tx_height(tx_hash)
|
||||
height = self.wallet.get_tx_height(tx_hash).height
|
||||
tx = self.wallet.transactions.get(tx_hash)
|
||||
is_relevant, is_mine, v, fee = self.wallet.get_wallet_delta(tx)
|
||||
is_unconfirmed = height <= 0
|
||||
|
||||
@@ -87,9 +87,9 @@ class ElectrumGui:
|
||||
+ "%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s"
|
||||
messages = []
|
||||
|
||||
for item in self.wallet.get_history():
|
||||
tx_hash, height, conf, timestamp, delta, balance = item
|
||||
if conf:
|
||||
for tx_hash, tx_mined_status, delta, balance in self.wallet.get_history():
|
||||
if tx_mined_status.conf:
|
||||
timestamp = tx_mined_status.timestamp
|
||||
try:
|
||||
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
|
||||
except Exception:
|
||||
|
||||
@@ -109,9 +109,9 @@ class ElectrumGui:
|
||||
|
||||
b = 0
|
||||
self.history = []
|
||||
for item in self.wallet.get_history():
|
||||
tx_hash, height, conf, timestamp, value, balance = item
|
||||
if conf:
|
||||
for tx_hash, tx_mined_status, value, balance in self.wallet.get_history():
|
||||
if tx_mined_status.conf:
|
||||
timestamp = tx_mined_status.timestamp
|
||||
try:
|
||||
time_str = datetime.datetime.fromtimestamp(timestamp).isoformat(' ')[:-3]
|
||||
except Exception:
|
||||
|
||||
Reference in New Issue
Block a user