Skip to content

Commit

Permalink
fix merge
Browse files Browse the repository at this point in the history
  • Loading branch information
alex v committed Dec 4, 2019
2 parents ab2a211 + 7a27649 commit aa2c8ec
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 72 deletions.
72 changes: 0 additions & 72 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,77 +913,6 @@ UniValue getcfunddbstatehash(const UniValue& params, bool fHelp)
return view.GetCFundDBStateHash(chainActive.Tip()->nCFLocked, chainActive.Tip()->nCFSupply).ToString();
}

UniValue listproposals(const UniValue& params, bool fHelp)
{
if (fHelp)
throw runtime_error(
"listproposals \"filter\"\n"
"\nList the proposals and all the relating data including payment requests and status.\n"
"\nNote passing no argument returns all proposals regardless of state.\n"
"\nArguments:\n"
"\n1. \"filter\" (string, optional) \"accepted\" | \"rejected\" | \"expired\" | \"pending\"\n"
"\nExamples:\n"
+ HelpExampleCli("listproposal", "accepted")
+ HelpExampleRpc("listproposal", "")
);

LOCK(cs_main);

UniValue ret(UniValue::VARR);

bool showAll = true;
bool showAccepted = false;
bool showRejected = false;
bool showExpired = false;
bool showPending = false;
if(params.size() == 1) {
if(params[0].get_str() == "accepted") {
showAccepted = true;
showAll = false;
}
if(params[0].get_str() == "rejected") {
showRejected = true;
showAll = false;
}
if(params[0].get_str() == "expired") {
showAll = false;
showExpired = true;
}
if(params[0].get_str() == "pending") {
showAll = false;
showPending = true;
}
}

CProposalMap mapProposals;

if(pcoinsTip->GetAllProposals(mapProposals))
{
for (CProposalMap::iterator it = mapProposals.begin(); it != mapProposals.end(); it++)
{
CFund::CProposal proposal;
if (!pcoinsTip->GetProposal(it->first, proposal))
continue;

flags fLastState = proposal.GetLastState();

if((showAll && (!proposal.IsExpired(pindexBestHeader->GetBlockTime())
|| fLastState == CFund::PENDING_VOTING_PREQ
|| fLastState == CFund::PENDING_FUNDS))
|| (showPending && (fLastState == CFund::NIL || fLastState == CFund::PENDING_VOTING_PREQ
|| fLastState == CFund::PENDING_FUNDS))
|| (showAccepted && (fLastState == CFund::ACCEPTED || proposal.IsAccepted()))
|| (showRejected && (fLastState == CFund::REJECTED || proposal.IsRejected()))
|| (showExpired && proposal.IsExpired(pindexBestHeader->GetBlockTime()))) {
UniValue o(UniValue::VOBJ);
proposal.ToJson(o, *pcoinsTip);
ret.push_back(o);
}
}
}
return ret;
}

UniValue cfundstats(const UniValue& params, bool fHelp)
{

Expand Down Expand Up @@ -1665,7 +1594,6 @@ static const CRPCCommand commands[] =
{ "blockchain", "gettxout", &gettxout, true },
{ "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true },
{ "blockchain", "verifychain", &verifychain, true },
{ "communityfund", "listproposals", &listproposals, true },
{ "communityfund", "getcfunddbstatehash", &getcfunddbstatehash, true },

/* Not shown in help */
Expand Down
88 changes: 88 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3711,6 +3711,93 @@ UniValue paymentrequestvote(const UniValue& params, bool fHelp)

}

UniValue listproposals(const UniValue& params, bool fHelp)
{
if (fHelp)
throw runtime_error(
"listproposals \"filter\"\n"
"\nList the proposals and all the relating data including payment requests and status.\n"
"\nNote passing no argument returns all proposals regardless of state.\n"
"\nArguments:\n"
"\n1. \"filter\" (string, optional) \"accepted\" | \"rejected\" | \"expired\" | \"pending\" | \"mine\"\n"
"\nExamples:\n"
+ HelpExampleCli("listproposal", "mine accepted")
+ HelpExampleCli("listproposal", "accepted")
+ HelpExampleRpc("listproposal", "")
);

LOCK(cs_main);

UniValue ret(UniValue::VARR);

bool showAll = true;
bool showAccepted = false;
bool showRejected = false;
bool showExpired = false;
bool showPending = false;
bool showMine = false;
for(unsigned int i = 0; i < params.size(); i++) {
if(params[i].get_str() == "accepted") {
showAccepted = true;
showAll = false;
}
else if(params[i].get_str() == "rejected") {
showRejected = true;
showAll = false;
}
else if(params[i].get_str() == "expired") {
showAll = false;
showExpired = true;
}
else if(params[i].get_str() == "pending") {
showAll = false;
showPending = true;
}
else if(params[i].get_str() == "mine") {
showAll = false;
showMine = true;
}
}

CProposalMap mapProposals;

if(pcoinsTip->GetAllProposals(mapProposals))
{
for (CProposalMap::iterator it = mapProposals.begin(); it != mapProposals.end(); it++)
{
CFund::CProposal proposal;
if (!pcoinsTip->GetProposal(it->first, proposal))
continue;

flags fLastState = proposal.GetLastState();

bool fIsMine = false;

if (showMine)
{
CTxDestination address(CNavCoinAddress(proposal.Address).Get());
isminefilter mine = IsMine(*pwalletMain, address);
if(mine & ISMINE_SPENDABLE)
fIsMine = true;
}


if(showAll
|| (showMine && fIsMine)
|| (showPending && (fLastState == CFund::NIL || fLastState == CFund::PENDING_VOTING_PREQ
|| fLastState == CFund::PENDING_FUNDS))
|| (showAccepted && (fLastState == CFund::ACCEPTED))
|| (showRejected && (fLastState == CFund::REJECTED))
|| (showExpired && proposal.IsExpired(pindexBestHeader->GetBlockTime()))) {
UniValue o(UniValue::VOBJ);
proposal.ToJson(o, *pcoinsTip);
ret.push_back(o);
}
}
}
return ret;
}

extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp
extern UniValue dumpmasterprivkey(const UniValue& params, bool fHelp);
extern UniValue dumpmnemonic(const UniValue& params, bool fHelp);
Expand Down Expand Up @@ -3777,6 +3864,7 @@ static const CRPCCommand commands[] =
{ "communityfund", "proposalvotelist", &proposalvotelist, false },
{ "communityfund", "paymentrequestvote", &paymentrequestvote, false },
{ "communityfund", "paymentrequestvotelist", &paymentrequestvotelist, false },
{ "communityfund", "listproposals", &listproposals, true },
{ "wallet", "anonsend", &anonsend, false },
{ "wallet", "getanondestination", &getanondestination, false },
{ "wallet", "setaccount", &setaccount, true },
Expand Down

0 comments on commit aa2c8ec

Please sign in to comment.