Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | static UniValue buildavalancheproof(const Config &config, | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"buildavalancheproof", | "buildavalancheproof", | ||||
"Build a proof for avalanche's sybil resistance.\n", | "Build a proof for avalanche's sybil resistance.\n", | ||||
{ | { | ||||
{"sequence", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"sequence", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"The proof's sequence"}, | "The proof's sequence"}, | ||||
{"expiration", RPCArg::Type::NUM, RPCArg::Optional::NO, | {"expiration", RPCArg::Type::NUM, RPCArg::Optional::NO, | ||||
"A timestamp indicating when the proof expire"}, | "A timestamp indicating when the proof expire"}, | ||||
{"master", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"master", RPCArg::Type::STR, RPCArg::Optional::NO, | ||||
"The master public key"}, | "The master private key in base58-encoding"}, | ||||
{ | { | ||||
"stakes", | "stakes", | ||||
RPCArg::Type::ARR, | RPCArg::Type::ARR, | ||||
RPCArg::Optional::NO, | RPCArg::Optional::NO, | ||||
"The stakes to be signed and associated private keys", | "The stakes to be signed and associated private keys", | ||||
{ | { | ||||
{ | { | ||||
"stake", | "stake", | ||||
Show All 27 Lines | static UniValue buildavalancheproof(const Config &config, | ||||
} | } | ||||
.Check(request); | .Check(request); | ||||
RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM, | RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM, | ||||
UniValue::VSTR, UniValue::VARR}); | UniValue::VSTR, UniValue::VARR}); | ||||
const uint64_t sequence = request.params[0].get_int64(); | const uint64_t sequence = request.params[0].get_int64(); | ||||
const int64_t expiration = request.params[1].get_int64(); | const int64_t expiration = request.params[1].get_int64(); | ||||
avalanche::ProofBuilder pb(sequence, expiration, | |||||
ParsePubKey(request.params[2])); | CKey masterKey = DecodeSecret(request.params[2].get_str()); | ||||
if (!masterKey.IsValid()) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid master key"); | |||||
} | |||||
avalanche::ProofBuilder pb(sequence, expiration, masterKey); | |||||
const UniValue &stakes = request.params[3].get_array(); | const UniValue &stakes = request.params[3].get_array(); | ||||
for (size_t i = 0; i < stakes.size(); i++) { | for (size_t i = 0; i < stakes.size(); i++) { | ||||
const UniValue &stake = stakes[i]; | const UniValue &stake = stakes[i]; | ||||
RPCTypeCheckObj(stake, | RPCTypeCheckObj(stake, | ||||
{ | { | ||||
{"txid", UniValue::VSTR}, | {"txid", UniValue::VSTR}, | ||||
{"vout", UniValue::VNUM}, | {"vout", UniValue::VNUM}, | ||||
▲ Show 20 Lines • Show All 425 Lines • Show Last 20 Lines |