2023-06-27 20:51:40 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2023 The Dash Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
|
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
"""Test transaction wiping using the wipewallettxes RPC."""
|
|
|
|
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
from test_framework.util import assert_equal, assert_raises_rpc_error
|
|
|
|
|
|
|
|
|
|
|
|
class WipeWalletTxesTest(BitcoinTestFramework):
|
|
|
|
def set_test_params(self):
|
|
|
|
self.setup_clean_chain = True
|
|
|
|
self.num_nodes = 1
|
|
|
|
|
|
|
|
def skip_test_if_missing_module(self):
|
|
|
|
self.skip_if_no_wallet()
|
|
|
|
|
|
|
|
def run_test(self):
|
|
|
|
self.log.info("Test that wipewallettxes removes txes and rescanblockchain is able to recover them")
|
2024-09-26 21:17:04 +02:00
|
|
|
self.generate(self.nodes[0], 101, sync_fun=self.no_op)
|
2023-06-27 20:51:40 +02:00
|
|
|
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
2024-09-26 21:17:04 +02:00
|
|
|
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
|
2023-06-27 20:51:40 +02:00
|
|
|
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 103)
|
|
|
|
self.nodes[0].wipewallettxes()
|
|
|
|
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 0)
|
|
|
|
self.nodes[0].rescanblockchain()
|
|
|
|
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 103)
|
|
|
|
|
|
|
|
self.log.info("Test that wipewallettxes removes txes but keeps confirmed ones when asked to")
|
|
|
|
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
|
|
|
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 104)
|
|
|
|
self.nodes[0].wipewallettxes(True)
|
|
|
|
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 103)
|
|
|
|
self.nodes[0].rescanblockchain()
|
|
|
|
assert_equal(self.nodes[0].getwalletinfo()["txcount"], 103)
|
|
|
|
assert_raises_rpc_error(-5, "Invalid or non-wallet transaction id", self.nodes[0].gettransaction, txid)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
WipeWalletTxesTest().main()
|