diff --git a/doc/release-notes-14023.md b/doc/release-notes-14023.md
index b23c11268b..18ea6f26d0 100644
--- a/doc/release-notes-14023.md
+++ b/doc/release-notes-14023.md
@@ -1,5 +1,5 @@
-Accout API removed
-------------------
+Account API removed
+-------------------
The 'account' API was deprecated in v0.17 and has been fully removed in v0.18.
The 'label' API was introduced in v0.17 as a replacement for accounts.
diff --git a/src/coinjoin/coinjoin-util.cpp b/src/coinjoin/coinjoin-util.cpp
index 2e296e7aee..8eb7f710d7 100644
--- a/src/coinjoin/coinjoin-util.cpp
+++ b/src/coinjoin/coinjoin-util.cpp
@@ -306,7 +306,7 @@ bool CTransactionBuilder::Commit(std::string& strResult)
}
CValidationState state;
- if (!pwallet->CommitTransaction(tx, {}, {}, {}, dummyReserveKey, g_connman.get(), state)) {
+ if (!pwallet->CommitTransaction(tx, {}, {}, dummyReserveKey, g_connman.get(), state)) {
strResult = state.GetRejectReason();
return false;
}
diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp
index 52a2af75c3..745b9e6d7b 100644
--- a/src/interfaces/wallet.cpp
+++ b/src/interfaces/wallet.cpp
@@ -40,13 +40,12 @@ public:
bool commit(WalletValueMap value_map,
WalletOrderForm order_form,
- std::string from_account,
std::string& reject_reason) override
{
LOCK2(cs_main, mempool.cs);
LOCK(m_wallet.cs_wallet);
CValidationState state;
- if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), std::move(order_form), std::move(from_account), m_key, g_connman.get(), state)) {
+ if (!m_wallet.CommitTransaction(m_tx, std::move(value_map), std::move(order_form), m_key, g_connman.get(), state)) {
reject_reason = state.GetRejectReason();
return false;
}
diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h
index 110dcc6168..94a75df563 100644
--- a/src/interfaces/wallet.h
+++ b/src/interfaces/wallet.h
@@ -318,7 +318,6 @@ public:
//! Send pending transaction and commit to wallet.
virtual bool commit(WalletValueMap value_map,
WalletOrderForm order_form,
- std::string from_account,
std::string& reject_reason) = 0;
};
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 32e761324d..8cc954c64a 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -305,7 +305,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
auto& newTx = transaction.getWtx();
std::string rejectReason;
- if (!newTx->commit(std::move(mapValue), std::move(vOrderForm), {} /* fromAccount */, rejectReason))
+ if (!newTx->commit(std::move(mapValue), std::move(vOrderForm), rejectReason))
return SendCoinsReturn(TransactionCommitFailed, QString::fromStdString(rejectReason));
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp
index ff44d4ccae..97d218b5a6 100644
--- a/src/rpc/governance.cpp
+++ b/src/rpc/governance.cpp
@@ -227,7 +227,7 @@ static UniValue gobject_prepare(const JSONRPCRequest& request)
CReserveKey reservekey(pwallet);
// -- send the tx to the network
CValidationState state;
- if (!pwallet->CommitTransaction(tx, {}, {}, {}, reservekey, g_connman.get(), state)) {
+ if (!pwallet->CommitTransaction(tx, {}, {}, reservekey, g_connman.get(), state)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "CommitTransaction failed! Reason given: " + state.GetRejectReason());
}
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 824b770955..4a443b41a8 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -83,7 +83,7 @@ void WalletInit::AddWalletOptions() const
gArgs.AddArg("-walletdir=
", "Specify directory to hold wallets (default: /wallets if it exists, otherwise )", false, OptionsCategory::WALLET);
gArgs.AddArg("-walletnotify=", "Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)", false, OptionsCategory::WALLET);
gArgs.AddArg("-zapwallettxes=", "Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup"
- " (1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET);
+ " (1 = keep tx meta data e.g. payment request information, 2 = drop tx meta data)", false, OptionsCategory::WALLET);
gArgs.AddArg("-discardfee=", strprintf("The fee rate (in %s/kB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). "
"Note: An output is discarded if it is dust at this rate, but we will always discard up to the dust relay fee and a discard fee above that is limited by the fee estimate for the longest target",
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 4fd6130075..5b9bef3ef8 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -191,16 +191,6 @@ UniValue getnewaddress(const JSONRPCRequest& request)
return EncodeDestination(keyID);
}
-CTxDestination GetLabelDestination(CWallet* const pwallet, const std::string& label, bool bForceNew=false)
-{
- CTxDestination dest;
- if (!pwallet->GetLabelDestination(dest, label, bForceNew)) {
- throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
- }
-
- return dest;
-}
-
static UniValue getrawchangeaddress(const JSONRPCRequest& request)
{
std::shared_ptr const wallet = GetWalletForJSONRPCRequest(request);
@@ -282,20 +272,6 @@ static UniValue setlabel(const JSONRPCRequest& request)
pwallet->SetAddressBook(dest, label, "send");
}
- // Detect when there are no addresses using this label.
- // If so, delete the account record for it. Labels, unlike addresses, can be deleted,
- // and if we wouldn't do this, the record would stick around forever.
- bool found_address = false;
- for (const std::pair& item : pwallet->mapAddressBook) {
- if (item.second.name == label) {
- found_address = true;
- break;
- }
- }
- if (!found_address) {
- pwallet->DeleteLabel(old_label);
- }
-
return NullUniValue;
}
@@ -337,7 +313,7 @@ static CTransactionRef SendMoney(CWallet * const pwallet, const CTxDestination &
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}
CValidationState state;
- if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, "" /* account */, reservekey, g_connman.get(), state)) {
+ if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, reservekey, g_connman.get(), state)) {
strError = strprintf("Error: The transaction was rejected! Reason given: %s", FormatStateMessage(state));
throw JSONRPCError(RPC_WALLET_ERROR, strError);
}
@@ -967,7 +943,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet);
// Check funds
- if (totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, nullptr, fAddLocked)) {
+ if (totalAmount > pwallet->GetLegacyBalance(ISMINE_SPENDABLE, nMinDepth, fAddLocked)) {
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Wallet has insufficient funds");
}
@@ -981,7 +957,7 @@ static UniValue sendmany(const JSONRPCRequest& request)
if (!fCreated)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
CValidationState state;
- if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, "" /* account */, keyChange, g_connman.get(), state)) {
+ if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, keyChange, g_connman.get(), state)) {
strFailReason = strprintf("Transaction commit failed:: %s", FormatStateMessage(state));
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason);
}
@@ -1343,11 +1319,10 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
static void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter) EXCLUSIVE_LOCKS_REQUIRED(cs_main, pwallet->cs_wallet)
{
CAmount nFee;
- std::string dummy_account;
std::list listReceived;
std::list listSent;
- wtx.GetAmounts(listReceived, listSent, nFee, dummy_account, filter);
+ wtx.GetAmounts(listReceived, listSent, nFee, filter);
bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);
@@ -1513,10 +1488,8 @@ static UniValue listtransactions(const JSONRPCRequest& request)
// iterate backwards until we have nCount items to return:
for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
{
- CWalletTx *const pwtx = (*it).second.first;
- if (pwtx != nullptr) {
- ListTransactions(pwallet, *pwtx, 0, true, ret, filter);
- }
+ CWalletTx *const pwtx = (*it).second;
+ ListTransactions(pwallet, *pwtx, 0, true, ret, filter);
if ((int)ret.size() >= (nCount+nFrom)) break;
}
}
diff --git a/src/wallet/test/coinjoin_tests.cpp b/src/wallet/test/coinjoin_tests.cpp
index 97eee9c416..807adbbc44 100644
--- a/src/wallet/test/coinjoin_tests.cpp
+++ b/src/wallet/test/coinjoin_tests.cpp
@@ -89,7 +89,7 @@ public:
for (CAmount nAmount : vecAmounts) {
BOOST_CHECK(wallet->CreateTransaction({{GetScriptForDestination(tallyItem.txdest), nAmount, false}}, tx, reserveKey, nFeeRet, nChangePosRet, strError, coinControl));
CValidationState state;
- BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, {}, reserveKey, nullptr, state));
+ BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, reserveKey, nullptr, state));
AddTxToChain(tx->GetHash());
for (size_t n = 0; n < tx->vout.size(); ++n) {
if (nChangePosRet != -1 && n == nChangePosRet) {
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp
index 48058e95fb..14517fb098 100644
--- a/src/wallet/test/wallet_tests.cpp
+++ b/src/wallet/test/wallet_tests.cpp
@@ -310,7 +310,7 @@ public:
CCoinControl dummy;
BOOST_CHECK(wallet->CreateTransaction({recipient}, tx, reservekey, fee, changePos, error, dummy));
CValidationState state;
- BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, {}, reservekey, nullptr, state));
+ BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, reservekey, nullptr, state));
CMutableTransaction blocktx;
{
LOCK(wallet->cs_wallet);
@@ -512,7 +512,7 @@ public:
CCoinControl coinControl;
BOOST_CHECK(wallet->CreateTransaction(GetRecipients(vecEntries), tx, reserveKey, nFeeRet, nChangePosRet, strError, coinControl));
CValidationState state;
- BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, {}, reserveKey, nullptr, state));
+ BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, reserveKey, nullptr, state));
CMutableTransaction blocktx;
{
LOCK(wallet->cs_wallet);
@@ -853,7 +853,7 @@ BOOST_FIXTURE_TEST_CASE(select_coins_grouped_by_addresses, ListCoinsTestingSetup
BOOST_CHECK(wallet->CreateTransaction({CRecipient{GetScriptForRawPubKey({}), 1 * COIN, true /* subtract fee */}},
tx2, reservekey2, fee, changePos, error, dummy));
CValidationState state;
- BOOST_CHECK(wallet->CommitTransaction(tx1, {}, {}, {}, reservekey1, nullptr, state));
+ BOOST_CHECK(wallet->CommitTransaction(tx1, {}, {}, reservekey1, nullptr, state));
reservekey2.KeepKey();
BOOST_CHECK_EQUAL(wallet->GetAvailableBalance(), 0);
CreateAndProcessBlock({CMutableTransaction(*tx2)}, GetScriptForRawPubKey({}));
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 028a9d3fb4..88f1337312 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -776,7 +776,6 @@ void CWallet::SyncMetaData(std::pair ran
// nTimeReceived not copied on purpose
copyTo->nTimeSmart = copyFrom->nTimeSmart;
copyTo->fFromMe = copyFrom->fFromMe;
- copyTo->strFromAccount = copyFrom->strFromAccount;
// nOrderPos not copied on purpose
// cached members not copied on purpose
}
@@ -968,44 +967,30 @@ DBErrors CWallet::ReorderTransactions()
// Old wallets didn't have any defined order for transactions
// Probably a bad idea to change the output of this
- // First: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap.
- typedef std::pair TxPair;
- typedef std::multimap TxItems;
+ // First: get all CWalletTx into a sorted-by-time multimap.
+ typedef std::multimap TxItems;
TxItems txByTime;
for (auto& entry : mapWallet)
{
CWalletTx* wtx = &entry.second;
- txByTime.insert(std::make_pair(wtx->nTimeReceived, TxPair(wtx, nullptr)));
- }
- std::list acentries;
- batch.ListAccountCreditDebit("", acentries);
- for (CAccountingEntry& entry : acentries)
- {
- txByTime.insert(std::make_pair(entry.nTime, TxPair(nullptr, &entry)));
+ txByTime.insert(std::make_pair(wtx->nTimeReceived, wtx));
}
nOrderPosNext = 0;
std::vector nOrderPosOffsets;
for (TxItems::iterator it = txByTime.begin(); it != txByTime.end(); ++it)
{
- CWalletTx *const pwtx = (*it).second.first;
- CAccountingEntry *const pacentry = (*it).second.second;
- int64_t& nOrderPos = (pwtx != nullptr) ? pwtx->nOrderPos : pacentry->nOrderPos;
+ CWalletTx *const pwtx = (*it).second;
+ int64_t& nOrderPos = pwtx->nOrderPos;
if (nOrderPos == -1)
{
nOrderPos = nOrderPosNext++;
nOrderPosOffsets.push_back(nOrderPos);
- if (pwtx)
- {
- if (!batch.WriteTx(*pwtx))
- return DBErrors::LOAD_FAIL;
- }
- else
- if (!batch.WriteAccountingEntry(pacentry->nEntryNo, *pacentry))
- return DBErrors::LOAD_FAIL;
+ if (!batch.WriteTx(*pwtx))
+ return DBErrors::LOAD_FAIL;
}
else
{
@@ -1022,14 +1007,8 @@ DBErrors CWallet::ReorderTransactions()
continue;
// Since we're changing the order, write it back
- if (pwtx)
- {
- if (!batch.WriteTx(*pwtx))
- return DBErrors::LOAD_FAIL;
- }
- else
- if (!batch.WriteAccountingEntry(pacentry->nEntryNo, *pacentry))
- return DBErrors::LOAD_FAIL;
+ if (!batch.WriteTx(*pwtx))
+ return DBErrors::LOAD_FAIL;
}
}
batch.WriteOrderPosNext(nOrderPosNext);
@@ -1049,81 +1028,6 @@ int64_t CWallet::IncOrderPosNext(WalletBatch *batch)
return nRet;
}
-bool CWallet::AccountMove(std::string strFrom, std::string strTo, CAmount nAmount, std::string strComment)
-{
- WalletBatch batch(*database);
- if (!batch.TxnBegin())
- return false;
-
- int64_t nNow = GetAdjustedTime();
-
- // Debit
- CAccountingEntry debit;
- debit.nOrderPos = IncOrderPosNext(&batch);
- debit.strAccount = strFrom;
- debit.nCreditDebit = -nAmount;
- debit.nTime = nNow;
- debit.strOtherAccount = strTo;
- debit.strComment = strComment;
- AddAccountingEntry(debit, &batch);
-
- // Credit
- CAccountingEntry credit;
- credit.nOrderPos = IncOrderPosNext(&batch);
- credit.strAccount = strTo;
- credit.nCreditDebit = nAmount;
- credit.nTime = nNow;
- credit.strOtherAccount = strFrom;
- credit.strComment = strComment;
- AddAccountingEntry(credit, &batch);
-
- if (!batch.TxnCommit())
- return false;
-
- return true;
-}
-
-bool CWallet::GetLabelDestination(CTxDestination &dest, const std::string& label, bool bForceNew)
-{
- AssertLockHeld(cs_wallet);
-
- WalletBatch batch(*database);
-
- CAccount account;
- batch.ReadAccount(label, account);
-
- if (!bForceNew) {
- if (!account.vchPubKey.IsValid())
- bForceNew = true;
- else {
- // Check if the current key has been used
- CScript scriptPubKey = GetScriptForDestination(account.vchPubKey.GetID());
- for (std::map::iterator it = mapWallet.begin();
- it != mapWallet.end() && account.vchPubKey.IsValid();
- ++it)
- for (const CTxOut& txout : (*it).second.tx->vout)
- if (txout.scriptPubKey == scriptPubKey) {
- bForceNew = true;
- break;
- }
- }
- }
-
- // Generate a new key
- if (bForceNew) {
- if (!GetKeyFromPool(account.vchPubKey, false))
- return false;
-
- dest = account.vchPubKey.GetID();
- SetAddressBook(dest, label, "receive");
- batch.WriteAccount(label, account);
- } else {
- dest = account.vchPubKey.GetID();
- }
-
- return true;
-}
-
void CWallet::MarkDirty()
{
{
@@ -1153,7 +1057,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose)
if (fInsertedNew) {
wtx.nTimeReceived = GetAdjustedTime();
wtx.nOrderPos = IncOrderPosNext(&batch);
- wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr)));
+ wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
wtx.nTimeSmart = ComputeTimeSmart(wtx);
AddToSpends(hash);
@@ -1243,7 +1147,7 @@ void CWallet::LoadToWallet(const CWalletTx& wtxIn)
CWalletTx& wtx = ins.first->second;
wtx.BindWallet(this);
if (/* insertion took place */ ins.second) {
- wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, nullptr)));
+ wtx.m_it_wtxOrdered = wtxOrdered.insert(std::make_pair(wtx.nOrderPos, &wtx));
}
AddToSpends(hash);
for (const CTxIn& txin : wtx.tx->vin) {
@@ -2134,12 +2038,11 @@ int CalculateMaximumSignedInputSize(const CTxOut& txout, const CWallet* wallet,
}
void CWalletTx::GetAmounts(std::list& listReceived,
- std::list& listSent, CAmount& nFee, std::string& strSentAccount, const isminefilter& filter) const
+ std::list& listSent, CAmount& nFee, const isminefilter& filter) const
{
nFee = 0;
listReceived.clear();
listSent.clear();
- strSentAccount = strFromAccount;
// Compute fee:
CAmount nDebit = GetDebit(filter);
@@ -2920,7 +2823,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const
// wallet, and then subtracts the values of TxIns spending from the wallet. This
// also has fewer restrictions on which unconfirmed transactions are considered
// trusted.
-CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, const std::string* account, const bool fAddLocked) const
+CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, const bool fAddLocked) const
{
LOCK2(cs_main, cs_wallet);
@@ -2939,21 +2842,17 @@ CAmount CWallet::GetLegacyBalance(const isminefilter& filter, int minDepth, cons
for (const CTxOut& out : wtx.tx->vout) {
if (outgoing && IsChange(out)) {
debit -= out.nValue;
- } else if (IsMine(out) & filter && (depth >= minDepth || (fAddLocked && wtx.IsLockedByInstantSend())) && (!account || *account == GetLabelName(out.scriptPubKey))) {
+ } else if (IsMine(out) & filter && (depth >= minDepth || (fAddLocked && wtx.IsLockedByInstantSend()))) {
balance += out.nValue;
}
}
// For outgoing txs, subtract amount debited.
- if (outgoing && (!account || *account == wtx.strFromAccount)) {
+ if (outgoing) {
balance -= debit;
}
}
- if (account) {
- balance += WalletBatch(*database).GetAccountCreditDebit(*account);
- }
-
return balance;
}
@@ -4016,7 +3915,7 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CTransac
/**
* Call after CreateTransaction unless you want to abort
*/
-bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector> orderForm, std::string fromAccount, CReserveKey& reservekey, CConnman* connman, CValidationState& state)
+bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector> orderForm, CReserveKey& reservekey, CConnman* connman, CValidationState& state)
{
{
LOCK2(cs_main, mempool.cs);
@@ -4025,7 +3924,6 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
CWalletTx wtxNew(this, std::move(tx));
wtxNew.mapValue = std::move(mapValue);
wtxNew.vOrderForm = std::move(orderForm);
- wtxNew.strFromAccount = std::move(fromAccount);
wtxNew.fTimeReceivedIsTxTime = true;
wtxNew.fFromMe = true;
@@ -4070,31 +3968,6 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
return true;
}
-void CWallet::ListAccountCreditDebit(const std::string& strAccount, std::list& entries) {
- WalletBatch batch(*database);
- return batch.ListAccountCreditDebit(strAccount, entries);
-}
-
-bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry)
-{
- WalletBatch batch(*database);
-
- return AddAccountingEntry(acentry, &batch);
-}
-
-bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, WalletBatch *batch)
-{
- if (!batch->WriteAccountingEntry(++nAccountingEntryNumber, acentry)) {
- return false;
- }
-
- laccentries.push_back(acentry);
- CAccountingEntry & entry = laccentries.back();
- wtxOrdered.insert(std::make_pair(entry.nOrderPos, TxPair(nullptr, &entry)));
-
- return true;
-}
-
DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
{
LOCK2(cs_main, cs_wallet);
@@ -4675,12 +4548,6 @@ std::set CWallet::GetLabelAddresses(const std::string& label) co
return result;
}
-void CWallet::DeleteLabel(const std::string& label)
-{
- WalletBatch batch(*database);
- batch.EraseAccount(label);
-}
-
bool CReserveKey::GetReservedKey(CPubKey& pubkey, bool fInternalIn)
{
if (nIndex == -1)
@@ -4897,19 +4764,14 @@ unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx) const
int64_t latestTolerated = latestNow + 300;
const TxItems& txOrdered = wtxOrdered;
for (auto it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) {
- CWalletTx* const pwtx = it->second.first;
+ CWalletTx* const pwtx = it->second;
if (pwtx == &wtx) {
continue;
}
- CAccountingEntry* const pacentry = it->second.second;
int64_t nSmartTime;
- if (pwtx) {
- nSmartTime = pwtx->nTimeSmart;
- if (!nSmartTime) {
- nSmartTime = pwtx->nTimeReceived;
- }
- } else {
- nSmartTime = pacentry->nTime;
+ nSmartTime = pwtx->nTimeSmart;
+ if (!nSmartTime) {
+ nSmartTime = pwtx->nTimeReceived;
}
if (nSmartTime <= latestTolerated) {
latestEntry = nSmartTime;
@@ -5339,7 +5201,6 @@ std::shared_ptr CWallet::CreateWalletFromFile(const WalletLocation& loc
copyTo->nTimeReceived = copyFrom->nTimeReceived;
copyTo->nTimeSmart = copyFrom->nTimeSmart;
copyTo->fFromMe = copyFrom->fFromMe;
- copyTo->strFromAccount = copyFrom->strFromAccount;
copyTo->nOrderPos = copyFrom->nOrderPos;
batch.WriteTx(*copyTo);
}
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index f8bec0185c..a6f3a14754 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -347,9 +347,8 @@ public:
* externally and came in through the network or sendrawtransaction RPC.
*/
char fFromMe;
- std::string strFromAccount;
int64_t nOrderPos; //!< position in ordered transaction list
- std::multimap>::const_iterator m_it_wtxOrdered;
+ std::multimap::const_iterator m_it_wtxOrdered;
// memory only
mutable bool fDebitCached;
@@ -392,7 +391,6 @@ public:
nTimeReceived = 0;
nTimeSmart = 0;
fFromMe = false;
- strFromAccount.clear();
fDebitCached = false;
fCreditCached = false;
fImmatureCreditCached = false;
@@ -427,7 +425,7 @@ public:
char fSpent = false;
mapValue_t mapValueCopy = mapValue;
- mapValueCopy["fromaccount"] = strFromAccount;
+ mapValueCopy["fromaccount"] = "";
WriteOrderPos(nOrderPos, mapValueCopy);
if (nTimeSmart) {
mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart);
@@ -448,7 +446,6 @@ public:
std::vector vUnused; //!< Used to be vtxPrev
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent;
- strFromAccount = std::move(mapValue["fromaccount"]);
ReadOrderPos(nOrderPos, mapValue);
nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0;
@@ -508,7 +505,7 @@ public:
}
void GetAmounts(std::list& listReceived,
- std::list& listSent, CAmount& nFee, std::string& strSentAccount, const isminefilter& filter) const;
+ std::list& listSent, CAmount& nFee, const isminefilter& filter) const;
bool IsFromMe(const isminefilter& filter) const
{
@@ -623,89 +620,6 @@ public:
}
};
-/**
- * DEPRECATED Internal transfers.
- * Database key is acentry.
- */
-class CAccountingEntry
-{
-public:
- std::string strAccount;
- CAmount nCreditDebit;
- int64_t nTime;
- std::string strOtherAccount;
- std::string strComment;
- mapValue_t mapValue;
- int64_t nOrderPos; //!< position in ordered transaction list
- uint64_t nEntryNo;
-
- CAccountingEntry()
- {
- SetNull();
- }
-
- void SetNull()
- {
- nCreditDebit = 0;
- nTime = 0;
- strAccount.clear();
- strOtherAccount.clear();
- strComment.clear();
- nOrderPos = -1;
- nEntryNo = 0;
- }
-
- template
- void Serialize(Stream& s) const {
- int nVersion = s.GetVersion();
- if (!(s.GetType() & SER_GETHASH)) {
- s << nVersion;
- }
- //! Note: strAccount is serialized as part of the key, not here.
- s << nCreditDebit << nTime << strOtherAccount;
-
- mapValue_t mapValueCopy = mapValue;
- WriteOrderPos(nOrderPos, mapValueCopy);
-
- std::string strCommentCopy = strComment;
- if (!mapValueCopy.empty() || !_ssExtra.empty()) {
- CDataStream ss(s.GetType(), s.GetVersion());
- ss.insert(ss.begin(), '\0');
- ss << mapValueCopy;
- ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end());
- strCommentCopy.append(ss.str());
- }
- s << strCommentCopy;
- }
-
- template
- void Unserialize(Stream& s) {
- int nVersion = s.GetVersion();
- if (!(s.GetType() & SER_GETHASH)) {
- s >> nVersion;
- }
- //! Note: strAccount is serialized as part of the key, not here.
- s >> nCreditDebit >> nTime >> LIMITED_STRING(strOtherAccount, 65536) >> LIMITED_STRING(strComment, 65536);
-
- size_t nSepPos = strComment.find("\0", 0, 1);
- mapValue.clear();
- if (std::string::npos != nSepPos) {
- CDataStream ss(std::vector(strComment.begin() + nSepPos + 1, strComment.end()), s.GetType(), s.GetVersion());
- ss >> mapValue;
- _ssExtra = std::vector(ss.begin(), ss.end());
- }
- ReadOrderPos(nOrderPos, mapValue);
- if (std::string::npos != nSepPos) {
- strComment.erase(nSepPos);
- }
-
- mapValue.erase("n");
- }
-
-private:
- std::vector _ssExtra;
-};
-
struct CoinSelectionParams
{
bool use_bnb = true;
@@ -905,10 +819,8 @@ public:
}
std::map mapWallet GUARDED_BY(cs_wallet);
- std::list laccentries;
- typedef std::pair TxPair;
- typedef std::multimap TxItems;
+ typedef std::multimap TxItems;
TxItems wtxOrdered;
int64_t nOrderPosNext GUARDED_BY(cs_wallet) = 0;
@@ -1055,8 +967,6 @@ public:
*/
int64_t IncOrderPosNext(WalletBatch *batch = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
DBErrors ReorderTransactions();
- bool AccountMove(std::string strFrom, std::string strTo, CAmount nAmount, std::string strComment = "") EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
- bool GetLabelDestination(CTxDestination &dest, const std::string& label, bool bForceNew = false);
void MarkDirty();
bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);
@@ -1082,7 +992,7 @@ public:
CAmount GetImmatureBalance() const;
CAmount GetUnconfirmedWatchOnlyBalance() const;
CAmount GetImmatureWatchOnlyBalance() const;
- CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const std::string* account, const bool fAddLocked) const;
+ CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const bool fAddLocked) const;
CAmount GetAnonymizableBalance(bool fSkipDenominated = false, bool fSkipUnconfirmed = true) const;
CAmount GetAnonymizedBalance(const CCoinControl* coinControl = nullptr) const;
@@ -1107,11 +1017,8 @@ public:
*/
bool CreateTransaction(const std::vector& vecSend, CTransactionRef& tx, CReserveKey& reservekey, CAmount& nFeeRet, int& nChangePosInOut,
std::string& strFailReason, const CCoinControl& coin_control, bool sign = true, int nExtraPayloadSize = 0);
- bool CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector> orderForm, std::string fromAccount, CReserveKey& reservekey, CConnman* connman, CValidationState& state);
+ bool CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector> orderForm, CReserveKey& reservekey, CConnman* connman, CValidationState& state);
- void ListAccountCreditDebit(const std::string& strAccount, std::list& entries);
- bool AddAccountingEntry(const CAccountingEntry&);
- bool AddAccountingEntry(const CAccountingEntry&, WalletBatch *batch);
bool DummySignTx(CMutableTransaction &txNew, const std::set &txouts, bool use_max_sig = false) const
{
std::vector v_txouts(txouts.size());
@@ -1168,7 +1075,6 @@ public:
std::map GetAddressBalances() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
std::set GetLabelAddresses(const std::string& label) const;
- void DeleteLabel(const std::string& label);
isminetype IsMine(const CTxIn& txin) const;
/**
@@ -1383,36 +1289,6 @@ public:
void KeepScript() override { KeepKey(); }
};
-
-/**
- * DEPRECATED Account information.
- * Stored in wallet with key "acc"+string account name.
- */
-class CAccount
-{
-public:
- CPubKey vchPubKey;
-
- CAccount()
- {
- SetNull();
- }
-
- void SetNull()
- {
- vchPubKey = CPubKey();
- }
-
- SERIALIZE_METHODS(CAccount, obj)
- {
- int nVersion = s.GetVersion();
- if (!(s.GetType() & SER_GETHASH))
- READWRITE(nVersion);
- READWRITE(obj.vchPubKey);
- }
-};
-
-
/** RAII object to check and reserve a wallet rescan */
class WalletRescanReserver
{
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index 8b7ff2ae27..563dc917ab 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -20,6 +20,7 @@
#include
#include
+#include
//
// WalletBatch
@@ -156,27 +157,6 @@ bool WalletBatch::WriteMinVersion(int nVersion)
return WriteIC(std::string("minversion"), nVersion);
}
-bool WalletBatch::ReadAccount(const std::string& strAccount, CAccount& account)
-{
- account.SetNull();
- return m_batch.Read(std::make_pair(std::string("acc"), strAccount), account);
-}
-
-bool WalletBatch::WriteAccount(const std::string& strAccount, const CAccount& account)
-{
- return WriteIC(std::make_pair(std::string("acc"), strAccount), account);
-}
-
-bool WalletBatch::EraseAccount(const std::string& strAccount)
-{
- return EraseIC(std::make_pair(std::string("acc"), strAccount));
-}
-
-bool WalletBatch::WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry)
-{
- return WriteIC(std::make_pair(std::string("acentry"), std::make_pair(acentry.strAccount, nAccEntryNum)), acentry);
-}
-
bool WalletBatch::ReadCoinJoinSalt(uint256& salt, bool fLegacy)
{
// TODO: Remove legacy checks after few major releases
@@ -193,60 +173,6 @@ bool WalletBatch::WriteGovernanceObject(const CGovernanceObject& obj)
return WriteIC(std::make_pair(std::string("gobject"), obj.GetHash()), obj, false);
}
-CAmount WalletBatch::GetAccountCreditDebit(const std::string& strAccount)
-{
- std::list entries;
- ListAccountCreditDebit(strAccount, entries);
-
- CAmount nCreditDebit = 0;
- for (const CAccountingEntry& entry : entries)
- nCreditDebit += entry.nCreditDebit;
-
- return nCreditDebit;
-}
-
-void WalletBatch::ListAccountCreditDebit(const std::string& strAccount, std::list& entries)
-{
- bool fAllAccounts = (strAccount == "*");
-
- Dbc* pcursor = m_batch.GetCursor();
- if (!pcursor)
- throw std::runtime_error(std::string(__func__) + ": cannot create DB cursor");
- bool setRange = true;
- while (true)
- {
- // Read next record
- CDataStream ssKey(SER_DISK, CLIENT_VERSION);
- if (setRange)
- ssKey << std::make_pair(std::string("acentry"), std::make_pair((fAllAccounts ? std::string("") : strAccount), uint64_t(0)));
- CDataStream ssValue(SER_DISK, CLIENT_VERSION);
- int ret = m_batch.ReadAtCursor(pcursor, ssKey, ssValue, setRange);
- setRange = false;
- if (ret == DB_NOTFOUND)
- break;
- else if (ret != 0)
- {
- pcursor->close();
- throw std::runtime_error(std::string(__func__) + ": error scanning DB");
- }
-
- // Unserialize
- std::string strType;
- ssKey >> strType;
- if (strType != "acentry")
- break;
- CAccountingEntry acentry;
- ssKey >> acentry.strAccount;
- if (!fAllAccounts && acentry.strAccount != strAccount)
- break;
-
- ssValue >> acentry;
- ssKey >> acentry.nEntryNo;
- entries.push_back(acentry);
- }
-
- pcursor->close();
-}
class CWalletScanState {
public:
@@ -303,9 +229,10 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
{
char fTmp;
char fUnused;
- ssValue >> fTmp >> fUnused >> wtx.strFromAccount;
- strErr = strprintf("LoadWallet() upgrading tx ver=%d %d '%s' %s",
- wtx.fTimeReceivedIsTxTime, fTmp, wtx.strFromAccount, hash.ToString());
+ std::string unused_string;
+ ssValue >> fTmp >> fUnused >> unused_string;
+ strErr = strprintf("LoadWallet() upgrading tx ver=%d %d %s",
+ wtx.fTimeReceivedIsTxTime, fTmp, hash.ToString());
wtx.fTimeReceivedIsTxTime = fTmp;
}
else
@@ -321,24 +248,6 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
pwallet->LoadToWallet(wtx);
}
- else if (strType == "acentry")
- {
- std::string strAccount;
- ssKey >> strAccount;
- uint64_t nNumber;
- ssKey >> nNumber;
- if (nNumber > pwallet->nAccountingEntryNumber) {
- pwallet->nAccountingEntryNumber = nNumber;
- }
-
- if (!wss.fAnyUnordered)
- {
- CAccountingEntry acentry;
- ssValue >> acentry;
- if (acentry.nOrderPos == -1)
- wss.fAnyUnordered = true;
- }
- }
else if (strType == "watchs")
{
wss.nWatchKeys++;
@@ -578,7 +487,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
}
}
else if (strType != "bestblock" && strType != "bestblock_nomerkle" &&
- strType != "minversion"){
+ strType != "minversion" && strType != "acentry"){
wss.m_unknown_records++;
}
} catch (const std::exception& e) {
@@ -702,12 +611,6 @@ DBErrors WalletBatch::LoadWallet(CWallet* pwallet)
if (wss.fAnyUnordered)
result = pwallet->ReorderTransactions();
- pwallet->laccentries.clear();
- ListAccountCreditDebit("*", pwallet->laccentries);
- for (CAccountingEntry& entry : pwallet->laccentries) {
- pwallet->wtxOrdered.insert(make_pair(entry.nOrderPos, CWallet::TxPair(nullptr, &entry)));
- }
-
return result;
}
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index 3ff20fdd53..ee9d1b4786 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -31,8 +31,6 @@
static const bool DEFAULT_FLUSHWALLET = true;
-class CAccount;
-class CAccountingEntry;
struct CBlockLocator;
class CGovernanceObject;
class CKeyPool;
@@ -154,13 +152,6 @@ public:
bool WriteMinVersion(int nVersion);
- /// This writes directly to the database, and will not update the CWallet's cached accounting entries!
- /// Use wallet.AddAccountingEntry instead, to write *and* update its caches.
- bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
- bool ReadAccount(const std::string& strAccount, CAccount& account);
- bool WriteAccount(const std::string& strAccount, const CAccount& account);
- bool EraseAccount(const std::string& strAccount);
-
bool ReadCoinJoinSalt(uint256& salt, bool fLegacy = false);
bool WriteCoinJoinSalt(const uint256& salt);
@@ -172,9 +163,6 @@ public:
/// Erase destination data tuple from wallet database
bool EraseDestData(const std::string &address, const std::string &key);
- CAmount GetAccountCreditDebit(const std::string& strAccount);
- void ListAccountCreditDebit(const std::string& strAccount, std::list& acentries);
-
DBErrors LoadWallet(CWallet* pwallet);
DBErrors FindWalletTx(std::vector& vTxHash, std::vector& vWtx);
DBErrors ZapWalletTx(std::vector& vWtx);