Browse Source

walletdb: fix convert_version_58 for partial local txs

The transaction dict can also contain PSBTs (in addition to complete raw hex txs).
This is the case if the user has saved a partial (e.g. unsigned) tx as local into the history.

fixes https://github.com/spesmilo/electrum/issues/8913
master
SomberNight 2 years ago
parent
commit
51b7fc04ef
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/wallet_db.py
  2. 8
      tests/test_storage_upgrade.py
  3. 2749
      tests/test_storage_upgrade/client_4_5_2_9dk_with_ln

5
electrum/wallet_db.py

@ -40,7 +40,7 @@ from . import util, bitcoin
from .util import profiler, WalletFileException, multisig_type, TxMinedInfo, bfh, MyEncoder
from .invoices import Invoice, Request
from .keystore import bip44_derivation
from .transaction import Transaction, TxOutpoint, tx_from_any, PartialTransaction, PartialTxOutput
from .transaction import Transaction, TxOutpoint, tx_from_any, PartialTransaction, PartialTxOutput, BadHeaderMagic
from .logging import Logger
from .lnutil import LOCAL, REMOTE, HTLCOwner, ChannelType
@ -1119,6 +1119,9 @@ class WalletDBUpgrader(Logger):
transactions = self.get('transactions', {}) # txid -> raw_tx
prevouts_by_scripthash = {}
for txid, raw_tx in transactions.items():
try:
tx = PartialTransaction.from_raw_psbt(raw_tx)
except BadHeaderMagic:
tx = Transaction(raw_tx)
for idx, txout in enumerate(tx.outputs()):
outpoint = f"{txid}:{idx}"

8
tests/test_storage_upgrade.py

@ -313,6 +313,14 @@ class TestStorageUpgrade(WalletTestCase):
wallet_str = self._get_wallet_str()
await self._upgrade_storage(wallet_str)
@as_testnet
async def test_upgrade_from_client_4_5_2_9dk_with_ln(self):
# This is a realistic testnet wallet, from the "9dk" seed, including some lightning sends/receives,
# some labels, frozen addresses, saved local txs, invoices/requests, etc. The file also has partial writes.
# Also, regression test for #8913
wallet_str = self._get_wallet_str()
await self._upgrade_storage(wallet_str)
##########
plugins: 'electrum.plugin.Plugins'

2749
tests/test_storage_upgrade/client_4_5_2_9dk_with_ln

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save