Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add collateralAddress into masternode/protx list rpc output #2740

Merged
merged 1 commit into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ void CDeterministicMN::ToJson(UniValue& obj) const
obj.push_back(Pair("proTxHash", proTxHash.ToString()));
obj.push_back(Pair("collateralHash", collateralOutpoint.hash.ToString()));
obj.push_back(Pair("collateralIndex", (int)collateralOutpoint.n));

Coin coin;
if (GetUTXOCoin(collateralOutpoint, coin)) {
CTxDestination dest;
if (ExtractDestination(coin.out.scriptPubKey, dest)) {
obj.push_back(Pair("collateralAddress", CBitcoinAddress(dest).ToString()));
}
}

obj.push_back(Pair("operatorReward", (double)nOperatorReward / 100));
obj.push_back(Pair("state", stateObj));
}
Expand Down
12 changes: 11 additions & 1 deletion src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,18 @@ UniValue masternodelist(const JSONRPCRequest& request)

mnList.ForEachMN(false, [&](const CDeterministicMNCPtr& dmn) {
std::string strOutpoint = dmn->collateralOutpoint.ToStringShort();
Coin coin;
std::string collateralAddressStr = "UNKNOWN";
if (GetUTXOCoin(dmn->collateralOutpoint, coin)) {
CTxDestination collateralDest;
if (ExtractDestination(coin.out.scriptPubKey, collateralDest)) {
collateralAddressStr = CBitcoinAddress(collateralDest).ToString();
}
}

CScript payeeScript = dmn->pdmnState->scriptPayout;
CTxDestination payeeDest;
std::string payeeStr = "UNKOWN";
std::string payeeStr = "UNKNOWN";
if (ExtractDestination(payeeScript, payeeDest)) {
payeeStr = CBitcoinAddress(payeeDest).ToString();
}
Expand Down Expand Up @@ -564,6 +572,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
dmn->pdmnState->nLastPaidHeight << " " <<
CBitcoinAddress(dmn->pdmnState->keyIDOwner).ToString() << " " <<
CBitcoinAddress(dmn->pdmnState->keyIDVoting).ToString() << " " <<
collateralAddressStr << " " <<
dmn->pdmnState->pubKeyOperator.ToString();
std::string strInfo = streamInfo.str();
if (strFilter !="" && strInfo.find(strFilter) == std::string::npos &&
Expand All @@ -576,6 +585,7 @@ UniValue masternodelist(const JSONRPCRequest& request)
objMN.push_back(Pair("lastpaidblock", dmn->pdmnState->nLastPaidHeight));
objMN.push_back(Pair("owneraddress", CBitcoinAddress(dmn->pdmnState->keyIDOwner).ToString()));
objMN.push_back(Pair("votingaddress", CBitcoinAddress(dmn->pdmnState->keyIDVoting).ToString()));
objMN.push_back(Pair("collateraladdress", collateralAddressStr));
objMN.push_back(Pair("pubkeyoperator", dmn->pdmnState->pubKeyOperator.ToString()));
obj.push_back(Pair(strOutpoint, objMN));
} else if (strMode == "lastpaidblock") {
Expand Down