Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getmasternodeblocks depth filtering #946

Merged
merged 61 commits into from
Dec 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ddb821c
Adds possibility to use "*" to auto-select address in placeauctionbid…
Jouzo Nov 26, 2021
0535a08
Reduce complexity by throwing first if isNull
Jouzo Nov 26, 2021
b5bbba2
Remove dangling brace
Jouzo Nov 26, 2021
dd7cad4
Fix test assertion
Jouzo Nov 27, 2021
98ac64f
Remove print in tests
Jouzo Nov 29, 2021
01a345a
Adjusting interest calc
Mixa84 Dec 1, 2021
0114894
Add test and minor fix
Mixa84 Dec 1, 2021
4e09210
Fix lint
Mixa84 Dec 1, 2021
0ac1119
Merge branch 'master' into feature/loan_autoselectaccount
prasannavl Dec 2, 2021
2815ba5
Merge branch 'master' into feature/museum_later_upgrades
Mixa84 Dec 2, 2021
6879367
Fix getmasternodeblocks depth filtering
dcorral Dec 3, 2021
fc021e1
Check depth on lambda return
dcorral Dec 3, 2021
a3c3a8e
Correct startBlock implementation for depth in getmasternodeblocks
dcorral Dec 6, 2021
fee339b
Merge branch 'master' into feature/loan_autoselectaccount
prasannavl Dec 7, 2021
334ee3b
Merge branch 'master' into fix/getmasternodeblocks-depth
dcorral Dec 7, 2021
23a66e8
Merge branch 'master' into fix/getmasternodeblocks-depth
dcorral Dec 7, 2021
1456c5e
Add FC Museum
Bushstar Dec 7, 2021
12b9007
Revert "Use height based on hashPrevBlock (#932)"
Bushstar Dec 7, 2021
155779e
Reject block with incorrect height set
Bushstar Dec 7, 2021
1f3b99e
Prefer tx entry time order for a block (#950)
bvbfan Dec 7, 2021
f7b4993
Fix build suffix for all branches and introduce hotfix (#919)
prasannavl Dec 7, 2021
e96fb6d
Revert "Use height based on hashPrevBlock (#932)" (#955)
Bushstar Dec 7, 2021
443528a
Ensure overbid is higher than previous one
bvbfan Dec 7, 2021
6d88b1d
Increase max tip age
Bushstar Dec 7, 2021
f11977c
Increase max tip age
Bushstar Dec 7, 2021
1892763
Merge branch 'pr/942' into hotfix
prasannavl Dec 7, 2021
78aec34
Merge branch 'fix/small_loan' into hotfix
prasannavl Dec 7, 2021
10e67a4
Merge branch 'pr/960' into hotfix
prasannavl Dec 7, 2021
3b258f5
Merge branch 'pr/961' into hotfix
prasannavl Dec 7, 2021
45e1065
Set Fork Canning Museum height and tip age
prasannavl Dec 7, 2021
694dbd8
Fix amount to burn
bvbfan Dec 7, 2021
4cf00fa
Merge branch 'master' into hotfix
prasannavl Dec 7, 2021
da81afa
Add FC height on testnet
prasannavl Dec 7, 2021
770f8e4
Revert max tip age
prasannavl Dec 7, 2021
a0d8358
Set height in block being created
Bushstar Dec 7, 2021
c1cb8e2
Merge branch 'hotfix' of https://github.com/DeFiCh/ain into hotfix
Bushstar Dec 7, 2021
b1216af
Change max tip again
prasannavl Dec 7, 2021
f972b8c
Merge pull request #960 from DeFiCh/hotfix
prasannavl Dec 7, 2021
7d02950
Version 2.3.0
prasannavl Dec 7, 2021
c5ac94e
Merge pull request #963 from DeFiCh/chore/update_ver
prasannavl Dec 7, 2021
5ee1fb5
Restore owner calc behaviour
Bushstar Dec 8, 2021
5c52eb2
Restore int behaviour pre-FCM
Bushstar Dec 9, 2021
7fd037a
Remove FCH references
prasannavl Dec 9, 2021
a8aa26e
Fix formatting
prasannavl Dec 9, 2021
804b7a5
Merge pull request #969 from DeFiCh/restore-int-behaviour
prasannavl Dec 9, 2021
b123e21
Merge branch 'master' into restore-reward-calc
prasannavl Dec 9, 2021
dcbeeab
Merge pull request #966 from DeFiCh/restore-reward-calc
prasannavl Dec 9, 2021
c846338
Version 2.3.1
prasannavl Dec 9, 2021
036ec43
Fix totalVaults and totalAuctions in getloaninfo
Jouzo Dec 14, 2021
cce2ce6
Use nHeight as height field may be incorrect
Bushstar Dec 15, 2021
6ec84f9
Factor out usage of height field in block header
Bushstar Dec 15, 2021
0a33783
Factor out usage of height field in CBlockIndex
Bushstar Dec 15, 2021
8dfa88a
Merge pull request #986 from DeFiCh/fix/getloaninfo_openauctions
prasannavl Dec 20, 2021
543d4b9
Fix boost 1.77 compilation (#997)
bvbfan Dec 22, 2021
27154e7
Merge branch 'master' into fix-incorrect-height
prasannavl Dec 22, 2021
8c68ce0
Merge pull request #987 from DeFiCh/fix-incorrect-height
prasannavl Dec 22, 2021
c83ad4d
Merge branch 'master' into feature/loan_autoselectaccount
prasannavl Dec 24, 2021
218a87c
Merge pull request #937 from DeFiCh/feature/loan_autoselectaccount
prasannavl Dec 24, 2021
2286182
Add start BTC height and record limit to spv_listanchors (#921)
Bushstar Dec 24, 2021
4801205
Rework mempool accounts view (#904)
bvbfan Dec 24, 2021
211b393
Merge branch 'fix/getmasternodeblocks-depth'
prasannavl Dec 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 2)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
Expand Down
2 changes: 1 addition & 1 deletion src/bench/checkblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void DeserializeAndCheckBlockTest(benchmark::State& state)
CValidationState validationState;
CheckContextState ctxState;

bool checked = CheckBlock(block, validationState, chainParams->GetConsensus(), ctxState, false);
bool checked = CheckBlock(block, validationState, chainParams->GetConsensus(), ctxState, false, 413567);
assert(checked);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bench/duplicate_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void DuplicateInputs(benchmark::State& state)
while (state.KeepRunning()) {
CValidationState cvstate{};
CheckContextState ctxState;
assert(!CheckBlock(block, cvstate, chainparams.GetConsensus(), ctxState, false, false));
assert(!CheckBlock(block, cvstate, chainparams.GetConsensus(), ctxState, false, nHeight, false));
assert(cvstate.GetRejectReason() == "bad-txns-inputs-duplicate");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/blockencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
return txn_available[index] != nullptr;
}

ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing, const int height) {
assert(!header.IsNull());
uint256 hash = header.GetHash();
block = header;
Expand All @@ -200,7 +200,7 @@ ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<
CValidationState state;
CheckContextState ctxState;

if (!CheckBlock(block, state, Params().GetConsensus(), ctxState, false)) {
if (!CheckBlock(block, state, Params().GetConsensus(), ctxState, false, height)) {
// TODO: We really want to just check merkle tree manually here,
// but that is expensive, and CheckBlock caches a block's
// "checked-status" (in the CBlock?). CBlock should be able to
Expand Down
2 changes: 1 addition & 1 deletion src/blockencodings.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class PartiallyDownloadedBlock {
// extra_txn is a list of extra transactions to look at, in <witness hash, reference> form
ReadStatus InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<std::pair<uint256, CTransactionRef>>& extra_txn);
bool IsTxAvailable(size_t index) const;
ReadStatus FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing);
ReadStatus FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing, const int height);
};

#endif // DEFI_BLOCKENCODINGS_H
14 changes: 7 additions & 7 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class CBlockIndex
uint32_t nBits;

// proof-of-stake specific fields
uint64_t height;
uint64_t deprecatedHeight;
uint64_t mintedBlocks;
uint256 stakeModifier; // hash modifier for proof-of-stake
std::vector<unsigned char> sig;
Expand Down Expand Up @@ -222,7 +222,7 @@ class CBlockIndex
nTime = 0;
nBits = 0;
stakeModifier = uint256{};
height = 0;
deprecatedHeight = 0;
mintedBlocks = 0;
sig = {};
minterKeyID = {};
Expand All @@ -241,7 +241,7 @@ class CBlockIndex
hashMerkleRoot = block.hashMerkleRoot;
nTime = block.nTime;
nBits = block.nBits;
height = block.height;
deprecatedHeight = block.deprecatedHeight;
mintedBlocks = block.mintedBlocks;
stakeModifier = block.stakeModifier;
sig = block.sig;
Expand Down Expand Up @@ -276,7 +276,7 @@ class CBlockIndex
block.nTime = nTime;
block.nBits = nBits;
block.stakeModifier = stakeModifier;
block.height = height;
block.deprecatedHeight = deprecatedHeight;
block.mintedBlocks = mintedBlocks;
block.sig = sig;
return block;
Expand Down Expand Up @@ -330,7 +330,7 @@ class CBlockIndex
std::sort(pbegin, pend);

// Only after FC and when we have a full set of times.
if (height >= Params().GetConsensus().FortCanningHeight && pend - pbegin == nMedianTimeSpan) {
if (nHeight >= Params().GetConsensus().FortCanningHeight && pend - pbegin == nMedianTimeSpan) {
// Take the median of the top five.
return pbegin[8];
}
Expand Down Expand Up @@ -424,7 +424,7 @@ class CDiskBlockIndex : public CBlockIndex
READWRITE(nTime);
READWRITE(nBits);
READWRITE(stakeModifier);
READWRITE(height);
READWRITE(deprecatedHeight);
READWRITE(mintedBlocks);
READWRITE(sig);
}
Expand All @@ -438,7 +438,7 @@ class CDiskBlockIndex : public CBlockIndex
block.nTime = nTime;
block.nBits = nBits;
block.stakeModifier = stakeModifier;
block.height = height;
block.deprecatedHeight = deprecatedHeight;
block.mintedBlocks = mintedBlocks;
block.sig = sig;

Expand Down
7 changes: 6 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, uint32_t nTime, uint3
genesis.nTime = nTime;
genesis.nBits = nBits;
genesis.nVersion = nVersion;
genesis.height = 0;
genesis.deprecatedHeight = 0;
genesis.stakeModifier = uint256S("0");
genesis.mintedBlocks = 0;
genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
Expand Down Expand Up @@ -127,6 +127,7 @@ class CMainParams : public CChainParams {
consensus.EunosKampungHeight = 895743;
consensus.EunosPayaHeight = 1072000; // Aug 05, 2021.
consensus.FortCanningHeight = 1367000; // Nov 15, 2021.
consensus.FortCanningMuseumHeight = 1430640;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
Expand Down Expand Up @@ -346,6 +347,7 @@ class CTestNetParams : public CChainParams {
consensus.EunosKampungHeight = consensus.EunosHeight;
consensus.EunosPayaHeight = 463300;
consensus.FortCanningHeight = 686200;
consensus.FortCanningMuseumHeight = 724000;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
// consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
Expand Down Expand Up @@ -527,6 +529,7 @@ class CDevNetParams : public CChainParams {
consensus.EunosKampungHeight = consensus.EunosHeight;
consensus.EunosPayaHeight = 300;
consensus.FortCanningHeight = std::numeric_limits<int>::max();
consensus.FortCanningMuseumHeight = std::numeric_limits<int>::max();

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.pos.nTargetTimespan = 5 * 60; // 5 min == 10 blocks
Expand Down Expand Up @@ -700,6 +703,7 @@ class CRegTestParams : public CChainParams {
consensus.EunosKampungHeight = 10000000;
consensus.EunosPayaHeight = 10000000;
consensus.FortCanningHeight = 10000000;
consensus.FortCanningMuseumHeight = 10000000;

consensus.pos.diffLimit = uint256S("00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.pos.nTargetTimespan = 14 * 24 * 60 * 60; // two weeks
Expand Down Expand Up @@ -912,6 +916,7 @@ void CRegTestParams::UpdateActivationParametersFromArgs(const ArgsManager& args)
}
UpdateHeightValidation("Eunos Paya", "-eunospayaheight", consensus.EunosPayaHeight);
UpdateHeightValidation("Fork canning", "-fortcanningheight", consensus.FortCanningHeight);
UpdateHeightValidation("Fork canning museum", "-fortcanningmuseumheight", consensus.FortCanningMuseumHeight);

if (!args.IsArgSet("-vbparams")) return;

Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ struct Params {
int EunosKampungHeight;
int EunosPayaHeight;
int FortCanningHeight;
int FortCanningMuseumHeight;

/** Foundation share after AMK, normalized to COIN = 100% */
CAmount foundationShareDFIP1;
Expand Down
1 change: 1 addition & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ void SetupServerArgs()
gArgs.AddArg("-eunosheight", "Eunos fork activation height (regtest only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-eunospayaheight", "EunosPaya fork activation height (regtest only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-fortcanningheight", "Fort Canning fork activation height (regtest only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-fortcanningmuseumheight", "Fort Canning Museum fork activation height (regtest only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS);
gArgs.AddArg("-jellyfish_regtest", "Configure the regtest network for jellyfish testing", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
#ifdef USE_UPNP
#if USE_UPNP
Expand Down
22 changes: 19 additions & 3 deletions src/masternodes/loan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,18 @@ boost::optional<CInterestRate> CLoanView::GetInterestRate(const CVaultId& vaultI
return ReadBy<LoanInterestByVault, CInterestRate>(std::make_pair(vaultId, id));
}

CAmount InterestPerBlock(CAmount amount, CAmount tokenInterest, CAmount schemeInterest)
inline CAmount InterestPerBlock(CAmount amount, CAmount tokenInterest, CAmount schemeInterest)
{
auto netInterest = (tokenInterest + schemeInterest) / 100; // in %
return MultiplyAmounts(netInterest, amount) / (365 * Params().GetConsensus().blocksPerDay());
}

inline float InterestPerBlockFloat(CAmount amount, CAmount tokenInterest, CAmount schemeInterest)
{
auto netInterest = (tokenInterest + schemeInterest) / 100; // in %
return MultiplyAmounts(netInterest, amount) / (365.f * Params().GetConsensus().blocksPerDay());
}

CAmount TotalInterest(const CInterestRate& rate, uint32_t height)
{
CAmount interest = rate.interestToHeight + ((height - rate.height) * rate.interestPerBlock);
Expand Down Expand Up @@ -235,8 +241,13 @@ Res CLoanView::StoreInterest(uint32_t height, const CVaultId& vaultId, const std
LogPrint(BCLog::LOAN,"%s():\n", __func__);
rate.interestToHeight = TotalInterest(rate, height);
}

if (int(height) >= Params().GetConsensus().FortCanningMuseumHeight) {
rate.interestPerBlock += std::ceil(InterestPerBlockFloat(loanIncreased, token->interest, scheme->rate));
} else {
rate.interestPerBlock += InterestPerBlock(loanIncreased, token->interest, scheme->rate);
}
rate.height = height;
rate.interestPerBlock += InterestPerBlock(loanIncreased, token->interest, scheme->rate);

WriteBy<LoanInterestByVault>(std::make_pair(vaultId, id), rate);
return Res::Ok();
Expand Down Expand Up @@ -264,8 +275,13 @@ Res CLoanView::EraseInterest(uint32_t height, const CVaultId& vaultId, const std
}
LogPrint(BCLog::LOAN,"%s():\n", __func__);
rate.interestToHeight = std::max(CAmount{0}, TotalInterest(rate, height) - interestDecreased);

rate.height = height;
rate.interestPerBlock = std::max(CAmount{0}, rate.interestPerBlock - InterestPerBlock(loanDecreased, token->interest, scheme->rate));
if (int(height) >= Params().GetConsensus().FortCanningMuseumHeight) {
rate.interestPerBlock = std::max(CAmount{0}, rate.interestPerBlock - CAmount(std::ceil(InterestPerBlockFloat(loanDecreased, token->interest, scheme->rate))));
} else {
rate.interestPerBlock = std::max(CAmount{0}, rate.interestPerBlock - InterestPerBlock(loanDecreased, token->interest, scheme->rate));
}

WriteBy<LoanInterestByVault>(std::make_pair(vaultId, id), rate);
return Res::Ok();
Expand Down
1 change: 0 additions & 1 deletion src/masternodes/loan.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ struct CInterestRate
}
};

CAmount InterestPerBlock(const CInterestRate& rate);
CAmount TotalInterest(const CInterestRate& rate, uint32_t height);

class CLoanTakeLoanMessage
Expand Down
4 changes: 2 additions & 2 deletions src/masternodes/masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ void CCustomCSView::CalcAnchoringTeams(const uint256 & stakeModifier, const CBlo
std::map<arith_uint256, CKeyID, std::less<arith_uint256>> authMN;
std::map<arith_uint256, CKeyID, std::less<arith_uint256>> confirmMN;
ForEachMasternode([&] (uint256 const & id, CMasternode node) {
if(!node.IsActive(pindexNew->height))
if(!node.IsActive(pindexNew->nHeight))
return true;

// Not in our list of MNs from last week, skip.
Expand Down Expand Up @@ -820,7 +820,7 @@ void CCustomCSView::CalcAnchoringTeams(const uint256 & stakeModifier, const CBlo

{
LOCK(cs_main);
SetAnchorTeams(authTeam, confirmTeam, pindexNew->height);
SetAnchorTeams(authTeam, confirmTeam, pindexNew->nHeight);
}

// Debug logging
Expand Down
25 changes: 22 additions & 3 deletions src/masternodes/mn_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class CCustomMetadataParseVisitor : public boost::static_visitor<Res>
Res operator()(CUpdateMasterNodeMessage& obj) const {
// Temporarily disabled for 2.2
return Res::Err("updatemasternode is disabled for Fort Canning");

auto res = isPostFortCanningFork();
return !res ? res : serialize(obj);
}
Expand Down Expand Up @@ -955,7 +955,7 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
Res operator()(const CUpdateMasterNodeMessage& obj) const {
// Temporarily disabled for 2.2
return Res::Err("updatemasternode is disabled for Fort Canning");

auto res = HasCollateralAuth(obj.mnId);
return !res ? res : mnview.UpdateMasternode(obj.mnId, obj.operatorType, obj.operatorAuthAddress, height);
}
Expand Down Expand Up @@ -2682,6 +2682,16 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
if (!res)
return res;

if (static_cast<int>(height) >= consensus.FortCanningMuseumHeight && subLoan < it->second)
{
auto newRate = mnview.GetInterestRate(obj.vaultId, tokenId);
if (!newRate)
return Res::Err("Cannot get interest rate for this token (%s)!", loanToken->symbol);

if (newRate->interestPerBlock == 0)
return Res::Err("Cannot payback this amount of loan for %s, either payback full amount or less than this amount!", loanToken->symbol);
}

res = mnview.SubMintedTokens(loanToken->creationTx, subLoan);
if (!res)
return res;
Expand Down Expand Up @@ -2739,10 +2749,19 @@ class CCustomTxApplyVisitor : public CCustomTxVisitor
auto amount = MultiplyAmounts(batch->loanAmount.nValue, COIN + data->liquidationPenalty);
if (amount > obj.amount.nValue)
return Res::Err("First bid should include liquidation penalty of %d%%", data->liquidationPenalty * 100 / COIN);

if (static_cast<int>(height) >= consensus.FortCanningMuseumHeight
&& data->liquidationPenalty && obj.amount.nValue == batch->loanAmount.nValue)
return Res::Err("First bid should be higher than batch one");
} else {
auto amount = MultiplyAmounts(bid->second.nValue, COIN + (COIN / 100));
if (amount > obj.amount.nValue)
return Res::Err("Bid override should be at least 1%% higher than current one");

if (static_cast<int>(height) >= consensus.FortCanningMuseumHeight
&& obj.amount.nValue == bid->second.nValue)
return Res::Err("Bid override should be higher than last one");

// immediate refund previous bid
CalculateOwnerRewards(bid->first);
mnview.AddBalance(bid->first, bid->second);
Expand Down Expand Up @@ -3567,7 +3586,7 @@ Res SwapToDFIOverUSD(CCustomCSView & mnview, DCT_ID tokenId, CAmount amount, CS
if (!token)
return Res::Err("Cannot find token with id %s!", tokenId.ToString());

// TODO: Optimize double look up later when first token is DUSD.
// TODO: Optimize double look up later when first token is DUSD.
auto dUsdToken = mnview.GetToken("DUSD");
if (!dUsdToken)
return Res::Err("Cannot find token DUSD");
Expand Down
10 changes: 5 additions & 5 deletions src/masternodes/rpc_accounts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ UniValue outputEntryToJSON(COutputEntry const & entry, CBlockIndex const * index
UniValue obj(UniValue::VOBJ);

obj.pushKV("owner", EncodeDestination(entry.destination));
obj.pushKV("blockHeight", index->height);
obj.pushKV("blockHeight", index->nHeight);
obj.pushKV("blockHash", index->GetBlockHash().GetHex());
obj.pushKV("blockTime", index->GetBlockTime());
if (pwtx->IsCoinBase()) {
Expand Down Expand Up @@ -155,7 +155,7 @@ static void searchInWallet(CWallet const * pwallet,
auto* pwtx = &(*it);

auto index = LookupBlockIndex(pwtx->hashBlock);
if (!index || index->height == 0) { // skip genesis block
if (!index || index->nHeight == 0) { // skip genesis block
continue;
}

Expand Down Expand Up @@ -1180,10 +1180,10 @@ UniValue listaccounthistory(const JSONRPCRequest& request) {
count = limit;
searchInWallet(pwallet, account, filter,
[&](CBlockIndex const * index, CWalletTx const * pwtx) {
return txs.count(pwtx->GetHash()) || startBlock > index->height || index->height > maxBlockHeight;
return txs.count(pwtx->GetHash()) || startBlock > index->nHeight || index->nHeight > maxBlockHeight;
},
[&](COutputEntry const & entry, CBlockIndex const * index, CWalletTx const * pwtx) {
auto& array = ret.emplace(index->height, UniValue::VARR).first->second;
auto& array = ret.emplace(index->nHeight, UniValue::VARR).first->second;
array.push_back(outputEntryToJSON(entry, index, pwtx));
return --count != 0;
}
Expand Down Expand Up @@ -1509,7 +1509,7 @@ UniValue accounthistorycount(const JSONRPCRequest& request) {
if (shouldSearchInWallet) {
searchInWallet(pwallet, owner, filter,
[&](CBlockIndex const * index, CWalletTx const * pwtx) {
return txs.count(pwtx->GetHash()) || index->height > currentHeight;
return txs.count(pwtx->GetHash()) || index->nHeight > currentHeight;
},
[&count](COutputEntry const &, CBlockIndex const *, CWalletTx const *) {
++count;
Expand Down
Loading