35 "Returns the key used to sign avalanche messages.\n",
43 "Avalanche is not initialized");
52 const std::string keyHex = param.
get_str();
57 strprintf(
"Invalid public key: %s\n", keyHex));
66 if (localProof && localProof->getId() == proof->getId()) {
71 return pm.
getProof(proof->getId()) ||
82 const std::string &dgHex,
CPubKey &auth) {
89 if (!dg.
verify(state, auth)) {
91 "The delegation is invalid: " + state.
ToString());
96 const std::string &proofHex) {
116 "The proof is invalid: " + state.
ToString());
124 "Add a node in the set of peers to poll for avalanche.\n",
127 "Node to be added to avalanche."},
129 "The public key of the node."},
131 "Proof that the node is not a sybil."},
133 "The proof delegation the the node public key"},
136 "Whether the addition succeeded or not."},
138 HelpExampleRpc(
"addavalanchenode",
"5, \"<pubkey>\", \"<proof>\"")},
142 {UniValue::VNUM, UniValue::VSTR, UniValue::VSTR});
146 "Avalanche is not initialized");
149 const NodeId nodeid = request.params[0].get_int64();
157 if (key != proof->getMaster()) {
158 if (request.params.size() < 4 || request.params[3].isNull()) {
161 "The public key does not match the proof");
171 "The delegation does not match the proof");
177 "The public key does not match the delegation");
183 "The proof has conflicting utxos");
186 if (!
node.connman->ForNode(nodeid, [&](
CNode *pnode) {
187 LOCK(pnode->cs_avalanche_pubkey);
188 bool expected = false;
189 if (pnode->m_avalanche_enabled.compare_exchange_strong(
191 pnode->m_avalanche_pubkey = std::move(key);
197 strprintf(
"The node does not exist: %d", nodeid));
202 if (!pm.
addNode(nodeid, proofid)) {
215 "buildavalancheproof",
216 "Build a proof for avalanche's sybil resistance.\n",
219 "The proof's sequence"},
221 "A timestamp indicating when the proof expire"},
223 "The master private key in base58-encoding"},
228 "The stakes to be signed and associated private keys",
234 "A stake to be attached to this proof",
239 "The output number"},
243 "The height at which this UTXO was mined"},
246 "Indicate wether the UTXO is a coinbase"},
249 "private key in base58-encoding"},
258 "A string that is a serialized, hex-encoded proof data."},
260 "0 1234567800 \"<master>\" []")},
263 RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM,
264 UniValue::VSTR, UniValue::VARR});
266 const uint64_t sequence = request.params[0].get_int64();
267 const int64_t expiration = request.params[1].get_int64();
275 request.params[4].get_str(), config.GetChainParams());
279 "Invalid payout address");
286 for (
size_t i = 0; i < stakes.
size(); i++) {
303 "vout cannot be negative");
309 "height must be positive");
315 if (!stake.
exists(
"amount")) {
323 const bool iscoinbase =
330 "Invalid private key");
333 if (!pb.
addUTXO(utxo, amount, uint32_t(height), iscoinbase,
342 return proof->ToHex();
349 "decodeavalancheproof",
350 "Convert a serialized, hex-encoded proof, into JSON object. "
351 "The validity of the proof is not verified.\n",
354 "The proof hex string"},
362 "The proof's sequential number"},
364 "A timestamp indicating when the proof expires"},
367 "The proof signature (base64 encoded)"},
370 "The proof payout script",
374 "Raw payout script in hex format"},
378 "The required signatures"},
387 "A hash of the proof data excluding the master key."},
389 "A hash of the limitedid and master key."},
391 "The total staked amount of this proof in " +
403 "The transaction id"},
406 "The amount in this UTXO"},
408 "The height at which this UTXO was mined"},
410 "Indicate whether the UTXO is a coinbase"},
412 "This UTXO's public key"},
414 "Signature of the proofid with this UTXO's private "
415 "key (base64 encoded)"},
442 result.
pushKV(
"payoutscript", payoutScriptObj);
452 const COutPoint &utxo = s.getStake().getUTXO();
456 stake.
pushKV(
"amount", s.getStake().getAmount());
457 stake.
pushKV(
"height", uint64_t(s.getStake().getHeight()));
458 stake.
pushKV(
"iscoinbase", s.getStake().isCoinbase());
459 stake.
pushKV(
"pubkey",
HexStr(s.getStake().getPubkey()));
467 result.
pushKV(
"stakes", stakes);
476 "delegateavalancheproof",
477 "Delegate the avalanche proof to another public key.\n",
480 "The limited id of the proof to be delegated."},
482 "The private key in base58-encoding. Must match the proof master "
483 "public key or the upper level parent delegation public key if "
486 "The public key to delegate the proof to."},
488 "A string that is the serialized, hex-encoded delegation for the "
489 "proof and which is a parent for the delegation to build."},
492 "A string that is a serialized, hex-encoded delegation."},
495 "\"<limitedproofid>\" \"<privkey>\" \"<pubkey>\"")},
499 {UniValue::VSTR, UniValue::VSTR, UniValue::VSTR});
503 "Avalanche is not initialized");
507 ParseHashV(request.params[0],
"limitedproofid")};
512 "The private key is invalid");
517 std::unique_ptr<avalanche::DelegationBuilder> dgb;
518 if (request.params.size() >= 4 && !request.params[3].isNull()) {
527 "The delegation does not match the proof");
533 "The private key does not match the delegation");
536 dgb = std::make_unique<avalanche::DelegationBuilder>(dg);
538 dgb = std::make_unique<avalanche::DelegationBuilder>(
542 if (!dgb->addLevel(privkey, pubkey)) {
544 "Unable to build the delegation");
556 "decodeavalanchedelegation",
557 "Convert a serialized, hex-encoded avalanche proof delegation, into "
559 "The validity of the delegation is not verified.\n",
562 "The delegation hex string"},
570 "The public key the proof is delegated to."},
572 "The delegated proof master public key."},
574 "The identifier of this delegation."},
576 "A delegated proof data hash excluding the master key."},
578 "A hash of the delegated proof limitedid and master key."},
580 "The number of delegation levels."},
590 "The index of this delegation level."},
592 "This delegated public key for this level"},
594 "Signature of this delegation level (base64 "
600 "\"<hex delegation>\"") +
602 "\"<hex delegation>\"")},
610 delegation, request.params[0].get_str(),
error)) {
618 result.
pushKV(
"limitedid",
623 result.
pushKV(
"depth", uint64_t(levels.size()));
626 for (
auto &level : levels) {
632 result.
pushKV(
"levels", levelsArray);
642 "Returns an object containing various state info regarding avalanche "
651 "Whether the node is ready to start polling and voting."},
654 "Only available if -avaproof has been supplied to the node",
657 "Whether the node local proof has been locally verified "
660 "The proof verification status. Only available if the "
661 "\"verified\" flag is false."},
663 "The node local proof id."},
665 "The node local limited proof id."},
667 "The node local proof master public key."},
669 "The node local proof payout address. This might be "
670 "omitted if the payout script is not one of P2PK, P2PKH "
671 "or P2SH, in which case decodeavalancheproof can be used "
672 "to get more details."},
674 "The node local proof staked amount."},
681 "The number of valid avalanche proofs we know exist "
682 "(including this node's local proof if applicable)."},
684 "The number of avalanche proofs with at least one node "
685 "we are connected to (including this node's local proof "
688 "The number of avalanche proofs with no node attached."},
690 "The number of known avalanche proofs that have been "
691 "finalized by avalanche."},
693 "The number of known avalanche proofs that conflict with "
696 "The number of known avalanche proofs that have immature "
699 "The total staked amount over all the valid proofs in " +
701 " (including this node's local proof if "
704 "The total staked amount over all the connected proofs "
707 " (including this node's local proof if "
710 "The total staked amount over all the dangling proofs "
713 " (including this node's local proof if "
716 "The total staked amount over all the immature proofs "
719 " (including this node's local proof if "
722 "The number of avalanche nodes we are connected to "
723 "(including this node if a local proof is set)."},
725 "The number of avalanche nodes associated with an "
726 "avalanche proof (including this node if a local proof "
729 "The number of avalanche nodes pending for a proof."},
739 "Avalanche is not initialized");
746 if (localProof !=
nullptr) {
748 const bool verified =
g_avalanche->withPeerManager(
753 local.
pushKV(
"verified", verified);
754 const bool sharing =
g_avalanche->canShareLocalProof();
760 local.
pushKV(
"verification_status",
762 ? (sharing ?
"pending verification"
763 :
"pending inbound connections")
766 local.
pushKV(
"proofid", localProof->getId().ToString());
767 local.
pushKV(
"limited_proofid",
768 localProof->getLimitedId().ToString());
769 local.
pushKV(
"master",
HexStr(localProof->getMaster()));
773 local.
pushKV(
"payout_address",
776 local.
pushKV(
"stake_amount", localProof->getStakedAmount());
777 ret.
pushKV(
"local", local);
783 uint64_t proofCount{0};
784 uint64_t connectedProofCount{0};
785 uint64_t finalizedProofCount{0};
786 uint64_t connectedNodeCount{0};
793 const bool isLocalProof =
795 peer.
proof->getId() == localProof->getId();
798 const Amount proofStake = peer.
proof->getStakedAmount();
800 totalStakes += proofStake;
803 ++finalizedProofCount;
807 ++connectedProofCount;
808 connectedStakes += proofStake;
811 connectedNodeCount += peer.
node_count + isLocalProof;
817 immatureStakes += proof->getStakedAmount();
820 network.
pushKV(
"proof_count", proofCount);
821 network.
pushKV(
"connected_proof_count", connectedProofCount);
822 network.
pushKV(
"dangling_proof_count",
823 proofCount - connectedProofCount);
825 network.
pushKV(
"finalized_proof_count", finalizedProofCount);
827 "conflicting_proof_count",
830 "immature_proof_count",
833 network.
pushKV(
"total_stake_amount", totalStakes);
834 network.
pushKV(
"connected_stake_amount", connectedStakes);
835 network.
pushKV(
"dangling_stake_amount",
836 totalStakes - connectedStakes);
837 network.
pushKV(
"immature_stake_amount", immatureStakes);
840 network.
pushKV(
"node_count", connectedNodeCount + pendingNodes);
841 network.
pushKV(
"connected_node_count", connectedNodeCount);
842 network.
pushKV(
"pending_node_count", pendingNodes);
844 ret.
pushKV(
"network", network);
854 "getavalanchepeerinfo",
855 "Returns data about an avalanche peer as a json array of objects. If "
856 "no proofid is provided, returns data about all the peers.\n",
859 "The hex encoded avalanche proof identifier."},
871 "The avalanche internal peer identifier"},
873 "The agreggated availability score of this peer's nodes"},
875 "The avalanche proof id used by this peer"},
877 "The avalanche proof used by this peer"},
879 "The number of nodes for this peer"},
885 "Node id, as returned by getpeerinfo"},
900 "Avalanche is not initialized");
907 obj.
pushKV(
"avalanche_peerid", uint64_t(peer.peerid));
908 obj.
pushKV(
"availability_score", peer.availabilityScore);
909 obj.
pushKV(
"proofid", peer.getProofId().ToString());
910 obj.
pushKV(
"proof", peer.proof->ToHex());
917 obj.
pushKV(
"nodecount", uint64_t(peer.node_count));
918 obj.
pushKV(
"node_list", nodes);
927 if (!request.params[0].isNull()) {
928 const avalanche::ProofId proofid =
929 avalanche::ProofId::fromHex(
930 request.params[0].get_str());
931 if (!pm.isBoundToPeer(proofid)) {
932 throw JSONRPCError(RPC_INVALID_PARAMETER,
933 "Proofid not found");
937 return ret.push_back(peerToUniv(pm, peer));
956 "getavalancheproofs",
957 "Returns an object containing all tracked proofids.\n",
969 "Avalanche proof id"},
976 "Avalanche proof id"},
983 "Avalanche proof id"},
993 "Avalanche is not initialized");
999 const std::string &key) {
1021 "Return a list of possible staking reward winners based on the previous "
1023 "If -deprecatedrpc=getstakingreward is set it returns a single payout "
1024 "script instead of an array.\n",
1027 "The previous block hash, hex encoded."},
1029 "Whether to recompute the staking reward winner if there is a "
1037 "The winning proof payout script",
1041 "Raw payout script in hex format"},
1045 "The required signatures"},
1062 "The winning proof payout script",
1066 "Raw payout script in hex format"},
1070 "The required signatures"},
1102 config.GetChainParams().GetConsensus(), pprev)) {
1106 "Staking rewards are not activated for block %s\n",
1110 if (!request.params[1].isNull() && request.params[1].get_bool()) {
1119 strprintf(
"Unable to determine a staking reward winner "
1124 std::vector<CScript> winnerPayoutScripts;
1125 if (!
g_avalanche->getStakingRewardWinners(blockhash,
1126 winnerPayoutScripts)) {
1129 strprintf(
"Unable to retrieve the staking reward winner "
1135 for (
auto &winnerPayoutScript : winnerPayoutScripts) {
1138 stakingRewardsPayoutScriptObj,
1141 return stakingRewardsPayoutScriptObj;
1143 winners.
push_back(stakingRewardsPayoutScriptObj);
1154 "Set the staking reward winner for the given previous block hash.\n",
1157 "The previous block hash, hex encoded."},
1159 "The payout script for the staking reward, hex encoded."},
1161 "Append to the list of possible winners instead of replacing."},
1164 "Whether the payout script was set or not"},
1166 HelpExampleRpc(
"setstakingreward",
"<blockhash> <payout script>")},
1188 config.GetChainParams().GetConsensus(), pprev)) {
1192 "Staking rewards are not activated for block %s\n",
1196 const std::vector<uint8_t> data =
1197 ParseHex(request.params[1].get_str());
1198 const CScript payoutScript(data.begin(), data.end());
1200 std::vector<CScript> payoutScripts;
1202 if (!request.params[2].isNull() && request.params[2].get_bool()) {
1206 g_avalanche->getStakingRewardWinners(blockhash, payoutScripts);
1209 payoutScripts.push_back(std::move(payoutScript));
1214 g_avalanche->setStakingRewardWinners(pprev, payoutScripts);
1223 "Get the list of remote proofs for the given node id.\n",
1226 "The node identifier."},
1238 "The hex encoded proof identifier."},
1240 "Whether the node has the proof."},
1242 "The last time this proof status was updated."},
1251 "Avalanche is not initialized");
1254 const NodeId nodeid = request.params[0].get_int64();
1262 for (
const auto &remoteProof : remoteProofs) {
1264 obj.
pushKV(
"proofid", remoteProof.proofid.ToString());
1265 obj.
pushKV(
"present", remoteProof.present);
1266 obj.
pushKV(
"last_update", remoteProof.lastUpdate.count());
1278 "getrawavalancheproof",
1279 "Lookup for a known avalanche proof by id.\n",
1282 "The hex encoded avalanche proof identifier."},
1290 "The hex encoded proof matching the identifier."},
1292 "Whether the proof has immature utxos."},
1294 "Whether the proof is bound to an avalanche peer."},
1296 "Whether the proof has a conflicting UTXO with an avalanche "
1299 "Whether the proof is finalized by vote."},
1307 "Avalanche is not initialized");
1313 bool isImmature =
false;
1314 bool isBoundToPeer =
false;
1315 bool conflicting =
false;
1316 bool finalized =
false;
1338 ret.
pushKV(
"immature", isImmature);
1339 ret.
pushKV(
"boundToPeer", isBoundToPeer);
1340 ret.
pushKV(
"conflicting", conflicting);
1341 ret.
pushKV(
"finalized", finalized);
1350 "invalidateavalancheproof",
1351 "Reject a known avalanche proof by id.\n",
1354 "The hex encoded avalanche proof identifier."},
1366 "Avalanche is not initialized");
1374 throw JSONRPCError(RPC_INVALID_PARAMETER,
1381 throw JSONRPCError(RPC_INTERNAL_ERROR,
1382 "Failed to reject the proof");
1404 "Check if a block has been finalized by avalanche votes.\n",
1407 "The hash of the block."},
1410 "Whether the block has been finalized by avalanche votes."},
1417 "Avalanche is not initialized");
1422 "Avalanche is not ready to poll yet.");
1440 return chainman.ActiveChainstate().IsBlockAvalancheFinalized(
1448 "isfinaltransaction",
1449 "Check if a transaction has been finalized by avalanche votes.\n",
1452 "The id of the transaction."},
1454 "The block in which to look for the transaction"},
1458 "Whether the transaction has been finalized by avalanche votes."},
1465 "Avalanche is not initialized");
1474 if (!request.params[1].isNull()) {
1486 bool f_txindex_ready =
false;
1488 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
1493 pindex, &mempool, txid, config.GetChainParams().GetConsensus(),
1498 "Avalanche is not ready to poll yet.");
1505 return !pindex->nStatus.hasData())) {
1507 "Block data not downloaded yet.");
1509 errmsg =
"No such transaction found in the provided block.";
1511 errmsg =
"No such transaction. Use -txindex or provide a "
1512 "block hash to enable blockchain transaction "
1514 }
else if (!f_txindex_ready) {
1515 errmsg =
"No such transaction. Blockchain transactions are "
1516 "still in the process of being indexed.";
1518 errmsg =
"No such mempool or blockchain transaction.";
1539 return !
node.mempool->exists(txid) &&
1540 chainman.ActiveChainstate().IsBlockAvalancheFinalized(
1548 "reconsideravalancheproof",
1549 "Reconsider a known avalanche proof.\n",
1552 "The hex encoded avalanche proof."},
1557 "Whether the proof has been successfully registered.",
1564 "Avalanche is not initialized");
1580 pm.clearAllInvalid();
1605 "sendavalancheproof",
1606 "Broadcast an avalanche proof.\n",
1609 "The avalanche proof to broadcast."},
1612 "Whether the proof was sent successfully or not."},
1618 "Avalanche is not initialized");
1646 node.peerman->RelayProof(proofid);
1656 "verifyavalancheproof",
1657 "Verify an avalanche proof is valid and return the error otherwise.\n",
1660 "Proof to verify."},
1663 "Whether the proof is valid or not."},
1671 request.params[0].get_str());
1680 "verifyavalanchedelegation",
1681 "Verify an avalanche delegation is valid and return the error "
1685 "The avalanche proof delegation to verify."},
1688 "Whether the delegation is valid or not."},
1732 for (
const auto &c : commands) {
std::unique_ptr< avalanche::Processor > g_avalanche
Global avalanche instance.
#define CHECK_NONFATAL(condition)
Identity function.
#define Assert(val)
Identity function.
The block chain is a tree shaped structure starting with the genesis block at the root,...
Double ended buffer combining vector and stream-like interfaces.
An encapsulated secp256k1 private key.
bool IsValid() const
Check whether this private key is valid.
CPubKey GetPubKey() const
Compute the public key from a private key.
Information about a peer.
An outpoint - a combination of a transaction hash and an index n into its vout.
const TxId & GetTxId() const
An encapsulated public key.
static constexpr unsigned int COMPRESSED_SIZE
static constexpr unsigned int SIZE
secp256k1:
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Serialized script, used inside transaction inputs and outputs.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
bool isAvalancheFinalized(const TxId &txid) const
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
static RCUPtr make(Args &&...args)
Construct a new object that is owned by the pointer.
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool exists(const std::string &key) const
bool pushKV(const std::string &key, const UniValue &val)
std::string GetRejectReason() const
std::string GetDebugMessage() const
std::string ToString() const
ProofId getProofId() const
const std::vector< Level > & getLevels() const
static bool FromHex(Delegation &dg, const std::string &dgHex, bilingual_str &errorOut)
bool verify(DelegationState &state, CPubKey &auth) const
const LimitedProofId & getLimitedProofId() const
const CPubKey & getDelegatedPubkey() const
const DelegationId & getId() const
const CPubKey & getProofMaster() const
std::vector< RemoteProof > getRemoteProofs(const NodeId nodeid) const
bool isDangling(const ProofId &proofid) const
bool exists(const ProofId &proofid) const
bool forPeer(const ProofId &proofid, Callable &&func) const
bool addNode(NodeId nodeid, const ProofId &proofid)
Node API.
void addUnbroadcastProof(const ProofId &proofid)
Proof broadcast API.
bool isBoundToPeer(const ProofId &proofid) const
const ProofPool & getConflictingProofPool() const
size_t getPendingNodeCount() const
void forEachPeer(Callable &&func) const
const ProofPool & getValidProofPool() const
void setInvalid(const ProofId &proofid)
void forEachNode(const Peer &peer, Callable &&func) const
const Amount & getStakeUtxoDustThreshold() const
bool isInvalid(const ProofId &proofid) const
const ProofPool & getImmatureProofPool() const
bool isImmature(const ProofId &proofid) const
bool rejectProof(const ProofId &proofid, RejectionMode mode=RejectionMode::DEFAULT)
bool isInConflictingPool(const ProofId &proofid) const
ProofRef getProof(const ProofId &proofid) const
bool registerProof(const ProofRef &proof, ProofRegistrationState ®istrationState, RegistrationMode mode=RegistrationMode::DEFAULT)
bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, bool is_coinbase, CKey key)
int64_t getExpirationTime() const
static bool FromHex(Proof &proof, const std::string &hexProof, bilingual_str &errorOut)
const ProofId & getId() const
const std::vector< SignedStake > & getStakes() const
bool verify(const Amount &stakeUtxoDustThreshold, ProofValidationState &state) const
Amount getStakedAmount() const
uint64_t getSequence() const
const CScript & getPayoutScript() const
const CPubKey & getMaster() const
const SchnorrSig & getSignature() const
uint32_t getScore() const
const LimitedProofId & getLimitedId() const
Map a proof to each utxo.
size_t countProofs() const
void forEachProof(Callable &&func) const
ProofIdSet getProofIds() const
std::string ToString() const
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
CKey DecodeSecret(const std::string &str)
static constexpr Amount PROOF_DUST_THRESHOLD
Minimum amount per utxo.
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const TxId &txid, const Consensus::Params &consensusParams, BlockHash &hashBlock)
Return transaction with a given txid.
std::shared_ptr< const CTransaction > CTransactionRef
UniValue JSONRPCError(int code, const std::string &message)
static RPCHelpMan buildavalancheproof()
static RPCHelpMan invalidateavalancheproof()
static RPCHelpMan delegateavalancheproof()
static RPCHelpMan getremoteproofs()
static RPCHelpMan decodeavalanchedelegation()
static RPCHelpMan sendavalancheproof()
static RPCHelpMan getavalancheproofs()
static void verifyDelegationOrThrow(avalanche::Delegation &dg, const std::string &dgHex, CPubKey &auth)
static RPCHelpMan getrawavalancheproof()
static void verifyProofOrThrow(const NodeContext &node, avalanche::Proof &proof, const std::string &proofHex)
void RegisterAvalancheRPCCommands(CRPCTable &t)
static RPCHelpMan getavalanchekey()
static RPCHelpMan addavalanchenode()
static bool registerProofIfNeeded(avalanche::ProofRef proof, avalanche::ProofRegistrationState &state)
static CPubKey ParsePubKey(const UniValue ¶m)
static RPCHelpMan verifyavalanchedelegation()
static RPCHelpMan setstakingreward()
static RPCHelpMan isfinalblock()
static RPCHelpMan reconsideravalancheproof()
static RPCHelpMan isfinaltransaction()
static RPCHelpMan getstakingreward()
static RPCHelpMan getavalanchepeerinfo()
static RPCHelpMan verifyavalancheproof()
static RPCHelpMan getavalancheinfo()
static RPCHelpMan decodeavalancheproof()
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
Amount AmountFromValue(const UniValue &value)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::string GetAllOutputTypes()
CPubKey HexToPubKey(const std::string &hex_in)
uint256 ParseHashO(const UniValue &o, std::string strKey)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Check for expected keys/value types in an Object.
bool IsDeprecatedRPCEnabled(const ArgsManager &args, const std::string &method)
ArgsManager & EnsureAnyArgsman(const std::any &context)
ChainstateManager & EnsureAnyChainman(const std::any &context)
NodeContext & EnsureAnyNodeContext(const std::any &context)
CTxMemPool & EnsureMemPool(const NodeContext &node)
ChainstateManager & EnsureChainman(const NodeContext &node)
bool IsStakingRewardsActivated(const Consensus::Params ¶ms, const CBlockIndex *pprev)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const uint8_t > input)
bool IsHex(const std::string &str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
std::vector< uint8_t > ParseHex(const char *psz)
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
static const Currency & get()
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
static ProofId fromHex(const std::string &str)
NodeContext struct containing references to chain state and connection state.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
bool error(const char *fmt, const Args &...args)
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
static const int PROTOCOL_VERSION
network protocol versioning