Browse Source

wallet: fix offline hw wallet signing when not specifying --offline

closes #5532
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight 5 years ago
parent
commit
a10dc04b28
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 7
      electrum/interface.py
  2. 9
      electrum/network.py
  3. 15
      electrum/wallet.py

7
electrum/interface.py

@ -157,7 +157,10 @@ class NotificationSession(RPCSession):
self.interface.logger.debug(msg)
class GracefulDisconnect(Exception):
class NetworkException(Exception): pass
class GracefulDisconnect(NetworkException):
log_level = logging.INFO
def __init__(self, *args, log_level=None, **kwargs):
@ -173,7 +176,7 @@ class RequestTimedOut(GracefulDisconnect):
class ErrorParsingSSLCert(Exception): pass
class ErrorGettingSSLCertFromServer(Exception): pass
class ConnectError(Exception): pass
class ConnectError(NetworkException): pass
class _RSClient(RSClient):

9
electrum/network.py

@ -52,7 +52,8 @@ from . import blockchain
from . import bitcoin
from .blockchain import Blockchain, HEADER_SIZE
from .interface import (Interface, serialize_server, deserialize_server,
RequestTimedOut, NetworkTimeout, BUCKET_NAME_OF_ONION_SERVERS)
RequestTimedOut, NetworkTimeout, BUCKET_NAME_OF_ONION_SERVERS,
NetworkException)
from .version import PROTOCOL_VERSION
from .simple_config import SimpleConfig
from .i18n import _
@ -174,10 +175,10 @@ def deserialize_proxy(s: str) -> Optional[dict]:
return proxy
class BestEffortRequestFailed(Exception): pass
class BestEffortRequestFailed(NetworkException): pass
class TxBroadcastError(Exception):
class TxBroadcastError(NetworkException):
def get_message_for_gui(self):
raise NotImplementedError()
@ -205,7 +206,7 @@ class TxBroadcastUnknownError(TxBroadcastError):
_("Consider trying to connect to a different server, or updating Electrum."))
class UntrustedServerReturnedError(Exception):
class UntrustedServerReturnedError(NetworkException):
def __init__(self, *, original_exception):
self.original_exception = original_exception

15
electrum/wallet.py

@ -61,7 +61,7 @@ from .address_synchronizer import (AddressSynchronizer, TX_HEIGHT_LOCAL,
from .paymentrequest import (PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED,
InvoiceStore)
from .contacts import Contacts
from .interface import RequestTimedOut
from .interface import NetworkException
from .ecc_fast import is_using_fast_ecc
from .mnemonic import Mnemonic
from .logging import get_logger
@ -1060,7 +1060,7 @@ class Abstract_Wallet(AddressSynchronizer):
return True
return False
def get_input_tx(self, tx_hash, ignore_timeout=False):
def get_input_tx(self, tx_hash, *, ignore_network_issues=False):
# First look up an input transaction in the wallet where it
# will likely be. If co-signing a transaction it may not have
# all the input txs, in which case we ask the network.
@ -1069,9 +1069,10 @@ class Abstract_Wallet(AddressSynchronizer):
try:
raw_tx = self.network.run_from_another_thread(
self.network.get_transaction(tx_hash, timeout=10))
except RequestTimedOut as e:
self.logger.info(f'getting input txn from network timed out for {tx_hash}')
if not ignore_timeout:
except NetworkException as e:
self.logger.info(f'got network error getting input txn. err: {repr(e)}. txid: {tx_hash}. '
f'if you are intentionally offline, consider using the --offline flag')
if not ignore_network_issues:
raise e
else:
tx = Transaction(raw_tx)
@ -1082,8 +1083,8 @@ class Abstract_Wallet(AddressSynchronizer):
for txin in tx.inputs():
tx_hash = txin['prevout_hash']
# segwit inputs might not be needed for some hw wallets
ignore_timeout = Transaction.is_segwit_input(txin)
txin['prev_tx'] = self.get_input_tx(tx_hash, ignore_timeout)
ignore_network_issues = Transaction.is_segwit_input(txin)
txin['prev_tx'] = self.get_input_tx(tx_hash, ignore_network_issues=ignore_network_issues)
# add output info for hw wallets
info = {}
xpubs = self.get_master_public_keys()

Loading…
Cancel
Save