update some wallet stuff

This commit is contained in:
Michel van Kessel
2020-12-24 08:44:52 +01:00
parent 9daba5457c
commit 7b781b351d
4 changed files with 29 additions and 25 deletions

View File

@@ -65,11 +65,12 @@ CFeeRate CWallet::minTxFee = CFeeRate(DEFAULT_TRANSACTION_MINFEE);
*/
CFeeRate CWallet::fallbackFee = CFeeRate(DEFAULT_FALLBACK_FEE);
const uint256 CMerkleTx::ABANDON_HASH(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
CAmount nReserveBalance = 0;
CAmount nMinimumInputValue = 0;
const uint256 CMerkleTx::ABANDON_HASH(uint256S("0000000000000000000000000000000000000000000000000000000000000001"));
/** @defgroup mapWallet
*
* @{
@@ -326,7 +327,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
{
// Found a kernel
LogPrint("coinstake", "CreateCoinStake : kernel found\n");
vector<vector<unsigned char> > vSolutions;
vector<std::vector<unsigned char>> vSolutions;
txnouttype whichType;
CScript scriptPubKeyOut;
scriptPubKeyKernel = pcoin.first->vout[pcoin.second].scriptPubKey;
@@ -1855,7 +1856,8 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter, bool fCheckMaturity) co
if (fCheckMaturity && (IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0)
return 0;
int64_t credit = 0;
CAmount credit = 0;
if (filter & ISMINE_SPENDABLE)
{
// GetBalance can assume transactions in mapWallet won't change
@@ -2564,7 +2566,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// enough, that fee sniping isn't a problem yet, but by implementing a fix
// now we ensure code won't be written that makes assumptions about
// nLockTime that preclude a fix later.
txNew.nLockTime = chainActive.Height();
txNew.nLockTime = chainActive.Height();
txNew.nTime = GetAdjustedTime();
// Secondly occasionally randomly pick a nLockTime even further back, so
@@ -2677,11 +2679,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
CPubKey vchPubKey;
bool ret;
ret = reservekey.GetReservedKey(vchPubKey);
if (!ret)
{
strFailReason = _("Keypool ran out, please call keypoolrefill first");
return false;
}
assert(ret); // should never fail, as we just unlocked
scriptChange = GetScriptForDestination(vchPubKey.GetID());
}
@@ -2801,6 +2799,9 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
}
CAmount nFeeNeeded = GetMinimumFee(nBytes, nTxConfirmTarget, mempool);
nFeeNeeded = nFeeNeeded > 10000 ? nFeeNeeded : 10000;
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
nFeeNeeded = coinControl->nMinimumTotalFee;
}
@@ -2929,8 +2930,6 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
// But always obey the maximum
if (nFeeNeeded > maxTxFee)
nFeeNeeded = maxTxFee;
if(nFeeNeeded < DEFAULT_TRANSACTION_FEE)
nFeeNeeded = DEFAULT_TRANSACTION_FEE;
return nFeeNeeded;
}
@@ -3039,7 +3038,8 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
{
LOCK(cs_wallet); // mapAddressBook
if(fFileBacked) {
if(fFileBacked)
{
// Delete destdata tuples associated with address
for(const std::pair<std::string, std::string> &item : mapAddressBook[address].destdata) {
CWalletDB(strWalletFile).EraseDestData(address, item.first);

View File

@@ -17,7 +17,7 @@
#include <wallet/walletdb.h>
#include <wallet/rpcwallet.h>
#include <primitives/transaction.h>
#include "pos.h"
#include <pos.h>
#include <algorithm>
#include <atomic>

View File

@@ -375,14 +375,16 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
{
string strAddress;
ssKey >> strAddress;
ssValue >>
pwallet->mapAddressBook[DecodeDestination(strAddress)].name;
} else if (strType == "purpose") {
ssValue >> pwallet->mapAddressBook[DecodeDestination(strAddress)].name;
}
else if (strType == "purpose")
{
std::string strAddress;
ssKey >> strAddress;
ssValue >>
pwallet->mapAddressBook[DecodeDestination(strAddress)].purpose;
} else if (strType == "tx") {
ssValue >> pwallet->mapAddressBook[DecodeDestination(strAddress)].purpose;
}
else if (strType == "tx")
{
uint256 hash;
ssKey >> hash;
CWalletTx wtx;
@@ -868,7 +870,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
void ThreadFlushWalletDB(const string& strFile)
{
// Make this thread recognisable as the wallet flushing thread
RenameThread("bitcoin-wallet");
RenameThread("blackcoin-wallet");
static bool fOneThread;
if (fOneThread)

View File

@@ -9,10 +9,10 @@
#define BITCOIN_WALLET_WALLETDB_H
#include <amount.h>
#include <key.h>
#include <primitives/transaction.h>
#include <script/standard.h> // for CTxDestination
#include <wallet/db.h>
#include <key.h>
#include <list>
#include <stdint.h>
@@ -158,15 +158,15 @@ public:
/// 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 WriteAccountingEntry_Backend(const CAccountingEntry &acentry);
bool ReadAccount(const std::string &strAccount, CAccount &account);
bool WriteAccount(const std::string &strAccount, const CAccount &account);
bool WriteAccountingEntry_Backend(const CAccountingEntry& acentry);
bool ReadAccount(const std::string& strAccount, CAccount& account);
bool WriteAccount(const std::string& strAccount, const CAccount& account);
/// Write destination data key,value tuple to database
bool WriteDestData(const CTxDestination &address, const std::string &key, const std::string &value);
/// Erase destination data tuple from wallet database
bool EraseDestData(const CTxDestination &address, const std::string &key);
CAmount GetAccountCreditDebit(const std::string& strAccount);
void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& acentries);
@@ -184,6 +184,8 @@ public:
private:
CWalletDB(const CWalletDB&);
void operator=(const CWalletDB&);
bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
};
void ThreadFlushWalletDB(const std::string& strFile);