wallet: fix offline hw wallet signing when not specifying --offline
closes #5532
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user