Skip to content

Commit

Permalink
RPC checkyourallmintvalidity
Browse files Browse the repository at this point in the history
  • Loading branch information
levoncrypto committed Aug 3, 2023
1 parent ddb04d8 commit 9417c54
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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"} },
Expand Down

0 comments on commit 9417c54

Please sign in to comment.