electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 808239bbccc7ac02ccb33b040a21bcbdb7199c9b
parent 46ae86f6002489c501416b82146a25fc80397943
Author: SomberNight <somber.night@protonmail.com>
Date:   Sat, 11 May 2019 02:08:15 +0200

wallet: fix deleting address from Imported_Wallet

closes #4481

Diffstat:
Melectrum/tests/test_wallet.py | 12+++++++++---
Melectrum/wallet.py | 2+-
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/electrum/tests/test_wallet.py b/electrum/tests/test_wallet.py @@ -10,7 +10,7 @@ from io import StringIO from electrum.storage import WalletStorage from electrum.json_db import FINAL_SEED_VERSION from electrum.wallet import (Abstract_Wallet, Standard_Wallet, create_new_wallet, - restore_wallet_from_text) + restore_wallet_from_text, Imported_Wallet) from electrum.exchange_rate import ExchangeBase, FxThread from electrum.util import TxMinedInfo from electrum.bitcoin import COIN @@ -197,16 +197,22 @@ class TestCreateRestoreWallet(WalletTestCase): def test_restore_wallet_from_text_addresses(self): text = 'bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw bc1qnp78h78vp92pwdwq5xvh8eprlga5q8gu66960c' d = restore_wallet_from_text(text, path=self.wallet_path, network=None) - wallet = d['wallet'] # type: Abstract_Wallet + wallet = d['wallet'] # type: Imported_Wallet self.assertEqual('bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw', wallet.get_receiving_addresses()[0]) self.assertEqual(2, len(wallet.get_receiving_addresses())) + # also test addr deletion + wallet.delete_address('bc1qnp78h78vp92pwdwq5xvh8eprlga5q8gu66960c') + self.assertEqual(1, len(wallet.get_receiving_addresses())) def test_restore_wallet_from_text_privkeys(self): text = 'p2wpkh:L4jkdiXszG26SUYvwwJhzGwg37H2nLhrbip7u6crmgNeJysv5FHL p2wpkh:L24GxnN7NNUAfCXA6hFzB1jt59fYAAiFZMcLaJ2ZSawGpM3uqhb1' d = restore_wallet_from_text(text, path=self.wallet_path, network=None) - wallet = d['wallet'] # type: Abstract_Wallet + wallet = d['wallet'] # type: Imported_Wallet addr0 = wallet.get_receiving_addresses()[0] self.assertEqual('bc1q2ccr34wzep58d4239tl3x3734ttle92a8srmuw', addr0) self.assertEqual('p2wpkh:L4jkdiXszG26SUYvwwJhzGwg37H2nLhrbip7u6crmgNeJysv5FHL', wallet.export_private_key(addr0, password=None)[0]) self.assertEqual(2, len(wallet.get_receiving_addresses())) + # also test addr deletion + wallet.delete_address('bc1qnp78h78vp92pwdwq5xvh8eprlga5q8gu66960c') + self.assertEqual(1, len(wallet.get_receiving_addresses())) diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -1451,7 +1451,7 @@ class Imported_Wallet(Simple_Wallet): for tx_hash, height in details: transactions_new.add(tx_hash) transactions_to_remove -= transactions_new - self.db.remove_history(address) + self.db.remove_addr_history(address) for tx_hash in transactions_to_remove: self.remove_transaction(tx_hash) self.db.remove_tx_fee(tx_hash)