Skip to content

Commit

Permalink
fix: return operator public key as "pub key share" for compatibility …
Browse files Browse the repository at this point in the history
…to tenderdash
  • Loading branch information
knst committed Dec 17, 2024
1 parent fd987f3 commit f0e7eb5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/rpc/quorums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static RPCHelpMan quorum_list_extended()
};
}

static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare)
static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_processor, const llmq::CQuorumCPtr& quorum, bool includeMembers, bool includeSkShare, bool single_node_quorum = false)
{
UniValue ret(UniValue::VOBJ);

Expand Down Expand Up @@ -210,9 +210,13 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
mo.pushKV("pubKeyOperator", dmn->pdmnState->pubKeyOperator.ToString());
mo.pushKV("valid", quorum->qc->validMembers[i]);
if (quorum->qc->validMembers[i]) {
CBLSPublicKey pubKey = quorum->GetPubKeyShare(i);
if (pubKey.IsValid()) {
mo.pushKV("pubKeyShare", pubKey.ToString());
if (single_node_quorum) {
mo.pushKV("pubKeyShare", dmn->pdmnState->pubKeyOperator.ToString());
} else {
CBLSPublicKey pubKey = quorum->GetPubKeyShare(i);
if (pubKey.IsValid()) {
mo.pushKV("pubKeyShare", pubKey.ToString());
}
}
}
membersArr.push_back(mo);
Expand All @@ -225,6 +229,14 @@ static UniValue BuildQuorumInfo(const llmq::CQuorumBlockProcessor& quorum_block_
if (includeSkShare && skShare.IsValid()) {
ret.pushKV("secretKeyShare", skShare.ToString());
}
/*
if (includeSkShare)
const CBLSSecretKey& skShare = !single_node_quorum ? quorum->GetSkShare() : ????
if (skShare.IsValid()) {
ret.pushKV("secretKeyShare", skShare.ToString());
}
}
*/
return ret;
}

Expand All @@ -245,7 +257,8 @@ static RPCHelpMan quorum_info()
const LLMQContext& llmq_ctx = EnsureLLMQContext(node);

const Consensus::LLMQType llmqType{static_cast<Consensus::LLMQType>(ParseInt32V(request.params[0], "llmqType"))};
if (!Params().GetLLMQ(llmqType).has_value()) {
auto llmq_opt = Params().GetLLMQ(llmqType);
if (!llmq_opt.has_value()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "invalid LLMQ type");
}

Expand All @@ -260,7 +273,7 @@ static RPCHelpMan quorum_info()
throw JSONRPCError(RPC_INVALID_PARAMETER, "quorum not found");
}

return BuildQuorumInfo(*llmq_ctx.quorum_block_processor, quorum, true, includeSkShare);
return BuildQuorumInfo(*llmq_ctx.quorum_block_processor, quorum, true, includeSkShare, llmq_opt->size == 1);
},
};
}
Expand Down

0 comments on commit f0e7eb5

Please sign in to comment.