Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < stakes.size(); i++) { | ||||
const Amount amount = AmountFromValue(find_value(stake, "amount")); | const Amount amount = AmountFromValue(find_value(stake, "amount")); | ||||
const UniValue &iscbparam = find_value(stake, "iscoinbase"); | const UniValue &iscbparam = find_value(stake, "iscoinbase"); | ||||
const bool iscoinbase = | const bool iscoinbase = | ||||
iscbparam.isNull() ? false : iscbparam.get_bool(); | iscbparam.isNull() ? false : iscbparam.get_bool(); | ||||
CKey key = DecodeSecret(find_value(stake, "privatekey").get_str()); | CKey key = DecodeSecret(find_value(stake, "privatekey").get_str()); | ||||
if (!key.IsValid()) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid private key"); | |||||
} | |||||
if (!pb.addUTXO(utxo, amount, uint32_t(height), iscoinbase, | if (!pb.addUTXO(utxo, amount, uint32_t(height), iscoinbase, | ||||
std::move(key))) { | std::move(key))) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid private key"); | throw JSONRPCError(RPC_INVALID_PARAMETER, "Duplicated stake"); | ||||
} | } | ||||
} | } | ||||
const avalanche::Proof proof = pb.build(); | const avalanche::Proof proof = pb.build(); | ||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); | ||||
ss << proof; | ss << proof; | ||||
return HexStr(ss); | return HexStr(ss); | ||||
▲ Show 20 Lines • Show All 377 Lines • Show Last 20 Lines |