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
This commit is contained in:
@@ -40,7 +40,7 @@ from . import util, bitcoin
|
|||||||
from .util import profiler, WalletFileException, multisig_type, TxMinedInfo, bfh, MyEncoder
|
from .util import profiler, WalletFileException, multisig_type, TxMinedInfo, bfh, MyEncoder
|
||||||
from .invoices import Invoice, Request
|
from .invoices import Invoice, Request
|
||||||
from .keystore import bip44_derivation
|
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 .logging import Logger
|
||||||
|
|
||||||
from .lnutil import LOCAL, REMOTE, HTLCOwner, ChannelType
|
from .lnutil import LOCAL, REMOTE, HTLCOwner, ChannelType
|
||||||
@@ -1119,7 +1119,10 @@ class WalletDBUpgrader(Logger):
|
|||||||
transactions = self.get('transactions', {}) # txid -> raw_tx
|
transactions = self.get('transactions', {}) # txid -> raw_tx
|
||||||
prevouts_by_scripthash = {}
|
prevouts_by_scripthash = {}
|
||||||
for txid, raw_tx in transactions.items():
|
for txid, raw_tx in transactions.items():
|
||||||
tx = Transaction(raw_tx)
|
try:
|
||||||
|
tx = PartialTransaction.from_raw_psbt(raw_tx)
|
||||||
|
except BadHeaderMagic:
|
||||||
|
tx = Transaction(raw_tx)
|
||||||
for idx, txout in enumerate(tx.outputs()):
|
for idx, txout in enumerate(tx.outputs()):
|
||||||
outpoint = f"{txid}:{idx}"
|
outpoint = f"{txid}:{idx}"
|
||||||
scripthash = script_to_scripthash(txout.scriptpubkey.hex())
|
scripthash = script_to_scripthash(txout.scriptpubkey.hex())
|
||||||
|
|||||||
@@ -313,6 +313,14 @@ class TestStorageUpgrade(WalletTestCase):
|
|||||||
wallet_str = self._get_wallet_str()
|
wallet_str = self._get_wallet_str()
|
||||||
await self._upgrade_storage(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'
|
plugins: 'electrum.plugin.Plugins'
|
||||||
|
|||||||
2749
tests/test_storage_upgrade/client_4_5_2_9dk_with_ln
Normal file
2749
tests/test_storage_upgrade/client_4_5_2_9dk_with_ln
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user