Attribute more diagnostic messages
This commit is contained in:
parent
93b99ebded
commit
39615333c0
|
@ -37,8 +37,8 @@ from electrum.bitcoin import MIN_RELAY_TX_FEE, COIN, is_valid
|
||||||
from electrum.plugins import run_hook
|
from electrum.plugins import run_hook
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.util import block_explorer, block_explorer_info, block_explorer_URL
|
from electrum.util import block_explorer, block_explorer_info, block_explorer_URL
|
||||||
from electrum.util import print_error, print_msg
|
from electrum.util import format_satoshis, format_satoshis_plain, format_time
|
||||||
from electrum.util import format_satoshis, format_satoshis_plain, format_time, NotEnoughFunds, StoreDict
|
from electrum.util import PrintError, NotEnoughFunds, StoreDict
|
||||||
from electrum import Transaction
|
from electrum import Transaction
|
||||||
from electrum import mnemonic
|
from electrum import mnemonic
|
||||||
from electrum import util, bitcoin, commands, Wallet
|
from electrum import util, bitcoin, commands, Wallet
|
||||||
|
@ -105,7 +105,7 @@ expiration_values = [
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ElectrumWindow(QMainWindow):
|
class ElectrumWindow(QMainWindow, PrintError):
|
||||||
labelsChanged = pyqtSignal()
|
labelsChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, config, network, gui_object):
|
def __init__(self, config, network, gui_object):
|
||||||
|
@ -184,6 +184,10 @@ class ElectrumWindow(QMainWindow):
|
||||||
self.require_fee_update = False
|
self.require_fee_update = False
|
||||||
self.tx_notifications = []
|
self.tx_notifications = []
|
||||||
|
|
||||||
|
def diagnostic_name(self):
|
||||||
|
return "%s/%s" % (PrintError.diagnostic_name(self),
|
||||||
|
self.wallet.basename() if self.wallet else "None")
|
||||||
|
|
||||||
def is_hidden(self):
|
def is_hidden(self):
|
||||||
return self.isMinimized() or self.isHidden()
|
return self.isMinimized() or self.isHidden()
|
||||||
|
|
||||||
|
@ -228,7 +232,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
|
|
||||||
def close_wallet(self):
|
def close_wallet(self):
|
||||||
if self.wallet:
|
if self.wallet:
|
||||||
print_error('close_wallet', self.wallet.storage.path)
|
self.print_error('close_wallet', self.wallet.storage.path)
|
||||||
self.wallet.storage.put('accounts_expanded', self.accounts_expanded)
|
self.wallet.storage.put('accounts_expanded', self.accounts_expanded)
|
||||||
self.wallet.stop_threads()
|
self.wallet.stop_threads()
|
||||||
run_hook('close_wallet')
|
run_hook('close_wallet')
|
||||||
|
@ -417,7 +421,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
def notify_transactions(self):
|
def notify_transactions(self):
|
||||||
if not self.network or not self.network.is_connected():
|
if not self.network or not self.network.is_connected():
|
||||||
return
|
return
|
||||||
print_error("Notifying GUI")
|
self.print_error("Notifying GUI")
|
||||||
if len(self.tx_notifications) > 0:
|
if len(self.tx_notifications) > 0:
|
||||||
# Combine the transactions if there are more then three
|
# Combine the transactions if there are more then three
|
||||||
tx_amount = len(self.tx_notifications)
|
tx_amount = len(self.tx_notifications)
|
||||||
|
@ -2855,7 +2859,7 @@ class ElectrumWindow(QMainWindow):
|
||||||
msg += '\n\n' + _('Requires') + ':\n' + '\n'.join(map(lambda x: x[1], descr.get('requires')))
|
msg += '\n\n' + _('Requires') + ':\n' + '\n'.join(map(lambda x: x[1], descr.get('requires')))
|
||||||
grid.addWidget(HelpButton(msg), i, 2)
|
grid.addWidget(HelpButton(msg), i, 2)
|
||||||
except Exception:
|
except Exception:
|
||||||
print_msg("Error: cannot display plugin", name)
|
self.print_msg("error: cannot display plugin", name)
|
||||||
traceback.print_exc(file=sys.stdout)
|
traceback.print_exc(file=sys.stdout)
|
||||||
grid.setRowStretch(i+1,1)
|
grid.setRowStretch(i+1,1)
|
||||||
vbox.addLayout(Buttons(CloseButton(d)))
|
vbox.addLayout(Buttons(CloseButton(d)))
|
||||||
|
|
|
@ -16,20 +16,17 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
import ast
|
import ast
|
||||||
import threading
|
import threading
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import math
|
|
||||||
import json
|
import json
|
||||||
import copy
|
import copy
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
from util import print_msg, print_error, NotEnoughFunds
|
from util import NotEnoughFunds, PrintError, profiler
|
||||||
from util import profiler
|
|
||||||
|
|
||||||
from bitcoin import *
|
from bitcoin import *
|
||||||
from account import *
|
from account import *
|
||||||
|
@ -49,14 +46,14 @@ import paymentrequest
|
||||||
IMPORTED_ACCOUNT = '/x'
|
IMPORTED_ACCOUNT = '/x'
|
||||||
|
|
||||||
|
|
||||||
class WalletStorage(object):
|
class WalletStorage(PrintError):
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
self.lock = threading.RLock()
|
self.lock = threading.RLock()
|
||||||
self.data = {}
|
self.data = {}
|
||||||
self.path = path
|
self.path = path
|
||||||
self.file_exists = False
|
self.file_exists = False
|
||||||
print_error( "wallet path", self.path )
|
self.print_error("wallet path", self.path)
|
||||||
if self.path:
|
if self.path:
|
||||||
self.read(self.path)
|
self.read(self.path)
|
||||||
|
|
||||||
|
@ -87,7 +84,7 @@ class WalletStorage(object):
|
||||||
json.dumps(key)
|
json.dumps(key)
|
||||||
json.dumps(value)
|
json.dumps(value)
|
||||||
except:
|
except:
|
||||||
print_error('Failed to convert label to json format', key)
|
self.print_error('Failed to convert label to json format', key)
|
||||||
continue
|
continue
|
||||||
self.data[key] = value
|
self.data[key] = value
|
||||||
self.file_exists = True
|
self.file_exists = True
|
||||||
|
@ -106,7 +103,7 @@ class WalletStorage(object):
|
||||||
json.dumps(key)
|
json.dumps(key)
|
||||||
json.dumps(value)
|
json.dumps(value)
|
||||||
except:
|
except:
|
||||||
print_error("json error: cannot save", key)
|
self.print_error("json error: cannot save", key)
|
||||||
return
|
return
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if value is not None:
|
if value is not None:
|
||||||
|
@ -136,7 +133,7 @@ class WalletStorage(object):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Abstract_Wallet(object):
|
class Abstract_Wallet(PrintError):
|
||||||
"""
|
"""
|
||||||
Wallet classes are created to handle various address generation methods.
|
Wallet classes are created to handle various address generation methods.
|
||||||
Completion states (watching-only, single account, no seed, etc) are handled inside classes.
|
Completion states (watching-only, single account, no seed, etc) are handled inside classes.
|
||||||
|
@ -191,6 +188,9 @@ class Abstract_Wallet(object):
|
||||||
if self.storage.get('wallet_type') is None:
|
if self.storage.get('wallet_type') is None:
|
||||||
self.storage.put('wallet_type', self.wallet_type, True)
|
self.storage.put('wallet_type', self.wallet_type, True)
|
||||||
|
|
||||||
|
def diagnostic_name(self):
|
||||||
|
return self.basename()
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
def load_transactions(self):
|
def load_transactions(self):
|
||||||
self.txi = self.storage.get('txi', {})
|
self.txi = self.storage.get('txi', {})
|
||||||
|
@ -202,7 +202,7 @@ class Abstract_Wallet(object):
|
||||||
tx = Transaction(raw)
|
tx = Transaction(raw)
|
||||||
self.transactions[tx_hash] = tx
|
self.transactions[tx_hash] = tx
|
||||||
if self.txi.get(tx_hash) is None and self.txo.get(tx_hash) is None and (tx_hash not in self.pruned_txo.values()):
|
if self.txi.get(tx_hash) is None and self.txo.get(tx_hash) is None and (tx_hash not in self.pruned_txo.values()):
|
||||||
print_error("removing unreferenced tx", tx_hash)
|
self.print_error("removing unreferenced tx", tx_hash)
|
||||||
self.transactions.pop(tx_hash)
|
self.transactions.pop(tx_hash)
|
||||||
|
|
||||||
@profiler
|
@profiler
|
||||||
|
@ -291,7 +291,7 @@ class Abstract_Wallet(object):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print_error("cannot load account", v)
|
self.print_error("cannot load account", v)
|
||||||
|
|
||||||
def synchronize(self):
|
def synchronize(self):
|
||||||
pass
|
pass
|
||||||
|
@ -689,7 +689,7 @@ class Abstract_Wallet(object):
|
||||||
for addr, l in dd.items():
|
for addr, l in dd.items():
|
||||||
for n, v, is_cb in l:
|
for n, v, is_cb in l:
|
||||||
if n == prevout_n:
|
if n == prevout_n:
|
||||||
print_error("found pay-to-pubkey address:", addr)
|
self.print_error("found pay-to-pubkey address:", addr)
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
def add_transaction(self, tx_hash, tx):
|
def add_transaction(self, tx_hash, tx):
|
||||||
|
@ -745,7 +745,7 @@ class Abstract_Wallet(object):
|
||||||
|
|
||||||
def remove_transaction(self, tx_hash):
|
def remove_transaction(self, tx_hash):
|
||||||
with self.transaction_lock:
|
with self.transaction_lock:
|
||||||
print_error("removing tx from history", tx_hash)
|
self.print_error("removing tx from history", tx_hash)
|
||||||
#tx = self.transactions.pop(tx_hash)
|
#tx = self.transactions.pop(tx_hash)
|
||||||
for ser, hh in self.pruned_txo.items():
|
for ser, hh in self.pruned_txo.items():
|
||||||
if hh == tx_hash:
|
if hh == tx_hash:
|
||||||
|
@ -841,7 +841,7 @@ class Abstract_Wallet(object):
|
||||||
|
|
||||||
# fixme: this may happen if history is incomplete
|
# fixme: this may happen if history is incomplete
|
||||||
if balance not in [None, 0]:
|
if balance not in [None, 0]:
|
||||||
print_error("Error: history not synchronized")
|
self.print_error("Error: history not synchronized")
|
||||||
return []
|
return []
|
||||||
|
|
||||||
return h2
|
return h2
|
||||||
|
@ -930,7 +930,7 @@ class Abstract_Wallet(object):
|
||||||
fee = fixed_fee if fixed_fee is not None else self.estimated_fee(tx, fee_per_kb)
|
fee = fixed_fee if fixed_fee is not None else self.estimated_fee(tx, fee_per_kb)
|
||||||
continue
|
continue
|
||||||
break
|
break
|
||||||
print_error("using %d inputs"%len(tx.inputs))
|
self.print_error("using %d inputs"%len(tx.inputs))
|
||||||
|
|
||||||
# change address
|
# change address
|
||||||
if not change_addr:
|
if not change_addr:
|
||||||
|
@ -963,11 +963,11 @@ class Abstract_Wallet(object):
|
||||||
change_amount = total - ( amount + fee )
|
change_amount = total - ( amount + fee )
|
||||||
if change_amount > DUST_THRESHOLD:
|
if change_amount > DUST_THRESHOLD:
|
||||||
tx.outputs.append(('address', change_addr, change_amount))
|
tx.outputs.append(('address', change_addr, change_amount))
|
||||||
print_error('change', change_amount)
|
self.print_error('change', change_amount)
|
||||||
else:
|
else:
|
||||||
print_error('not keeping dust', change_amount)
|
self.print_error('not keeping dust', change_amount)
|
||||||
else:
|
else:
|
||||||
print_error('not keeping dust', change_amount)
|
self.print_error('not keeping dust', change_amount)
|
||||||
|
|
||||||
# Sort the inputs and outputs deterministically
|
# Sort the inputs and outputs deterministically
|
||||||
tx.BIP_LI01_sort()
|
tx.BIP_LI01_sort()
|
||||||
|
@ -1100,7 +1100,7 @@ class Abstract_Wallet(object):
|
||||||
vr = self.verified_tx.keys() + self.unverified_tx.keys()
|
vr = self.verified_tx.keys() + self.unverified_tx.keys()
|
||||||
for tx_hash in self.transactions.keys():
|
for tx_hash in self.transactions.keys():
|
||||||
if tx_hash not in vr:
|
if tx_hash not in vr:
|
||||||
print_error("removing transaction", tx_hash)
|
self.print_error("removing transaction", tx_hash)
|
||||||
self.transactions.pop(tx_hash)
|
self.transactions.pop(tx_hash)
|
||||||
|
|
||||||
def start_threads(self, network):
|
def start_threads(self, network):
|
||||||
|
@ -1743,19 +1743,19 @@ class BIP32_HD_Wallet(BIP32_Wallet):
|
||||||
self.next_account = self.get_next_account(None)
|
self.next_account = self.get_next_account(None)
|
||||||
self.storage.put('next_account2', self.next_account)
|
self.storage.put('next_account2', self.next_account)
|
||||||
except:
|
except:
|
||||||
print_error('cannot get next account')
|
self.print_error('cannot get next account')
|
||||||
# check pending account
|
# check pending account
|
||||||
if self.next_account is not None:
|
if self.next_account is not None:
|
||||||
next_id, next_xpub, next_pubkey, next_address = self.next_account
|
next_id, next_xpub, next_pubkey, next_address = self.next_account
|
||||||
if self.address_is_old(next_address):
|
if self.address_is_old(next_address):
|
||||||
print_error("creating account", next_id)
|
self.print_error("creating account", next_id)
|
||||||
self.add_account(next_id, BIP32_Account({'xpub':next_xpub}))
|
self.add_account(next_id, BIP32_Account({'xpub':next_xpub}))
|
||||||
# here the user should get a notification
|
# here the user should get a notification
|
||||||
self.next_account = None
|
self.next_account = None
|
||||||
self.storage.put('next_account2', self.next_account)
|
self.storage.put('next_account2', self.next_account)
|
||||||
elif self.history.get(next_address, []):
|
elif self.history.get(next_address, []):
|
||||||
if next_id not in self.accounts:
|
if next_id not in self.accounts:
|
||||||
print_error("create pending account", next_id)
|
self.print_error("create pending account", next_id)
|
||||||
self.accounts[next_id] = PendingAccount({'pending':True, 'address':next_address, 'pubkey':next_pubkey})
|
self.accounts[next_id] = PendingAccount({'pending':True, 'address':next_address, 'pubkey':next_pubkey})
|
||||||
self.save_accounts()
|
self.save_accounts()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue