diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index aeed827b75..9647d8e81a 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1268,7 +1268,8 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) if (!Address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Gridcoin Address"); - std::unordered_multimap> uMultisig; + // Store as: TXID, VOUT, nValue, nHeight + std::vector, std::pair>> Multisig; { LOCK(cs_main); @@ -1323,8 +1324,8 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) if (!txindex.vSpent[dummy.n].IsNull()) continue; - // Add to multimap - uMultisig.insert(std::make_pair(txout.nValue, std::make_pair(tx.GetHash(), j))); + // Add to vector + Multisig.push_back(std::make_pair(std::make_pair(tx.GetHash(), j), std::make_pair(txout.nValue, pblkindex->nHeight))); } } } @@ -1338,7 +1339,7 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) res.pushKV("Block Start", nBlockStart); res.pushKV("Block End", nBlockEnd); // Check the end results - if (uMultisig.empty()) + if (Multisig.empty()) res.pushKV("Result", "No utxos found in specified range"); else @@ -1352,7 +1353,7 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) exportoutput << "\n\n"; else if (nType == 1) - exportoutput << "TXID / VOUT / Value\n"; + exportoutput << "TXID / VOUT / Value / HEIGHT\n"; } @@ -1360,17 +1361,18 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) int64_t nValue = 0; // Process the map - for (const auto& data : uMultisig) + for (const auto& data : Multisig) { nCount++; - nValue += data.first; + nValue += data.second.first; UniValue txdata(UniValue::VOBJ); - txdata.pushKV("txid", data.second.first.ToString()); - txdata.pushKV("vout", (int)data.second.second); - txdata.pushKV("value", ValueFromAmount(data.first)); + txdata.pushKV("txid", data.first.first.ToString()); + txdata.pushKV("vout", (int)data.first.second); + txdata.pushKV("value", ValueFromAmount(data.second.first)); + txdata.pushKV("height", data.second.second); txres.push_back(txdata); // Parse into type file here @@ -1380,14 +1382,15 @@ UniValue scanforunspent(const UniValue& params, bool fHelp) if (nType == 0) { exportoutput << spacing << "\n"; - exportoutput << spacing << spacing << "" << data.second.first.ToString() << "\n"; - exportoutput << spacing << spacing << "" << data.second.second << "\n"; - exportoutput << spacing << spacing << "" << std::fixed << setprecision(8) << data.first / (double)COIN << "\n"; + exportoutput << spacing << spacing << "" << data.first.first.ToString() << "\n"; + exportoutput << spacing << spacing << "" << data.first.second << "\n"; + exportoutput << spacing << spacing << "" << std::fixed << setprecision(8) << data.second.first / (double)COIN << "\n"; + exportoutput << spacing << spacing << "" << data.second.second << "\n"; exportoutput << spacing << "\n"; } else if (nType == 1) - exportoutput << data.second.first.ToString() << " / " << data.second.second << " / " << std::fixed << setprecision(8) << data.first / (double)COIN << "\n"; + exportoutput << data.first.first.ToString() << " / " << data.first.second << " / " << std::fixed << setprecision(8) << data.second.first / (double)COIN << " / " << data.second.second << "\n"; } }