ttransaction: fix remove_signatures - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit aadde9be17cbb7f9f9aefee1c9a509ae2ed5466c DIR parent cc9ad3ae9087831e668a55120ec279f8a7135584 HTML Author: SomberNight <somber.night@protonmail.com> Date: Fri, 5 Jul 2019 21:16:58 +0200 ttransaction: fix remove_signatures closes #5491 Diffstat: M electrum/tests/test_wallet_vertica… | 53 +++++++++++++++++++++++-------- M electrum/transaction.py | 3 +++ 2 files changed, 43 insertions(+), 13 deletions(-) --- DIR diff --git a/electrum/tests/test_wallet_vertical.py b/electrum/tests/test_wallet_vertical.py t@@ -860,7 +860,20 @@ class TestWalletSending(TestCaseForTestnet): @needs_test_with_all_ecc_implementations @mock.patch.object(storage.WalletStorage, '_write') - def test_bump_fee_p2pkh_when_there_is_a_change_address(self, mock_write): + def test_rbf(self, mock_write): + for simulate_moving_txs in (False, True): + with self.subTest(msg="_bump_fee_p2pkh_when_there_is_a_change_address", simulate_moving_txs=simulate_moving_txs): + self._bump_fee_p2pkh_when_there_is_a_change_address(simulate_moving_txs=simulate_moving_txs) + with self.subTest(msg="_bump_fee_p2wpkh_when_there_is_a_change_address", simulate_moving_txs=simulate_moving_txs): + self._bump_fee_p2wpkh_when_there_is_a_change_address(simulate_moving_txs=simulate_moving_txs) + with self.subTest(msg="_bump_fee_when_user_sends_max", simulate_moving_txs=simulate_moving_txs): + self._bump_fee_when_user_sends_max(simulate_moving_txs=simulate_moving_txs) + with self.subTest(msg="_bump_fee_when_new_inputs_need_to_be_added", simulate_moving_txs=simulate_moving_txs): + self._bump_fee_when_new_inputs_need_to_be_added(simulate_moving_txs=simulate_moving_txs) + with self.subTest(msg="_rbf_batching", simulate_moving_txs=simulate_moving_txs): + self._rbf_batching(simulate_moving_txs=simulate_moving_txs) + + def _bump_fee_p2pkh_when_there_is_a_change_address(self, *, simulate_moving_txs): wallet = self.create_standard_wallet_from_seed('fold object utility erase deputy output stadium feed stereo usage modify bean') # bootstrap wallet t@@ -877,6 +890,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325501 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) t@@ -899,6 +914,8 @@ class TestWalletSending(TestCaseForTestnet): tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config) tx.locktime = 1325501 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) self.assertFalse(tx.is_complete()) wallet.sign_transaction(tx, password=None) t@@ -947,9 +964,7 @@ class TestWalletSending(TestCaseForTestnet): wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED) self.assertEqual((0, funding_output_value - 50000, 0), wallet.get_balance()) - @needs_test_with_all_ecc_implementations - @mock.patch.object(storage.WalletStorage, '_write') - def test_bump_fee_p2wpkh_when_there_is_a_change_address(self, mock_write): + def _bump_fee_p2wpkh_when_there_is_a_change_address(self, *, simulate_moving_txs): wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage') # bootstrap wallet t@@ -966,6 +981,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325499 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) t@@ -988,6 +1005,8 @@ class TestWalletSending(TestCaseForTestnet): tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config) tx.locktime = 1325500 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) self.assertFalse(tx.is_complete()) wallet.sign_transaction(tx, password=None) t@@ -1002,9 +1021,7 @@ class TestWalletSending(TestCaseForTestnet): wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED) self.assertEqual((0, 7490060, 0), wallet.get_balance()) - @needs_test_with_all_ecc_implementations - @mock.patch.object(storage.WalletStorage, '_write') - def test_bump_fee_when_user_sends_max(self, mock_write): + def _bump_fee_when_user_sends_max(self, *, simulate_moving_txs): wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage') # bootstrap wallet t@@ -1020,6 +1037,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325499 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) t@@ -1042,6 +1061,8 @@ class TestWalletSending(TestCaseForTestnet): tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config) tx.locktime = 1325500 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) self.assertFalse(tx.is_complete()) wallet.sign_transaction(tx, password=None) t@@ -1056,9 +1077,7 @@ class TestWalletSending(TestCaseForTestnet): wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED) self.assertEqual((0, 0, 0), wallet.get_balance()) - @needs_test_with_all_ecc_implementations - @mock.patch.object(storage.WalletStorage, '_write') - def test_bump_fee_when_new_inputs_need_to_be_added(self, mock_write): + def _bump_fee_when_new_inputs_need_to_be_added(self, *, simulate_moving_txs): wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage') # bootstrap wallet (incoming funding_tx1) t@@ -1075,6 +1094,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325499 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) t@@ -1105,6 +1126,8 @@ class TestWalletSending(TestCaseForTestnet): tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config) tx.locktime = 1325500 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) self.assertFalse(tx.is_complete()) wallet.sign_transaction(tx, password=None) t@@ -1119,9 +1142,7 @@ class TestWalletSending(TestCaseForTestnet): wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED) self.assertEqual((0, 4_990_300, 0), wallet.get_balance()) - @needs_test_with_all_ecc_implementations - @mock.patch.object(storage.WalletStorage, '_write') - def test_rbf_batching(self, mock_write): + def _rbf_batching(self, *, simulate_moving_txs): wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage') config = SimpleConfig({'electrum_path': self.electrum_path, 'batch_rbf': True}) t@@ -1139,6 +1160,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325499 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) t@@ -1173,6 +1196,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325499 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) t@@ -1199,6 +1224,8 @@ class TestWalletSending(TestCaseForTestnet): tx.set_rbf(True) tx.locktime = 1325499 tx.version = 1 + if simulate_moving_txs: + tx = Transaction(str(tx)) wallet.sign_transaction(tx, password=None) self.assertTrue(tx.is_complete()) DIR diff --git a/electrum/transaction.py b/electrum/transaction.py t@@ -688,7 +688,10 @@ class Transaction: def remove_signatures(self): for txin in self.inputs(): txin['signatures'] = [None] * len(txin['signatures']) + txin['scriptSig'] = None + txin['witness'] = None assert not self.is_complete() + self.raw = None def deserialize(self, force_full_parse=False): if self.raw is None: