From 612bc1a52f7ab9239767f52d0ac5bd5928979e35 Mon Sep 17 00:00:00 2001 From: Anthony Fieroni Date: Tue, 15 Feb 2022 08:04:26 +0000 Subject: [PATCH] Fix dex loan token burns (#1100) Signed-off-by: Anthony Fieroni --- src/masternodes/rpc_accounts.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/masternodes/rpc_accounts.cpp b/src/masternodes/rpc_accounts.cpp index 74992b52cf..a42d735780 100644 --- a/src/masternodes/rpc_accounts.cpp +++ b/src/masternodes/rpc_accounts.cpp @@ -1724,6 +1724,8 @@ UniValue getburninfo(const JSONRPCRequest& request) { CBalances dexfeeburn; UniValue dfipaybacktokens{UniValue::VARR}; + LOCK(cs_main); + auto calcBurn = [&](AccountHistoryKey const & key, CLazySerialize valueLazy) -> bool { const auto & value = valueLazy.get(); @@ -1766,7 +1768,11 @@ UniValue getburninfo(const JSONRPCRequest& request) { if (value.category == uint8_t(CustomTxType::PoolSwap) || value.category == uint8_t(CustomTxType::PoolSwapV2)) { for (auto const & diff : value.diff) { - dexfeeburn.Add({diff.first, diff.second}); + if (pcustomcsview->GetLoanTokenByID(diff.first)) { + dexfeeburn.Add({diff.first, diff.second}); + } else { + burntTokens.Add({diff.first, diff.second}); + } } return true; } @@ -1792,8 +1798,6 @@ UniValue getburninfo(const JSONRPCRequest& request) { result.pushKV("paybackburn", ValueFromAmount(paybackFee)); result.pushKV("dexfeetokens", AmountsToJSON(dexfeeburn.balances)); - LOCK(cs_main); - if (auto attributes = pcustomcsview->GetAttributes()) { CDataStructureV0 liveKey{AttributeTypes::Live, ParamIDs::Economy, EconomyKeys::PaybackDFITokens}; auto tokenBalances = attributes->GetValue(liveKey, CBalances{});