Browse Source

synchronizer: request tx from server if we only have partial local tx

Note that there is a slight distinction between
`not tx.is_complete()` and `isinstance(tx, PartialTransaction)`,
which is that technically you can have a PSBT that is already complete
but was not yet converted to a standard bitcoin tx.
hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
72491bdf18
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/json_db.py
  2. 7
      electrum/synchronizer.py

4
electrum/json_db.py

@ -33,7 +33,7 @@ from typing import Dict, Optional, List, Tuple, Set, Iterable, NamedTuple, Seque
from . import util, bitcoin
from .util import profiler, WalletFileException, multisig_type, TxMinedInfo, bfh
from .keystore import bip44_derivation
from .transaction import Transaction, TxOutpoint, tx_from_any
from .transaction import Transaction, TxOutpoint, tx_from_any, PartialTransaction
from .logging import Logger
# seed_version is now used for the version of the wallet file
@ -708,7 +708,7 @@ class JsonDB(Logger):
raise Exception(f"trying to add tx to db with inconsistent txid: {tx_hash} != {tx.txid()}")
# don't allow overwriting complete tx with partial tx
tx_we_already_have = self.transactions.get(tx_hash, None)
if tx_we_already_have is None or not tx_we_already_have.is_complete():
if tx_we_already_have is None or isinstance(tx_we_already_have, PartialTransaction):
self.transactions[tx_hash] = tx
@modifier

7
electrum/synchronizer.py

@ -30,7 +30,7 @@ import logging
from aiorpcx import TaskGroup, run_in_thread, RPCError
from .transaction import Transaction
from .transaction import Transaction, PartialTransaction
from .util import bh2u, make_aiohttp_session, NetworkJobOnDefaultServer
from .bitcoin import address_to_scripthash, is_address
from .network import UntrustedServerReturnedError
@ -196,8 +196,9 @@ class Synchronizer(SynchronizerBase):
for tx_hash, tx_height in hist:
if tx_hash in self.requested_tx:
continue
if self.wallet.db.get_transaction(tx_hash):
continue
tx = self.wallet.db.get_transaction(tx_hash)
if tx and not isinstance(tx, PartialTransaction):
continue # already have complete tx
transaction_hashes.append(tx_hash)
self.requested_tx[tx_hash] = tx_height

Loading…
Cancel
Save