diff --git a/src/coincontrol.h b/src/coincontrol.h index 0af8e54806c9..4a72a4fa8aef 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -20,7 +20,7 @@ class CCoinControl int nSplitBlock; //! If false, allows unselected inputs, but requires all selected inputs be used bool fAllowOtherInputs; - //! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria + //! Includes watch only addresses which are solvable bool fAllowWatchOnly; //! Minimum absolute fee (not per kilobyte) CAmount nMinimumTotalFee; diff --git a/src/policy/policy.h b/src/policy/policy.h index 01d3bffbc413..ce355812c315 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -27,7 +27,7 @@ static const unsigned int MAX_P2SH_SIGOPS = 15; * with. However scripts violating these flags may still be present in valid * blocks and we must accept those blocks. */ -static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS | +static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY_FLAGS | SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_STRICTENC | SCRIPT_VERIFY_MINIMALDATA | @@ -36,7 +36,7 @@ static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY SCRIPT_VERIFY_LOW_S; /** For convenience, standard but not mandatory verify flags. */ -static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS; +static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS; // Sanity check the magic numbers when we change them BOOST_STATIC_ASSERT(DEFAULT_BLOCK_MAX_SIZE <= MAX_BLOCK_SIZE_CURRENT); diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp index 8c9405388249..194b9b6385de 100644 --- a/src/script/ismine.cpp +++ b/src/script/ismine.cpp @@ -39,8 +39,9 @@ isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey) std::vector vSolutions; txnouttype whichType; if(!Solver(scriptPubKey, whichType, vSolutions)) { - if(keystore.HaveWatchOnly(scriptPubKey)) - return ISMINE_WATCH_UNSOLVABLE; + if(keystore.HaveWatchOnly(scriptPubKey)) { + return ISMINE_WATCH_ONLY; + } return ISMINE_NO; } @@ -77,12 +78,15 @@ isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey) CKeyID ownerKeyID = CKeyID(uint160(vSolutions[1])); bool spendKeyIsMine = keystore.HaveKey(ownerKeyID); - if (spendKeyIsMine && stakeKeyIsMine) - return ISMINE_SPENDABLE_STAKEABLE; - else if (stakeKeyIsMine) - return ISMINE_COLD; - else if (spendKeyIsMine) + if (spendKeyIsMine) { + // If the wallet has both keys, ISMINE_SPENDABLE_DELEGATED + // takes precedence over ISMINE_COLD return ISMINE_SPENDABLE_DELEGATED; + } else if (stakeKeyIsMine) { + return ISMINE_COLD; + } else { + // todo: Include watch only.. + } break; } case TX_MULTISIG: { @@ -99,9 +103,7 @@ isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey) } if (keystore.HaveWatchOnly(scriptPubKey)) { - // TODO: This could be optimized some by doing some work after the above solver - SignatureData sigdata; - return ProduceSignature(DummySignatureCreator(&keystore), scriptPubKey, sigdata, false) ? ISMINE_WATCH_SOLVABLE : ISMINE_WATCH_UNSOLVABLE; + return ISMINE_WATCH_ONLY; } return ISMINE_NO; diff --git a/src/script/ismine.h b/src/script/ismine.h index 866d90496fcc..791fc01f0da1 100644 --- a/src/script/ismine.h +++ b/src/script/ismine.h @@ -9,6 +9,7 @@ #include "key.h" #include "script/standard.h" +#include class CKeyStore; class CScript; @@ -16,19 +17,15 @@ class CScript; /** IsMine() return codes */ enum isminetype { ISMINE_NO = 0, - //! Indicates that we dont know how to create a scriptSig that would solve this if we were given the appropriate private keys - ISMINE_WATCH_UNSOLVABLE = 1, - //! Indicates that we know how to create a scriptSig that would solve this if we were given the appropriate private keys - ISMINE_WATCH_SOLVABLE = 2, - ISMINE_WATCH_ONLY = ISMINE_WATCH_SOLVABLE | ISMINE_WATCH_UNSOLVABLE, - ISMINE_SPENDABLE = 4, + ISMINE_WATCH_ONLY = 1 << 0, + ISMINE_SPENDABLE = 1 << 1, //! Indicates that we have the staking key of a P2CS - ISMINE_COLD = 8, + ISMINE_COLD = 1 << 2, //! Indicates that we have the spending key of a P2CS - ISMINE_SPENDABLE_DELEGATED = 16, + ISMINE_SPENDABLE_DELEGATED = 1 << 3, ISMINE_SPENDABLE_ALL = ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE, - ISMINE_SPENDABLE_STAKEABLE = ISMINE_SPENDABLE_DELEGATED | ISMINE_COLD, - ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE | ISMINE_COLD | ISMINE_SPENDABLE_DELEGATED + ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE | ISMINE_COLD | ISMINE_SPENDABLE_DELEGATED, + ISMINE_ENUM_ELEMENTS }; /** used for bitflags of isminetype */ typedef uint8_t isminefilter; @@ -36,4 +33,23 @@ typedef uint8_t isminefilter; isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest); +/** + * Cachable amount subdivided into watchonly and spendable parts. + */ +struct CachableAmount +{ + // NO and ALL are never (supposed to be) cached + std::bitset m_cached; + CAmount m_value[ISMINE_ENUM_ELEMENTS]; + inline void Reset() + { + m_cached.reset(); + } + void Set(isminefilter filter, CAmount value) + { + m_cached.set(filter); + m_value[filter] = value; + } +}; + #endif // BITCOIN_SCRIPT_ISMINE_H diff --git a/src/script/sign.cpp b/src/script/sign.cpp index f6e19e8852ca..5991779fc8d5 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -380,3 +380,18 @@ bool DummySignatureCreator::CreateSig(std::vector& vchSig, const vchSig[6 + 33 + 32] = SIGHASH_ALL; return true; } + +bool IsSolvable(const CKeyStore& store, const CScript& script) +{ + // This check is to make sure that the script we created can actually be solved for and signed by us + // if we were to have the private keys. This is just to make sure that the script is valid and that, + // if found in a transaction, we would still accept and relay that transaction. In particular, + DummySignatureCreator creator(&store); + SignatureData sigs; + if (ProduceSignature(creator, script, sigs, false)) { + // VerifyScript check is just defensive, and should never fail. + assert(VerifyScript(sigs.scriptSig, script, STANDARD_SCRIPT_VERIFY_FLAGS, creator.Checker())); + return true; + } + return false; +} diff --git a/src/script/sign.h b/src/script/sign.h index 7e6a3651dd0a..f3881274ce0c 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -81,4 +81,10 @@ SignatureData CombineSignatures(const CScript& scriptPubKey, const BaseSignature SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nIn); void UpdateTransaction(CMutableTransaction& tx, unsigned int nIn, const SignatureData& data); +/* Check whether we know how to sign for an output like this, assuming we + * have all private keys. While this function does not need private keys, the passed + * keystore is used to look up public keys and redeemscripts by hash. + * Solvability is unrelated to whether we consider this output to be ours. */ +bool IsSolvable(const CKeyStore& store, const CScript& script); + #endif // BITCOIN_SCRIPT_SIGN_H diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 745b608ee927..912478035951 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -40,10 +40,8 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa tx.vin.resize(1); } CWalletTx* wtx = new CWalletTx(pwalletMain, tx); - if (fIsFromMe) - { - wtx->fDebitCached = true; - wtx->nDebitCached = 1; + if (fIsFromMe) { + wtx->m_amounts[CWalletTx::DEBIT].Set(ISMINE_SPENDABLE, 1); } COutput output(wtx, nInput, nAge, true, true); vCoins.push_back(output); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 29fa4b5515b2..4d083bc6fcb1 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1250,6 +1250,15 @@ int CWalletTx::GetRequestCount() const return nRequests; } +CAmount CWalletTx::GetCachableAmount(AmountType type, const isminefilter& filter, bool recalculate, bool fUnspent) const +{ + auto& amount = m_amounts[type]; + if (recalculate || !amount.m_cached[filter]) { + amount.Set(filter, type == DEBIT ? pwallet->GetDebit(*this, filter) : pwallet->GetCredit(*this, filter, fUnspent)); + } + return amount.m_value[filter]; +} + //! filter decides which addresses will count towards the debit CAmount CWalletTx::GetDebit(const isminefilter& filter) const { @@ -1258,52 +1267,28 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const CAmount debit = 0; if (filter & ISMINE_SPENDABLE) { - if (fDebitCached) - debit += nDebitCached; - else { - nDebitCached = pwallet->GetDebit(*this, ISMINE_SPENDABLE); - fDebitCached = true; - debit += nDebitCached; - } + debit += GetCachableAmount(DEBIT, ISMINE_SPENDABLE); } if (filter & ISMINE_WATCH_ONLY) { - if (fWatchDebitCached) - debit += nWatchDebitCached; - else { - nWatchDebitCached = pwallet->GetDebit(*this, ISMINE_WATCH_ONLY); - fWatchDebitCached = true; - debit += nWatchDebitCached; - } + debit += GetCachableAmount(DEBIT, ISMINE_WATCH_ONLY); } if (filter & ISMINE_COLD) { - if (fColdDebitCached) - debit += nColdDebitCached; - else { - nColdDebitCached = pwallet->GetDebit(*this, ISMINE_COLD); - fColdDebitCached = true; - debit += nColdDebitCached; - } + debit += GetCachableAmount(DEBIT, ISMINE_COLD); } if (filter & ISMINE_SPENDABLE_DELEGATED) { - if (fDelegatedDebitCached) - debit += nDelegatedDebitCached; - else { - nDelegatedDebitCached = pwallet->GetDebit(*this, ISMINE_SPENDABLE_DELEGATED); - fDelegatedDebitCached = true; - debit += nDelegatedDebitCached; - } + debit += GetCachableAmount(DEBIT, ISMINE_SPENDABLE_DELEGATED); } return debit; } CAmount CWalletTx::GetColdStakingDebit(bool fUseCache) const { - return UpdateAmount(nColdDebitCached, fColdDebitCached, fUseCache, ISMINE_COLD, false); + return GetCachableAmount(DEBIT, ISMINE_COLD, !fUseCache); } CAmount CWalletTx::GetStakeDelegationDebit(bool fUseCache) const { - return UpdateAmount(nDelegatedDebitCached, fDelegatedDebitCached, fUseCache, ISMINE_SPENDABLE_DELEGATED, false); + return GetCachableAmount(DEBIT, ISMINE_SPENDABLE_DELEGATED, !fUseCache); } CAmount CWalletTx::GetUnspentCredit(const isminefilter& filter) const @@ -1312,61 +1297,24 @@ CAmount CWalletTx::GetUnspentCredit(const isminefilter& filter) const if (GetBlocksToMaturity() > 0) return 0; - CAmount credit = 0; - if (filter & ISMINE_SPENDABLE) { - credit += pwallet->GetCredit(*this, ISMINE_SPENDABLE, true); - } - if (filter & ISMINE_WATCH_ONLY) { - credit += pwallet->GetCredit(*this, ISMINE_WATCH_ONLY, true); - } - if (filter & ISMINE_COLD) { - credit += pwallet->GetCredit(*this, ISMINE_COLD, true); - } - if (filter & ISMINE_SPENDABLE_DELEGATED) { - credit += pwallet->GetCredit(*this, ISMINE_SPENDABLE_DELEGATED, true); - } - return credit; + return GetCredit(filter, false, true); } -CAmount CWalletTx::GetCredit(const isminefilter& filter) const +CAmount CWalletTx::GetCredit(const isminefilter& filter, bool recalculate, bool fUnspent) const { CAmount credit = 0; if (filter & ISMINE_SPENDABLE) { // GetBalance can assume transactions in mapWallet won't change - if (fCreditCached) - credit += nCreditCached; - else { - nCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE, false); - fCreditCached = true; - credit += nCreditCached; - } + credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE, recalculate, fUnspent); } if (filter & ISMINE_WATCH_ONLY) { - if (fWatchCreditCached) - credit += nWatchCreditCached; - else { - nWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY, false); - fWatchCreditCached = true; - credit += nWatchCreditCached; - } + credit += GetCachableAmount(CREDIT, ISMINE_WATCH_ONLY, recalculate, fUnspent); } if (filter & ISMINE_COLD) { - if (fColdCreditCached) - credit += nColdCreditCached; - else { - nColdCreditCached = pwallet->GetCredit(*this, ISMINE_COLD, false); - fColdCreditCached = true; - credit += nColdCreditCached; - } + credit += GetCachableAmount(CREDIT, ISMINE_COLD, recalculate, fUnspent); } if (filter & ISMINE_SPENDABLE_DELEGATED) { - if (fDelegatedCreditCached) - credit += nDelegatedCreditCached; - else { - nDelegatedCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE_DELEGATED, false); - fDelegatedCreditCached = true; - credit += nDelegatedCreditCached; - } + credit += GetCachableAmount(CREDIT, ISMINE_SPENDABLE_DELEGATED, recalculate, fUnspent); } return credit; } @@ -1375,11 +1323,7 @@ CAmount CWalletTx::GetImmatureCredit(bool fUseCache, const isminefilter& filter) { LOCK(cs_main); if (IsInMainChainImmature()) { - if (fUseCache && fImmatureCreditCached && filter == ISMINE_SPENDABLE_ALL) - return nImmatureCreditCached; - nImmatureCreditCached = pwallet->GetCredit(*this, filter); - fImmatureCreditCached = true; - return nImmatureCreditCached; + return GetCachableAmount(IMMATURE_CREDIT, filter, !fUseCache); } return 0; @@ -1400,23 +1344,6 @@ CAmount CWalletTx::GetStakeDelegationCredit(bool fUseCache) const return GetUnspentCredit(ISMINE_SPENDABLE_DELEGATED); } -CAmount CWalletTx::UpdateAmount(CAmount& amountToUpdate, bool& cacheFlagToUpdate, bool fUseCache, isminetype mimeType, bool fCredit) const -{ - if (pwallet == 0) - return 0; - - // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) - return 0; - - if (fUseCache && cacheFlagToUpdate) - return amountToUpdate; - - amountToUpdate = (fCredit) ? GetCredit(mimeType) : GetDebit(mimeType); - cacheFlagToUpdate = true; - return amountToUpdate; -} - // Return sum of unlocked coins CAmount CWalletTx::GetUnlockedCredit() const { @@ -1482,11 +1409,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const { LOCK(cs_main); if (IsInMainChainImmature()) { - if (fUseCache && fImmatureWatchCreditCached) - return nImmatureWatchCreditCached; - nImmatureWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY); - fImmatureWatchCreditCached = true; - return nImmatureWatchCreditCached; + return GetCachableAmount(IMMATURE_CREDIT, ISMINE_WATCH_ONLY, !fUseCache); } return 0; @@ -1501,22 +1424,7 @@ CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; - if (fUseCache && fAvailableWatchCreditCached) - return nAvailableWatchCreditCached; - - CAmount nCredit = 0; - for (unsigned int i = 0; i < vout.size(); i++) { - if (!pwallet->IsSpent(GetHash(), i)) { - const CTxOut& txout = vout[i]; - nCredit += pwallet->GetCredit(txout, ISMINE_WATCH_ONLY); - if (!Params().GetConsensus().MoneyRange(nCredit)) - throw std::runtime_error("CWalletTx::GetAvailableCredit() : value out of range"); - } - } - - nAvailableWatchCreditCached = nCredit; - fAvailableWatchCreditCached = true; - return nCredit; + return GetCachableAmount(AVAILABLE_CREDIT, ISMINE_WATCH_ONLY, !fUseCache); } CAmount CWalletTx::GetLockedWatchOnlyCredit() const @@ -2013,10 +1921,9 @@ void CWallet::GetAvailableP2CSCoins(std::vector& vCoins) const { if (utxo.scriptPubKey.IsPayToColdStaking()) { isminetype mine = IsMine(utxo); bool isMineSpendable = mine & ISMINE_SPENDABLE_DELEGATED; - bool fIsSolvable = (mine & (ISMINE_SPENDABLE_ALL | ISMINE_WATCH_SOLVABLE)) != ISMINE_NO; if (mine & ISMINE_COLD || isMineSpendable) - // Depth is not used, no need waste resources and set it for now. - vCoins.emplace_back(COutput(pcoin, i, 0, isMineSpendable, fIsSolvable)); + // Depth and solvability members are not used, no need waste resources and set them for now. + vCoins.emplace_back(COutput(pcoin, i, 0, isMineSpendable, true)); } } } @@ -2177,10 +2084,8 @@ bool CWallet::AvailableCoins(std::vector* pCoins, // --> populates if (mine == ISMINE_COLD && (!fIncludeColdStaking || !HasDelegator(pcoin->vout[i]))) continue; // skip delegated coins if (mine == ISMINE_SPENDABLE_DELEGATED && !fIncludeDelegated) continue; - // skip auto-delegated coins - if (mine == ISMINE_SPENDABLE_STAKEABLE && !fIncludeColdStaking && !fIncludeDelegated) continue; - bool solvable = (mine & (ISMINE_SPENDABLE_ALL | ISMINE_WATCH_SOLVABLE)) != ISMINE_NO; + bool solvable = IsSolvable(*this, pcoin->vout[i].scriptPubKey); bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable)) || @@ -4235,32 +4140,7 @@ void CWalletTx::Init(const CWallet* pwalletIn) nTimeSmart = 0; fFromMe = false; strFromAccount.clear(); - fDebitCached = false; - fCreditCached = false; - fImmatureCreditCached = false; - fAvailableCreditCached = false; - fWatchDebitCached = false; - fWatchCreditCached = false; - fImmatureWatchCreditCached = false; - fAvailableWatchCreditCached = false; fChangeCached = false; - fColdDebitCached = false; - fColdCreditCached = false; - fDelegatedDebitCached = false; - fDelegatedCreditCached = false; - fStakeDelegationVoided = false; - nDebitCached = 0; - nCreditCached = 0; - nImmatureCreditCached = 0; - nAvailableCreditCached = 0; - nWatchDebitCached = 0; - nWatchCreditCached = 0; - nAvailableWatchCreditCached = 0; - nImmatureWatchCreditCached = 0; - nColdDebitCached = 0; - nColdCreditCached = 0; - nDelegatedDebitCached = 0; - nDelegatedCreditCached = 0; nChangeCached = 0; nOrderPos = -1; } @@ -4320,18 +4200,13 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const void CWalletTx::MarkDirty() { - fCreditCached = false; - fAvailableCreditCached = false; - fWatchDebitCached = false; - fWatchCreditCached = false; - fAvailableWatchCreditCached = false; - fImmatureWatchCreditCached = false; - fDebitCached = false; + m_amounts[DEBIT].Reset(); + m_amounts[CREDIT].Reset(); + m_amounts[IMMATURE_CREDIT].Reset(); + m_amounts[AVAILABLE_CREDIT].Reset(); + nChangeCached = 0; fChangeCached = false; - fColdDebitCached = false; - fColdCreditCached = false; - fDelegatedDebitCached = false; - fDelegatedCreditCached = false; + fStakeDelegationVoided = false; } void CWalletTx::BindWallet(CWallet* pwalletIn) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 2a8034048ede..561d6773d852 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -850,33 +850,12 @@ class CWalletTx : public CMerkleTx int64_t nOrderPos; //! position in ordered transaction list // memory only - mutable bool fDebitCached; - mutable bool fCreditCached; - mutable bool fImmatureCreditCached; - mutable bool fAvailableCreditCached; - mutable bool fWatchDebitCached; - mutable bool fWatchCreditCached; - mutable bool fImmatureWatchCreditCached; - mutable bool fAvailableWatchCreditCached; + enum AmountType { DEBIT, CREDIT, IMMATURE_CREDIT, AVAILABLE_CREDIT, AMOUNTTYPE_ENUM_ELEMENTS }; + CAmount GetCachableAmount(AmountType type, const isminefilter& filter, bool recalculate = false, bool fUnspent = false) const; + mutable CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]; mutable bool fChangeCached; - mutable bool fColdDebitCached; - mutable bool fColdCreditCached; - mutable bool fDelegatedDebitCached; - mutable bool fDelegatedCreditCached; mutable bool fStakeDelegationVoided; - mutable CAmount nDebitCached; - mutable CAmount nCreditCached; - mutable CAmount nImmatureCreditCached; - mutable CAmount nAvailableCreditCached; - mutable CAmount nWatchDebitCached; - mutable CAmount nWatchCreditCached; - mutable CAmount nImmatureWatchCreditCached; - mutable CAmount nAvailableWatchCreditCached; mutable CAmount nChangeCached; - mutable CAmount nColdDebitCached; - mutable CAmount nColdCreditCached; - mutable CAmount nDelegatedDebitCached; - mutable CAmount nDelegatedCreditCached; CWalletTx(); CWalletTx(const CWallet* pwalletIn); @@ -938,7 +917,7 @@ class CWalletTx : public CMerkleTx //! filter decides which addresses will count towards the debit CAmount GetDebit(const isminefilter& filter) const; - CAmount GetCredit(const isminefilter& filter) const; + CAmount GetCredit(const isminefilter& filter, bool recalculate = false, bool fUnspent = false) const; CAmount GetUnspentCredit(const isminefilter& filter) const; CAmount GetImmatureCredit(bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE_ALL) const; CAmount GetAvailableCredit(bool fUseCache = true) const; @@ -957,9 +936,6 @@ class CWalletTx : public CMerkleTx CAmount GetStakeDelegationCredit(bool fUseCache = true) const; CAmount GetStakeDelegationDebit(bool fUseCache = true) const; - // Helper method to update the amount and cacheFlag. - CAmount UpdateAmount(CAmount& amountToUpdate, bool& cacheFlagToUpdate, bool fUseCache, isminetype mimeType, bool fCredit = true) const; - void GetAmounts(std::list& listReceived, std::list& listSent, CAmount& nFee, diff --git a/test/functional/wallet_import_stakingaddress.py b/test/functional/wallet_import_stakingaddress.py index b0952ca9ccb6..c6cdd8dceea9 100755 --- a/test/functional/wallet_import_stakingaddress.py +++ b/test/functional/wallet_import_stakingaddress.py @@ -47,7 +47,7 @@ def run_test(self): delegations.append(self.nodes[0].delegatestake(sa, 10)['txid']) # mine a block and check staking balance self.nodes[0].generate(1) - assert_equal(self.nodes[0].getcoldstakingbalance(), DecimalAmt(10 * (i+1))) + assert_equal(self.nodes[0].getdelegatedbalance(), DecimalAmt(10 * (i+1))) sync_blocks(self.nodes) # Export keys