Skip to content

Commit a1d14f5

Browse files
committed
Merge #19671: wallet: Remove -zapwallettxes
3340dba Remove -zapwallettxes (Andrew Chow) Pull request description: It's not clear what use there is to keeping `-zapwallettxes` given that it's intended usage has been superseded by `abandontransaction`. So this removes it outright. Alternative to #19700 ACKs for top commit: meshcollider: utACK 3340dba fanquake: ACK 3340dba - remaining manpage references will get cleaned up pre-release. Tree-SHA512: 3e58e1ef6f4f94894d012b93e88baba3fb9c2ad75b8349403f9ce95b80b50b0b4f443cb623cf76c355930db109f491b3442be3aa02972e841450ce52cf545fc8
2 parents e796fdd + 3340dba commit a1d14f5

File tree

13 files changed

+12
-184
lines changed

13 files changed

+12
-184
lines changed

doc/release-notes-19671.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Wallet
2+
------
3+
4+
* The `-zapwallettxes` startup option has been removed and its functionality removed from the wallet.
5+
This option was originally intended to allow for the fee bumping of transactions that did not
6+
signal RBF. This functionality has been superseded with the abandon transaction feature.

src/dummywallet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ void DummyWalletInit::AddWalletOptions(ArgsManager& argsman) const
4646
"-walletdir=<dir>",
4747
"-walletnotify=<cmd>",
4848
"-walletrbf",
49-
"-zapwallettxes=<mode>",
5049
"-dblogsize=<n>",
5150
"-flushwallet",
5251
"-privdb",

src/wallet/init.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ void WalletInit::AddWalletOptions(ArgsManager& argsman) const
6767
argsman.AddArg("-walletnotify=<cmd>", "Execute command when a wallet transaction changes. %s in cmd is replaced by TxID and %w is replaced by wallet name. %w is not currently implemented on windows. On systems where %w is supported, it should NOT be quoted because this would break shell escaping used to invoke the command.", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
6868
#endif
6969
argsman.AddArg("-walletrbf", strprintf("Send transactions with full-RBF opt-in enabled (RPC only, default: %u)", DEFAULT_WALLET_RBF), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
70-
argsman.AddArg("-zapwallettxes=<mode>", "Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup"
71-
" (1 = keep tx meta data e.g. payment request information, 2 = drop tx meta data)", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
7270

7371
argsman.AddArg("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
7472
argsman.AddArg("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
7573
argsman.AddArg("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
7674
argsman.AddArg("-walletrejectlongchains", strprintf("Wallet will not create transactions that violate mempool chain limits (default: %u)", DEFAULT_WALLET_REJECT_LONG_CHAINS), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::WALLET_DEBUG_TEST);
75+
76+
argsman.AddHiddenArgs({"-zapwallettxes"});
7777
}
7878

7979
bool WalletInit::ParameterInteraction() const
@@ -86,26 +86,12 @@ bool WalletInit::ParameterInteraction() const
8686
return true;
8787
}
8888

89-
const bool is_multiwallet = gArgs.GetArgs("-wallet").size() > 1;
90-
9189
if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && gArgs.SoftSetBoolArg("-walletbroadcast", false)) {
9290
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
9391
}
9492

95-
bool zapwallettxes = gArgs.GetBoolArg("-zapwallettxes", false);
96-
// -zapwallettxes implies dropping the mempool on startup
97-
if (zapwallettxes && gArgs.SoftSetBoolArg("-persistmempool", false)) {
98-
LogPrintf("%s: parameter interaction: -zapwallettxes enabled -> setting -persistmempool=0\n", __func__);
99-
}
100-
101-
// -zapwallettxes implies a rescan
102-
if (zapwallettxes) {
103-
if (is_multiwallet) {
104-
return InitError(strprintf(Untranslated("%s is only allowed with a single wallet file"), "-zapwallettxes"));
105-
}
106-
if (gArgs.SoftSetBoolArg("-rescan", true)) {
107-
LogPrintf("%s: parameter interaction: -zapwallettxes enabled -> setting -rescan=1\n", __func__);
108-
}
93+
if (gArgs.IsArgSet("-zapwallettxes")) {
94+
return InitError(Untranslated("-zapwallettxes has been removed. If you are attempting to remove a stuck transaction from your wallet, please use abandontransaction instead."));
10995
}
11096

11197
if (gArgs.GetBoolArg("-sysperms", false))

src/wallet/rpcwallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ static UniValue loadwallet(const JSONRPCRequest& request)
24952495
RPCHelpMan{"loadwallet",
24962496
"\nLoads a wallet from a wallet file or directory."
24972497
"\nNote that all wallet command-line options used when starting bitcoind will be"
2498-
"\napplied to the new wallet (eg -zapwallettxes, rescan, etc).\n",
2498+
"\napplied to the new wallet (eg -rescan, etc).\n",
24992499
{
25002500
{"filename", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet directory or .dat file."},
25012501
{"load_on_startup", RPCArg::Type::BOOL, /* default */ "null", "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},

src/wallet/wallet.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,25 +3175,6 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
31753175
return DBErrors::LOAD_OK;
31763176
}
31773177

3178-
DBErrors CWallet::ZapWalletTx(std::list<CWalletTx>& vWtx)
3179-
{
3180-
DBErrors nZapWalletTxRet = WalletBatch(*database,"cr+").ZapWalletTx(vWtx);
3181-
if (nZapWalletTxRet == DBErrors::NEED_REWRITE)
3182-
{
3183-
if (database->Rewrite("\x04pool"))
3184-
{
3185-
for (const auto& spk_man_pair : m_spk_managers) {
3186-
spk_man_pair.second->RewriteDB();
3187-
}
3188-
}
3189-
}
3190-
3191-
if (nZapWalletTxRet != DBErrors::LOAD_OK)
3192-
return nZapWalletTxRet;
3193-
3194-
return DBErrors::LOAD_OK;
3195-
}
3196-
31973178
bool CWallet::SetAddressBookWithDB(WalletBatch& batch, const CTxDestination& address, const std::string& strName, const std::string& strPurpose)
31983179
{
31993180
bool fUpdated = false;
@@ -3772,20 +3753,6 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
37723753
{
37733754
const std::string walletFile = WalletDataFilePath(location.GetPath()).string();
37743755

3775-
// needed to restore wallet transaction meta data after -zapwallettxes
3776-
std::list<CWalletTx> vWtx;
3777-
3778-
if (gArgs.GetBoolArg("-zapwallettxes", false)) {
3779-
chain.initMessage(_("Zapping all transactions from wallet...").translated);
3780-
3781-
std::unique_ptr<CWallet> tempWallet = MakeUnique<CWallet>(&chain, location, CreateWalletDatabase(location.GetPath()));
3782-
DBErrors nZapWalletRet = tempWallet->ZapWalletTx(vWtx);
3783-
if (nZapWalletRet != DBErrors::LOAD_OK) {
3784-
error = strprintf(_("Error loading %s: Wallet corrupted"), walletFile);
3785-
return nullptr;
3786-
}
3787-
}
3788-
37893756
chain.initMessage(_("Loading wallet...").translated);
37903757

37913758
int64_t nStart = GetTimeMillis();
@@ -4062,30 +4029,6 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(interfaces::Chain& chain,
40624029
}
40634030
walletInstance->chainStateFlushed(chain.getTipLocator());
40644031
walletInstance->database->IncrementUpdateCounter();
4065-
4066-
// Restore wallet transaction metadata after -zapwallettxes=1
4067-
if (gArgs.GetBoolArg("-zapwallettxes", false) && gArgs.GetArg("-zapwallettxes", "1") != "2")
4068-
{
4069-
WalletBatch batch(*walletInstance->database);
4070-
4071-
for (const CWalletTx& wtxOld : vWtx)
4072-
{
4073-
uint256 hash = wtxOld.GetHash();
4074-
std::map<uint256, CWalletTx>::iterator mi = walletInstance->mapWallet.find(hash);
4075-
if (mi != walletInstance->mapWallet.end())
4076-
{
4077-
const CWalletTx* copyFrom = &wtxOld;
4078-
CWalletTx* copyTo = &mi->second;
4079-
copyTo->mapValue = copyFrom->mapValue;
4080-
copyTo->vOrderForm = copyFrom->vOrderForm;
4081-
copyTo->nTimeReceived = copyFrom->nTimeReceived;
4082-
copyTo->nTimeSmart = copyFrom->nTimeSmart;
4083-
copyTo->fFromMe = copyFrom->fFromMe;
4084-
copyTo->nOrderPos = copyFrom->nOrderPos;
4085-
batch.WriteTx(*copyTo);
4086-
}
4087-
}
4088-
}
40894032
}
40904033

40914034
{

src/wallet/wallet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,6 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
10751075
void chainStateFlushed(const CBlockLocator& loc) override;
10761076

10771077
DBErrors LoadWallet(bool& fFirstRunRet);
1078-
DBErrors ZapWalletTx(std::list<CWalletTx>& vWtx);
10791078
DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
10801079

10811080
bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);

src/wallet/walletdb.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -926,23 +926,6 @@ DBErrors WalletBatch::ZapSelectTx(std::vector<uint256>& vTxHashIn, std::vector<u
926926
return DBErrors::LOAD_OK;
927927
}
928928

929-
DBErrors WalletBatch::ZapWalletTx(std::list<CWalletTx>& vWtx)
930-
{
931-
// build list of wallet TXs
932-
std::vector<uint256> vTxHash;
933-
DBErrors err = FindWalletTx(vTxHash, vWtx);
934-
if (err != DBErrors::LOAD_OK)
935-
return err;
936-
937-
// erase each wallet TX
938-
for (const uint256& hash : vTxHash) {
939-
if (!EraseTx(hash))
940-
return DBErrors::CORRUPT;
941-
}
942-
943-
return DBErrors::LOAD_OK;
944-
}
945-
946929
void MaybeCompactWalletDB()
947930
{
948931
static std::atomic<bool> fOneThread(false);

src/wallet/walletdb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ class WalletBatch
257257

258258
DBErrors LoadWallet(CWallet* pwallet);
259259
DBErrors FindWalletTx(std::vector<uint256>& vTxHash, std::list<CWalletTx>& vWtx);
260-
DBErrors ZapWalletTx(std::list<CWalletTx>& vWtx);
261260
DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut);
262261
/* Function to determine if a certain KV/key-type is a key (cryptographical key) type */
263262
static bool IsKeyType(const std::string& strType);

test/functional/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@
105105
'wallet_listtransactions.py',
106106
# vv Tests less than 60s vv
107107
'p2p_sendheaders.py',
108-
'wallet_zapwallettxes.py',
109108
'wallet_importmulti.py',
110109
'mempool_limit.py',
111110
'rpc_txoutproof.py',

test/functional/wallet_basic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,6 @@ def run_test(self):
534534
maintenance = [
535535
'-rescan',
536536
'-reindex',
537-
'-zapwallettxes=1',
538-
'-zapwallettxes=2',
539537
]
540538
chainlimit = 6
541539
for m in maintenance:

0 commit comments

Comments
 (0)