mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
parent
cc9ad3ae90
commit
aadde9be17
2 changed files with 43 additions and 13 deletions
|
@ -860,7 +860,20 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
|
|
||||||
@needs_test_with_all_ecc_implementations
|
@needs_test_with_all_ecc_implementations
|
||||||
@mock.patch.object(storage.WalletStorage, '_write')
|
@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')
|
wallet = self.create_standard_wallet_from_seed('fold object utility erase deputy output stadium feed stereo usage modify bean')
|
||||||
|
|
||||||
# bootstrap wallet
|
# bootstrap wallet
|
||||||
|
@ -877,6 +890,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325501
|
tx.locktime = 1325501
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
@ -899,6 +914,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
||||||
tx.locktime = 1325501
|
tx.locktime = 1325501
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
self.assertFalse(tx.is_complete())
|
self.assertFalse(tx.is_complete())
|
||||||
|
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
@ -947,9 +964,7 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
||||||
self.assertEqual((0, funding_output_value - 50000, 0), wallet.get_balance())
|
self.assertEqual((0, funding_output_value - 50000, 0), wallet.get_balance())
|
||||||
|
|
||||||
@needs_test_with_all_ecc_implementations
|
def _bump_fee_p2wpkh_when_there_is_a_change_address(self, *, simulate_moving_txs):
|
||||||
@mock.patch.object(storage.WalletStorage, '_write')
|
|
||||||
def test_bump_fee_p2wpkh_when_there_is_a_change_address(self, mock_write):
|
|
||||||
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
||||||
|
|
||||||
# bootstrap wallet
|
# bootstrap wallet
|
||||||
|
@ -966,6 +981,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325499
|
tx.locktime = 1325499
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
@ -988,6 +1005,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
||||||
tx.locktime = 1325500
|
tx.locktime = 1325500
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
self.assertFalse(tx.is_complete())
|
self.assertFalse(tx.is_complete())
|
||||||
|
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
@ -1002,9 +1021,7 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
||||||
self.assertEqual((0, 7490060, 0), wallet.get_balance())
|
self.assertEqual((0, 7490060, 0), wallet.get_balance())
|
||||||
|
|
||||||
@needs_test_with_all_ecc_implementations
|
def _bump_fee_when_user_sends_max(self, *, simulate_moving_txs):
|
||||||
@mock.patch.object(storage.WalletStorage, '_write')
|
|
||||||
def test_bump_fee_when_user_sends_max(self, mock_write):
|
|
||||||
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
||||||
|
|
||||||
# bootstrap wallet
|
# bootstrap wallet
|
||||||
|
@ -1020,6 +1037,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325499
|
tx.locktime = 1325499
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
@ -1042,6 +1061,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
||||||
tx.locktime = 1325500
|
tx.locktime = 1325500
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
self.assertFalse(tx.is_complete())
|
self.assertFalse(tx.is_complete())
|
||||||
|
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
@ -1056,9 +1077,7 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
||||||
self.assertEqual((0, 0, 0), wallet.get_balance())
|
self.assertEqual((0, 0, 0), wallet.get_balance())
|
||||||
|
|
||||||
@needs_test_with_all_ecc_implementations
|
def _bump_fee_when_new_inputs_need_to_be_added(self, *, simulate_moving_txs):
|
||||||
@mock.patch.object(storage.WalletStorage, '_write')
|
|
||||||
def test_bump_fee_when_new_inputs_need_to_be_added(self, mock_write):
|
|
||||||
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
||||||
|
|
||||||
# bootstrap wallet (incoming funding_tx1)
|
# bootstrap wallet (incoming funding_tx1)
|
||||||
|
@ -1075,6 +1094,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325499
|
tx.locktime = 1325499
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
@ -1105,6 +1126,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
tx = wallet.bump_fee(tx=Transaction(tx.serialize()), new_fee_rate=70.0, config=self.config)
|
||||||
tx.locktime = 1325500
|
tx.locktime = 1325500
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
self.assertFalse(tx.is_complete())
|
self.assertFalse(tx.is_complete())
|
||||||
|
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
@ -1119,9 +1142,7 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
wallet.receive_tx_callback(tx.txid(), tx, TX_HEIGHT_UNCONFIRMED)
|
||||||
self.assertEqual((0, 4_990_300, 0), wallet.get_balance())
|
self.assertEqual((0, 4_990_300, 0), wallet.get_balance())
|
||||||
|
|
||||||
@needs_test_with_all_ecc_implementations
|
def _rbf_batching(self, *, simulate_moving_txs):
|
||||||
@mock.patch.object(storage.WalletStorage, '_write')
|
|
||||||
def test_rbf_batching(self, mock_write):
|
|
||||||
wallet = self.create_standard_wallet_from_seed('frost repair depend effort salon ring foam oak cancel receive save usage')
|
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})
|
config = SimpleConfig({'electrum_path': self.electrum_path, 'batch_rbf': True})
|
||||||
|
|
||||||
|
@ -1139,6 +1160,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325499
|
tx.locktime = 1325499
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
@ -1173,6 +1196,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325499
|
tx.locktime = 1325499
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
@ -1199,6 +1224,8 @@ class TestWalletSending(TestCaseForTestnet):
|
||||||
tx.set_rbf(True)
|
tx.set_rbf(True)
|
||||||
tx.locktime = 1325499
|
tx.locktime = 1325499
|
||||||
tx.version = 1
|
tx.version = 1
|
||||||
|
if simulate_moving_txs:
|
||||||
|
tx = Transaction(str(tx))
|
||||||
wallet.sign_transaction(tx, password=None)
|
wallet.sign_transaction(tx, password=None)
|
||||||
|
|
||||||
self.assertTrue(tx.is_complete())
|
self.assertTrue(tx.is_complete())
|
||||||
|
|
|
@ -688,7 +688,10 @@ class Transaction:
|
||||||
def remove_signatures(self):
|
def remove_signatures(self):
|
||||||
for txin in self.inputs():
|
for txin in self.inputs():
|
||||||
txin['signatures'] = [None] * len(txin['signatures'])
|
txin['signatures'] = [None] * len(txin['signatures'])
|
||||||
|
txin['scriptSig'] = None
|
||||||
|
txin['witness'] = None
|
||||||
assert not self.is_complete()
|
assert not self.is_complete()
|
||||||
|
self.raw = None
|
||||||
|
|
||||||
def deserialize(self, force_full_parse=False):
|
def deserialize(self, force_full_parse=False):
|
||||||
if self.raw is None:
|
if self.raw is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue