Skip to content

Commit

Permalink
Merge pull request #644 from dantudor/patch-2
Browse files Browse the repository at this point in the history
Adds proposalHash to the RPC getpaymentrequest
  • Loading branch information
proletesseract committed Dec 7, 2019
2 parents d501c89 + 6094b20 commit 5d59483
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/consensus/cfund.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,18 +547,21 @@ void CFund::CProposal::ToJson(UniValue& ret, CCoinsViewCache& coins) const {
if (prequest.proposalhash != hash)
continue;

prequest.ToJson(preq);
prequest.ToJson(preq, false);
arr.push_back(preq);
}

ret.pushKV("paymentRequests", arr);
}
}

void CFund::CPaymentRequest::ToJson(UniValue& ret) const {
void CFund::CPaymentRequest::ToJson(UniValue& ret, bool root) const {
ret.pushKV("version", nVersion);
ret.pushKV("hash", hash.ToString());
ret.pushKV("blockHash", txblockhash.ToString());
if (root) {
ret.pushKV("proposalHash", proposalhash.ToString());
}
ret.pushKV("description", strDZeel);
ret.pushKV("requestedAmount", FormatMoney(nAmount));
ret.pushKV("votesYes", nVotesYes);
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/cfund.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class CPaymentRequest
paymenthash.ToString().substr(0,10), strDZeel);
}

void ToJson(UniValue& ret) const;
void ToJson(UniValue& ret, bool root) const;

bool IsAccepted() const;

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@ UniValue getpaymentrequest(const UniValue& params, bool fHelp)

UniValue ret(UniValue::VOBJ);

prequest.ToJson(ret);
prequest.ToJson(ret, true);

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3625,7 +3625,7 @@ UniValue paymentrequestvotelist(const UniValue& params, bool fHelp)
auto it = std::find_if( vAddedPaymentRequestVotes.begin(), vAddedPaymentRequestVotes.end(),
[&prequest](const std::pair<std::string, bool>& element){ return element.first == prequest.hash.ToString();} );
UniValue p(UniValue::VOBJ);
prequest.ToJson(p);
prequest.ToJson(p, false);
if (it != vAddedPaymentRequestVotes.end()) {
if (it->second)
yesvotes.push_back(p);
Expand Down

0 comments on commit 5d59483

Please sign in to comment.