Skip to content

Commit c9c32e6

Browse files
jnewberylaanwj
authored andcommitted
[wallet] Kill accounts
This commit does the following changes: - [wallet] Remove 'account' argument from GetLegacyBalance() - GetLegacyBalance() is never called with an account argument. Remove the argument and helper functions. - [wallet] Remove CWallet::ListAccountCreditDebit() - Function no longer used. - [wallet] Remove AccountMove() - Function no longer used. - [wallet] Remove AddAccountingEntry() - Function no longer used. - [wallet] Remove GetAccountCreditDebit() - Function no longer used. - [wallet] Don't rewrite accounting entries when reordering wallet transactions. - Accounting entries are deprecated. Don't rewrite them to the wallet database when re-ordering transactions. - [wallet] Remove WriteAccountingEntry() - Function no longer used. - [wallet] Don't read acentry key-values from wallet on load. - [wallet] Remove ListAccountCreditDebit() - Function no longer used. - [wallet] Remove CAccountingEntry class - No longer used - [wallet] Remove GetLabelDestination - Function no longer used. - [wallet] Delete unused account functions - ReadAccount - WriteAccount - EraseAccount - DeleteLabel - [wallet] Remove fromAccount argument from CommitTransaction() - [wallet] Remove strFromAccount. - No longer used. - [wallet] Remove strSentAccount from GetAmounts(). - No longer used. - [wallet] Update zapwallettxes comment to remove accounts. - [wallet] Remove CAccount - No longer used - [docs] fix typo in release notes for PR 14023
1 parent f180e81 commit c9c32e6

File tree

12 files changed

+45
-447
lines changed

12 files changed

+45
-447
lines changed

doc/release-notes-14023.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Accout API removed
2-
------------------
1+
Account API removed
2+
-------------------
33

44
The 'account' API was deprecated in v0.17 and has been fully removed in v0.18.
55
The 'label' API was introduced in v0.17 as a replacement for accounts.

src/interfaces/wallet.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,11 @@ class PendingWalletTxImpl : public PendingWalletTx
3939

4040
bool commit(WalletValueMap value_map,
4141
WalletOrderForm order_form,
42-
std::string from_account,
4342
std::string& reject_reason) override
4443
{
4544
LOCK2(cs_main, m_wallet.cs_wallet);
4645
CValidationState state;
47-
if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), std::move(order_form), std::move(from_account), m_key, g_connman.get(), state)) {
46+
if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), std::move(order_form), m_key, g_connman.get(), state)) {
4847
reject_reason = state.GetRejectReason();
4948
return false;
5049
}

src/interfaces/wallet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ class PendingWalletTx
289289
//! Send pending transaction and commit to wallet.
290290
virtual bool commit(WalletValueMap value_map,
291291
WalletOrderForm order_form,
292-
std::string from_account,
293292
std::string& reject_reason) = 0;
294293
};
295294

src/qt/walletmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
253253

254254
auto& newTx = transaction.getWtx();
255255
std::string rejectReason;
256-
if (!newTx->commit({} /* mapValue */, std::move(vOrderForm), {} /* fromAccount */, rejectReason))
256+
if (!newTx->commit({} /* mapValue */, std::move(vOrderForm), rejectReason))
257257
return SendCoinsReturn(TransactionCommitFailed, QString::fromStdString(rejectReason));
258258

259259
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);

src/wallet/feebumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Result CommitTransaction(CWallet* wallet, const uint256& txid, CMutableTransacti
242242

243243
CReserveKey reservekey(wallet);
244244
CValidationState state;
245-
if (!wallet->CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm, oldWtx.strFromAccount, reservekey, g_connman.get(), state)) {
245+
if (!wallet->CommitTransaction(tx, std::move(mapValue), oldWtx.vOrderForm, reservekey, g_connman.get(), state)) {
246246
// NOTE: CommitTransaction never returns false, so this should never happen.
247247
errors.push_back(strprintf("The transaction was rejected: %s", FormatStateMessage(state)));
248248
return Result::WALLET_ERROR;

src/wallet/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void WalletInit::AddWalletOptions() const
7878
gArgs.AddArg("-walletnotify=<cmd>", "Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)", false, OptionsCategory::WALLET);
7979
gArgs.AddArg("-walletrbf", strprintf("Send transactions with full-RBF opt-in enabled (RPC only, default: %u)", DEFAULT_WALLET_RBF), false, OptionsCategory::WALLET);
8080
gArgs.AddArg("-zapwallettxes=<mode>", "Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup"
81-
" (1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET);
81+
" (1 = keep tx meta data e.g. payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET);
8282

8383
gArgs.AddArg("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE), true, OptionsCategory::WALLET_DEBUG_TEST);
8484
gArgs.AddArg("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET), true, OptionsCategory::WALLET_DEBUG_TEST);

src/wallet/rpcwallet.cpp

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,6 @@ static UniValue getnewaddress(const JSONRPCRequest& request)
196196
return EncodeDestination(dest);
197197
}
198198

199-
CTxDestination GetLabelDestination(CWallet* const pwallet, const std::string& label, bool bForceNew=false)
200-
{
201-
CTxDestination dest;
202-
if (!pwallet->GetLabelDestination(dest, label, bForceNew)) {
203-
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
204-
}
205-
206-
return dest;
207-
}
208-
209199
static UniValue getrawchangeaddress(const JSONRPCRequest& request)
210200
{
211201
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
@@ -297,20 +287,6 @@ static UniValue setlabel(const JSONRPCRequest& request)
297287
pwallet->SetAddressBook(dest, label, "send");
298288
}
299289

300-
// Detect when there are no addresses using this label.
301-
// If so, delete the account record for it. Labels, unlike addresses, can be deleted,
302-
// and if we wouldn't do this, the record would stick around forever.
303-
bool found_address = false;
304-
for (const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->mapAddressBook) {
305-
if (item.second.name == label) {
306-
found_address = true;
307-
break;
308-
}
309-
}
310-
if (!found_address) {
311-
pwallet->DeleteLabel(old_label);
312-
}
313-
314290
return NullUniValue;
315291
}
316292

@@ -348,7 +324,7 @@ static CTransactionRef SendMoney(CWallet * const pwallet, const CTxDestination &
348324
throw JSONRPCError(RPC_WALLET_ERROR, strError);
349325
}
350326
CValidationState state;
351-
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, "" /* account */, reservekey, g_connman.get(), state)) {
327+
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, reservekey, g_connman.get(), state)) {
352328
strError = strprintf("Error: The transaction was rejected! Reason given: %s", FormatStateMessage(state));
353329
throw JSONRPCError(RPC_WALLET_ERROR, strError);
354330
}
@@ -904,7 +880,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
904880
EnsureWalletIsUnlocked(pwallet);
905881

906882
// Check funds
907-
if (totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, nullptr)) {
883+
if (totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth)) {
908884
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Wallet has insufficient funds");
909885
}
910886

@@ -921,7 +897,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
921897
if (!fCreated)
922898
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
923899
CValidationState state;
924-
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, "" /* account */, keyChange, g_connman.get(), state)) {
900+
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, keyChange, g_connman.get(), state)) {
925901
strFailReason = strprintf("Transaction commit failed:: %s", FormatStateMessage(state));
926902
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
927903
}
@@ -1404,11 +1380,10 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
14041380
static void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
14051381
{
14061382
CAmount nFee;
1407-
std::string dummy_account;
14081383
std::list<COutputEntry> listReceived;
14091384
std::list<COutputEntry> listSent;
14101385

1411-
wtx.GetAmounts(listReceived, listSent, nFee, dummy_account, filter);
1386+
wtx.GetAmounts(listReceived, listSent, nFee, filter);
14121387

14131388
bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);
14141389

@@ -1563,10 +1538,8 @@ UniValue listtransactions(const JSONRPCRequest& request)
15631538
// iterate backwards until we have nCount items to return:
15641539
for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
15651540
{
1566-
CWalletTx *const pwtx = (*it).second.first;
1567-
if (pwtx != nullptr) {
1568-
ListTransactions(pwallet, *pwtx, 0, true, ret, filter);
1569-
}
1541+
CWalletTx *const pwtx = (*it).second;
1542+
ListTransactions(pwallet, *pwtx, 0, true, ret, filter);
15701543
if ((int)ret.size() >= (nCount+nFrom)) break;
15711544
}
15721545
}

src/wallet/test/wallet_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class ListCoinsTestingSetup : public TestChain100Setup
297297
CCoinControl dummy;
298298
BOOST_CHECK(wallet->CreateTransaction({recipient}, tx, reservekey, fee, changePos, error, dummy));
299299
CValidationState state;
300-
BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, {}, reservekey, nullptr, state));
300+
BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, reservekey, nullptr, state));
301301
CMutableTransaction blocktx;
302302
{
303303
LOCK(wallet->cs_wallet);

0 commit comments

Comments
 (0)