From 9417c54cfcc1abff8b308e6adf02bc4e5552b288 Mon Sep 17 00:00:00 2001 From: "levoncrypto1994@gmail.com" Date: Thu, 3 Aug 2023 11:59:24 +0400 Subject: [PATCH] RPC checkyourallmintvalidity --- src/wallet/rpcwallet.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 99ebb5c8f7..58f29b17b7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -164,6 +164,38 @@ std::string AccountFromValue(const UniValue& value) return strAccount; } +UniValue checkyourallmintvalidity(const JSONRPCRequest& request) +{ + CWallet * const pwallet = GetWalletForJSONRPCRequest(request); + if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { + assert(false || "Invalid wallet"); + } + + if (request.fHelp) { + throw std::runtime_error( + "checkyourallmintvalidity\n" + "checkyourallmintvalidity returns invalid(valid in your wallet but invalid from the outside) mints vector\n" + "\nResult\n" + "\"vector of invalid mints\"" + "\n\nExamples:\n" + + HelpExampleCli("checkyourallmintvalidity", "") + + HelpExampleRpc("checkyourallmintvalidity", "") + ); + } + + const auto listMints = pwallet->zwallet->GetTracker().ListLelantusMints(true, false, false); + Scalar s; + + UniValue usedMints(UniValue::VARR); + + for (auto it = listMints.begin(); it != listMints.end(); ++it) { + if (lelantus::CLelantusState::GetState()->IsUsedCoinSerialHash(s, it->hashSerial)) { + usedMints.push_back(it->GetPubCoinValueHash().GetHex()); + } + } + return usedMints; +} + UniValue getnewaddress(const JSONRPCRequest& request) { CWallet * const pwallet = GetWalletForJSONRPCRequest(request); @@ -5506,6 +5538,7 @@ static const CRPCCommand commands[] = { "wallet", "addwitnessaddress", &addwitnessaddress, true, {"address"} }, { "wallet", "backupwallet", &backupwallet, true, {"destination"} }, { "wallet", "bumpfee", &bumpfee, true, {"txid", "options"} }, + { "wallet", "checkyourallmintvalidity", &checkyourallmintvalidity, true, {} }, { "wallet", "dumpprivkey", &dumpprivkey_firo, true, {"address"} }, { "wallet", "dumpwallet", &dumpwallet_firo, true, {"filename"} }, { "wallet", "encryptwallet", &encryptwallet, true, {"passphrase"} },