38 "Returns the key used to sign avalanche messages.\n",
52 const std::string &keyHex = param.
get_str();
57 strprintf(
"Invalid public key: %s\n", keyHex));
66 auto localProof =
avalanche.getLocalProof();
67 if (localProof && localProof->getId() == proof->getId()) {
83 const std::string &dgHex,
CPubKey &auth) {
90 if (!dg.
verify(state, auth)) {
92 "The delegation is invalid: " + state.
ToString());
97 const std::string &proofHex) {
104 if (
node.avalanche) {
117 "The proof is invalid: " + state.
ToString());
125 "Add a node in the set of peers to poll for avalanche.\n",
128 "Node to be added to avalanche."},
130 "The public key of the node."},
132 "Proof that the node is not a sybil."},
134 "The proof delegation the the node public key"},
137 "Whether the addition succeeded or not."},
139 HelpExampleRpc(
"addavalanchenode",
"5, \"<pubkey>\", \"<proof>\"")},
142 const NodeId nodeid = request.params[0].
getInt<int64_t>();
152 if (key != proof->getMaster()) {
153 if (request.params.size() < 4 || request.params[3].isNull()) {
156 "The public key does not match the proof");
166 "The delegation does not match the proof");
172 "The public key does not match the delegation");
178 "The proof has conflicting utxos");
181 if (!
node.connman->ForNode(nodeid, [&](
CNode *pnode) {
182 LOCK(pnode->cs_avalanche_pubkey);
183 bool expected = false;
184 if (pnode->m_avalanche_enabled.compare_exchange_strong(
186 pnode->m_avalanche_pubkey = std::move(key);
192 strprintf(
"The node does not exist: %d", nodeid));
198 if (!pm.
addNode(nodeid, proofid,
212 "buildavalancheproof",
213 "Build a proof for avalanche's sybil resistance.\n",
216 "The proof's sequence"},
218 "A timestamp indicating when the proof expire"},
220 "The master private key in base58-encoding"},
225 "The stakes to be signed and associated private keys",
231 "A stake to be attached to this proof",
236 "The output number"},
240 "The height at which this UTXO was mined"},
243 "Indicate wether the UTXO is a coinbase"},
246 "private key in base58-encoding"},
255 "A string that is a serialized, hex-encoded proof data."},
257 "0 1234567800 \"<master>\" []")},
260 const uint64_t sequence = request.params[0].
getInt<int64_t>();
261 const int64_t expiration = request.params[1].getInt<int64_t>();
264 if (!masterKey.IsValid()) {
269 request.params[4].get_str(), config.GetChainParams());
273 "Invalid payout address");
280 for (
size_t i = 0; i < stakes.
size(); i++) {
297 "vout cannot be negative");
303 "height must be positive");
307 const COutPoint utxo(txid, nOut);
309 if (!stake.
exists(
"amount")) {
317 const bool iscoinbase =
324 "Invalid private key");
327 if (!pb.
addUTXO(utxo, amount, uint32_t(height), iscoinbase,
336 return proof->ToHex();
343 "decodeavalancheproof",
344 "Convert a serialized, hex-encoded proof, into JSON object. "
345 "The validity of the proof is not verified.\n",
348 "The proof hex string"},
356 "The proof's sequential number"},
358 "A timestamp indicating when the proof expires"},
361 "The proof signature (base64 encoded)"},
364 "The proof payout script",
368 "Raw payout script in hex format"},
372 "The required signatures"},
381 "A hash of the proof data excluding the master key."},
383 "A hash of the limitedid and master key."},
385 "The total staked amount of this proof in " +
397 "The transaction id"},
400 "The amount in this UTXO"},
402 "The height at which this UTXO was mined"},
404 "Indicate whether the UTXO is a coinbase"},
406 "This UTXO's public key"},
408 "Signature of the proofid with this UTXO's private "
409 "key (base64 encoded)"},
434 result.
pushKV(
"payoutscript", payoutScriptObj);
444 const COutPoint &utxo = s.getStake().getUTXO();
446 stake.
pushKV(
"txid", utxo.GetTxId().ToString());
447 stake.
pushKV(
"vout", uint64_t(utxo.GetN()));
448 stake.
pushKV(
"amount", s.getStake().getAmount());
449 stake.
pushKV(
"height", uint64_t(s.getStake().getHeight()));
450 stake.
pushKV(
"iscoinbase", s.getStake().isCoinbase());
451 stake.
pushKV(
"pubkey",
HexStr(s.getStake().getPubkey()));
459 result.
pushKV(
"stakes", stakes);
468 "delegateavalancheproof",
469 "Delegate the avalanche proof to another public key.\n",
472 "The limited id of the proof to be delegated."},
474 "The private key in base58-encoding. Must match the proof master "
475 "public key or the upper level parent delegation public key if "
478 "The public key to delegate the proof to."},
480 "A string that is the serialized, hex-encoded delegation for the "
481 "proof and which is a parent for the delegation to build."},
484 "A string that is a serialized, hex-encoded delegation."},
487 "\"<limitedproofid>\" \"<privkey>\" \"<pubkey>\"")},
491 ParseHashV(request.params[0],
"limitedproofid")};
496 "The private key is invalid");
501 std::unique_ptr<avalanche::DelegationBuilder> dgb;
502 if (request.params.size() >= 4 && !request.params[3].isNull()) {
511 "The delegation does not match the proof");
517 "The private key does not match the delegation");
520 dgb = std::make_unique<avalanche::DelegationBuilder>(dg);
522 dgb = std::make_unique<avalanche::DelegationBuilder>(
526 if (!dgb->addLevel(privkey, pubkey)) {
528 "Unable to build the delegation");
540 "decodeavalanchedelegation",
541 "Convert a serialized, hex-encoded avalanche proof delegation, into "
543 "The validity of the delegation is not verified.\n",
546 "The delegation hex string"},
554 "The public key the proof is delegated to."},
556 "The delegated proof master public key."},
558 "The identifier of this delegation."},
560 "A delegated proof data hash excluding the master key."},
562 "A hash of the delegated proof limitedid and master key."},
564 "The number of delegation levels."},
574 "The index of this delegation level."},
576 "This delegated public key for this level"},
578 "Signature of this delegation level (base64 "
584 "\"<hex delegation>\"") +
586 "\"<hex delegation>\"")},
592 delegation, request.params[0].get_str(), error)) {
600 result.
pushKV(
"limitedid",
605 result.
pushKV(
"depth", uint64_t(levels.size()));
608 for (
auto &level : levels) {
614 result.
pushKV(
"levels", levelsArray);
624 "Returns an object containing various state info regarding avalanche "
633 "Whether the node is ready to start polling and voting."},
636 "Only available if -avaproof has been supplied to the node",
639 "Whether the node local proof has been locally verified "
642 "The proof verification status. Only available if the "
643 "\"verified\" flag is false."},
645 "The node local proof id."},
647 "The node local limited proof id."},
649 "The node local proof master public key."},
651 "The node local proof payout address. This might be "
652 "omitted if the payout script is not one of P2PK, P2PKH "
653 "or P2SH, in which case decodeavalancheproof can be used "
654 "to get more details."},
656 "The node local proof staked amount."},
663 "The number of valid avalanche proofs we know exist "
664 "(including this node's local proof if applicable)."},
666 "The number of avalanche proofs with at least one node "
667 "we are connected to (including this node's local proof "
670 "The number of avalanche proofs with no node attached."},
672 "The number of known avalanche proofs that have been "
673 "finalized by avalanche."},
675 "The number of known avalanche proofs that conflict with "
678 "The number of known avalanche proofs that have immature "
681 "The total staked amount over all the valid proofs in " +
683 " (including this node's local proof if "
686 "The total staked amount over all the connected proofs "
689 " (including this node's local proof if "
692 "The total staked amount over all the dangling proofs "
695 " (including this node's local proof if "
698 "The total staked amount over all the immature proofs "
701 " (including this node's local proof if "
704 "The number of avalanche nodes we are connected to "
705 "(including this node if a local proof is set)."},
707 "The number of avalanche nodes associated with an "
708 "avalanche proof (including this node if a local proof "
711 "The number of avalanche nodes pending for a proof."},
725 auto localProof =
avalanche.getLocalProof();
726 if (localProof !=
nullptr) {
728 const bool verified =
avalanche.withPeerManager(
733 local.
pushKV(
"verified", verified);
734 const bool sharing =
avalanche.canShareLocalProof();
737 avalanche.getLocalProofRegistrationState();
740 local.
pushKV(
"verification_status",
742 ? (sharing ?
"pending verification"
743 :
"pending inbound connections")
746 local.
pushKV(
"proofid", localProof->getId().ToString());
747 local.
pushKV(
"limited_proofid",
748 localProof->getLimitedId().ToString());
749 local.
pushKV(
"master",
HexStr(localProof->getMaster()));
753 local.
pushKV(
"payout_address",
756 local.
pushKV(
"stake_amount", localProof->getStakedAmount());
757 ret.
pushKV(
"local", local);
763 uint64_t proofCount{0};
764 uint64_t connectedProofCount{0};
765 uint64_t finalizedProofCount{0};
766 uint64_t connectedNodeCount{0};
773 const bool isLocalProof =
775 peer.
proof->getId() == localProof->getId();
778 const Amount proofStake = peer.
proof->getStakedAmount();
780 totalStakes += proofStake;
783 ++finalizedProofCount;
787 ++connectedProofCount;
788 connectedStakes += proofStake;
791 connectedNodeCount += peer.
node_count + isLocalProof;
797 immatureStakes += proof->getStakedAmount();
800 network.
pushKV(
"proof_count", proofCount);
801 network.
pushKV(
"connected_proof_count", connectedProofCount);
802 network.
pushKV(
"dangling_proof_count",
803 proofCount - connectedProofCount);
805 network.
pushKV(
"finalized_proof_count", finalizedProofCount);
807 "conflicting_proof_count",
810 "immature_proof_count",
813 network.
pushKV(
"total_stake_amount", totalStakes);
814 network.
pushKV(
"connected_stake_amount", connectedStakes);
815 network.
pushKV(
"dangling_stake_amount",
816 totalStakes - connectedStakes);
817 network.
pushKV(
"immature_stake_amount", immatureStakes);
820 network.
pushKV(
"node_count", connectedNodeCount + pendingNodes);
821 network.
pushKV(
"connected_node_count", connectedNodeCount);
822 network.
pushKV(
"pending_node_count", pendingNodes);
824 ret.
pushKV(
"network", network);
834 "getavalanchepeerinfo",
835 "Returns data about an avalanche peer as a json array of objects. If "
836 "no proofid is provided, returns data about all the peers.\n",
839 "The hex encoded avalanche proof identifier."},
851 "The avalanche internal peer identifier"},
853 "The avalanche proof id used by this peer"},
855 "The avalanche proof used by this peer"},
857 "The number of nodes for this peer"},
863 "Node id, as returned by getpeerinfo"},
881 obj.
pushKV(
"avalanche_peerid", uint64_t(peer.peerid));
882 obj.
pushKV(
"proofid", peer.getProofId().ToString());
883 obj.
pushKV(
"proof", peer.proof->ToHex());
890 obj.
pushKV(
"nodecount", uint64_t(peer.node_count));
891 obj.
pushKV(
"node_list", nodes);
900 if (!request.params[0].isNull()) {
901 const avalanche::ProofId proofid =
902 avalanche::ProofId::fromHex(
903 request.params[0].get_str());
904 if (!pm.isBoundToPeer(proofid)) {
905 throw JSONRPCError(RPC_INVALID_PARAMETER,
906 "Proofid not found");
910 ret.push_back(peerToUniv(pm, peer));
930 "getavalancheproofs",
931 "Returns an object containing all tracked proofids.\n",
943 "Avalanche proof id"},
950 "Avalanche proof id"},
957 "Avalanche proof id"},
971 const std::string &key) {
993 "Return a list of possible staking reward winners based on the "
998 "The previous block hash, hex encoded."},
1000 "Whether to recompute the staking reward winner if there is a "
1010 "The winning proof",
1013 "The winning proofid"},
1016 "Raw payout script in hex format"},
1020 "The required signatures"},
1052 config.GetChainParams().GetConsensus(), pprev)) {
1056 "Staking rewards are not activated for block %s\n",
1060 if (!request.params[1].isNull() && request.params[1].get_bool()) {
1063 avalanche.eraseStakingRewardWinner(blockhash);
1066 if (!
avalanche.computeStakingReward(pprev)) {
1069 strprintf(
"Unable to determine a staking reward winner "
1074 std::vector<std::pair<avalanche::ProofId, CScript>> winners;
1075 if (!
avalanche.getStakingRewardWinners(blockhash, winners)) {
1078 strprintf(
"Unable to retrieve the staking reward winner "
1084 for (
auto &winner : winners) {
1088 stakingRewardsObj.
pushKV(
"proofid", winner.first.GetHex());
1089 winnersArr.
push_back(stakingRewardsObj);
1100 "Return true if a staking reward winner exists based on the previous "
1104 "The previous block hash, hex encoded."},
1107 "Whether staking reward winner has been computed for "
1108 "previous block hash or not."},
1132 config.GetChainParams().GetConsensus(), pprev)) {
1136 "Staking rewards are not activated for block %s\n",
1140 std::vector<std::pair<avalanche::ProofId, CScript>> winners;
1141 if (!
avalanche.getStakingRewardWinners(blockhash, winners)) {
1144 return winners.size() > 0;
1152 "Set the staking reward winner for the given previous block hash.\n",
1155 "The previous block hash, hex encoded."},
1157 "The payout script for the staking reward, hex encoded."},
1159 "Append to the list of possible winners instead of replacing."},
1162 "Whether the payout script was set or not"},
1164 HelpExampleRpc(
"setstakingreward",
"<blockhash> <payout script>")},
1187 config.GetChainParams().GetConsensus(), pprev)) {
1191 "Staking rewards are not activated for block %s\n",
1195 const std::vector<uint8_t> data =
1196 ParseHex(request.params[1].get_str());
1197 CScript payoutScript(data.begin(), data.end());
1199 std::vector<CScript> payoutScripts;
1201 if (!request.params[2].isNull() && request.params[2].get_bool()) {
1205 avalanche.getStakingRewardWinners(blockhash, payoutScripts);
1208 if (std::find(payoutScripts.begin(), payoutScripts.end(),
1209 payoutScript) != payoutScripts.end()) {
1213 "Staking rewards winner is already set for block %s\n",
1217 payoutScripts.push_back(std::move(payoutScript));
1222 avalanche.setStakingRewardWinners(pprev, payoutScripts);
1231 "Get the list of remote proofs for the given node id.\n",
1234 "The node identifier."},
1246 "The hex encoded proof identifier."},
1248 "Whether the node has the proof."},
1250 "The last time this proof status was updated."},
1260 const NodeId nodeid = request.params[0].getInt<int64_t>();
1261 auto remoteProofs =
avalanche.withPeerManager(
1268 for (
const auto &remoteProof : remoteProofs) {
1270 obj.
pushKV(
"proofid", remoteProof.proofid.ToString());
1271 obj.
pushKV(
"present", remoteProof.present);
1272 obj.
pushKV(
"last_update", remoteProof.lastUpdate.count());
1284 "getrawavalancheproof",
1285 "Lookup for a known avalanche proof by id.\n",
1288 "The hex encoded avalanche proof identifier."},
1296 "The hex encoded proof matching the identifier."},
1298 "Whether the proof has immature utxos."},
1300 "Whether the proof is bound to an avalanche peer."},
1302 "Whether the proof has a conflicting UTXO with an avalanche "
1305 "Whether the proof is finalized by vote."},
1317 bool isImmature =
false;
1318 bool isBoundToPeer =
false;
1319 bool conflicting =
false;
1320 bool finalized =
false;
1342 ret.
pushKV(
"immature", isImmature);
1343 ret.
pushKV(
"boundToPeer", isBoundToPeer);
1344 ret.
pushKV(
"conflicting", conflicting);
1345 ret.
pushKV(
"finalized", finalized);
1354 "invalidateavalancheproof",
1355 "Reject a known avalanche proof by id.\n",
1358 "The hex encoded avalanche proof identifier."},
1376 throw JSONRPCError(RPC_INVALID_PARAMETER,
1383 throw JSONRPCError(RPC_INTERNAL_ERROR,
1384 "Failed to reject the proof");
1390 if (
avalanche.isRecentlyFinalized(proofid)) {
1406 "Check if a block has been finalized by avalanche votes.\n",
1409 "The hash of the block."},
1412 "Whether the block has been finalized by avalanche votes."},
1422 "Avalanche is not ready to poll yet.");
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."},
1471 if (!request.params[1].isNull()) {
1483 bool f_txindex_ready =
false;
1485 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
1490 pindex, &mempool, txid, hash_block, chainman.
m_blockman);
1494 "Avalanche is not ready to poll yet.");
1501 return !pindex->nStatus.hasData())) {
1503 "Block data not downloaded yet.");
1505 errmsg =
"No such transaction found in the provided block.";
1507 errmsg =
"No such transaction. Use -txindex or provide a "
1508 "block hash to enable blockchain transaction "
1510 }
else if (!f_txindex_ready) {
1511 errmsg =
"No such transaction. Blockchain transactions are "
1512 "still in the process of being indexed.";
1514 errmsg =
"No such mempool or blockchain transaction.";
1537 return !
node.mempool->exists(txid) &&
1546 "reconsideravalancheproof",
1547 "Reconsider a known avalanche proof.\n",
1550 "The hex encoded avalanche proof."},
1555 "Whether the proof has been successfully registered.",
1575 pm.clearAllInvalid();
1600 "sendavalancheproof",
1601 "Broadcast an avalanche proof.\n",
1604 "The avalanche proof to broadcast."},
1607 "Whether the proof was sent successfully or not."},
1638 node.peerman->RelayProof(proofid);
1648 "verifyavalancheproof",
1649 "Verify an avalanche proof is valid and return the error otherwise.\n",
1652 "Proof to verify."},
1655 "Whether the proof is valid or not."},
1661 request.params[0].get_str());
1670 "verifyavalanchedelegation",
1671 "Verify an avalanche delegation is valid and return the error "
1675 "The avalanche proof delegation to verify."},
1678 "Whether the delegation is valid or not."},
1695 "Add or remove a proofid from the flaky list. This means that an "
1696 "additional staking reward winner will be accepted if this proof is "
1697 "the selected one.\n",
1700 "The avalanche proof id."},
1702 "Whether to add (true) or remove (false) the proof from the flaky "
1706 "Whether the addition/removal is successful."},
1714 const auto proofid =
1716 const bool addNotRemove = request.params[1].get_bool();
1721 return pm.setFlaky(proofid);
1730 return avalanche.computeStakingReward(pprev);
1740 "List the flaky proofs (set via setflakyproof).\n",
1752 "The hex encoded proof identifier."},
1754 "The proof stake amount, only present if the proof is "
1758 "The proof payout script, only present if the proof is "
1763 "Raw payout script in hex format"},
1767 "The required signatures"},
1786 avalanche.withPeerManager([&flakyProofs](
1792 const auto proof = pm.
getProof(proofid);
1794 flakyProof.
pushKV(
"staked_amount",
1795 proof->getStakedAmount());
1799 flakyProof.
pushKV(
"payout", payout);
1812 "getavailabilityscore",
1813 "Return the node availability score.\n",
1818 "The node availability score (if any)."},
1825 const NodeId nodeid(request.params[0].getInt<int64_t>());
1840 "getstakecontendervote",
1841 "Return the stake contender avalanche vote.\n",
1844 "The prevblockhash used to compute the stake contender ID, hex "
1847 "The proofid used to compute the stake contender ID, hex "
1851 "The vote that would be returned if polled."},
1853 "<prevblockhash> <proofid>")},
1860 ParseHashV(request.params[0],
"prevblockhash"));
1865 return avalanche.getStakeContenderStatus(contenderId);
1872 "finalizetransaction",
1873 "Force finalize a mempool transaction. No attempt is made to poll for "
1874 "this transaction and this could cause the node to disagree with the "
1875 "network. This can fail if the transaction to be finalized would "
1876 "overflow the block size. Upon success it will be included in the "
1877 "block template.\n",
1880 "The id of the transaction to be finalized."},
1884 "The list of the successfully finalized txids if any (it can "
1885 "include ancestors of the target txid).",
1889 "The finalized transaction id.",
1901 auto entry = mempool.
GetIter(txid);
1904 "The transaction is not in the mempool.");
1910 "There is no active chain tip.");
1915 std::vector<TxId> finalizedTxids;
1916 if (!mempool.setAvalancheFinalized(**entry, chainman.
GetConsensus(),
1917 *tip, finalizedTxids)) {
1923 for (
TxId &finalizedTxid : finalizedTxids) {
1924 ret.
push_back(finalizedTxid.ToString());
1941 "removetransaction",
1942 "Remove a transaction and all its descendants from the mempool. If the "
1943 "transaction is final it is removed anyway. No attempt is made to poll "
1944 "for this transaction and this could cause the node to disagree with "
1948 "The id of the transaction to be removed."},
1952 "The list of the removed txids if any (it can include "
1953 "descendants of the target txid).",
1957 "The removed transaction id.",
1967 auto iter = mempool.
GetIter(txid);
1970 "The transaction is not in the mempool.");
1979 for (
auto &it : setDescendants) {
1980 ret.
push_back((*it)->GetSharedTx()->GetId().ToString());
1992 "getfinaltransactions",
1993 "Returns all finalized transactions that have not been included in a "
1994 "finalized block yet.",
1997 "True for a json object, false for an array of transaction ids"},
2023 const bool fVerbose =
2024 !request.params[0].
isNull() && request.params[0].get_bool();
2035 entryRef->GetTx().GetId().GetHex());
2087 for (
const auto &c : commands) {
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 hasstakingreward()
static RPCHelpMan addavalanchenode()
static CPubKey ParsePubKey(const UniValue ¶m)
static RPCHelpMan finalizetransaction()
static RPCHelpMan getavailabilityscore()
static RPCHelpMan getstakecontendervote()
static RPCHelpMan verifyavalanchedelegation()
static RPCHelpMan setflakyproof()
static RPCHelpMan getfinaltransactions()
static RPCHelpMan removetransaction()
static RPCHelpMan setstakingreward()
static RPCHelpMan getflakyproofs()
static RPCHelpMan isfinalblock()
static RPCHelpMan reconsideravalancheproof()
static RPCHelpMan isfinaltransaction()
static RPCHelpMan getstakingreward()
static bool registerProofIfNeeded(const avalanche::Processor &avalanche, avalanche::ProofRef proof, avalanche::ProofRegistrationState &state)
static RPCHelpMan getavalanchepeerinfo()
static RPCHelpMan verifyavalancheproof()
static RPCHelpMan getavalancheinfo()
static RPCHelpMan decodeavalancheproof()
#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,...
BlockHash GetBlockHash() const
void GetNodeStats(std::vector< CNodeStats > &vstats) const
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 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.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::set< txiter, CompareIteratorById > setEntries
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
bool setAvalancheFinalized(const CTxMemPoolEntryRef &tx, const Consensus::Params ¶ms, const CBlockIndex &active_chain_tip, std::vector< TxId > &finalizedTxIds) EXCLUSIVE_LOCKS_REQUIRED(bool isAvalancheFinalizedPreConsensus(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
RadixTree< CTxMemPoolEntry, MemPoolEntryRadixTreeAdapter > finalizedTxs
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
void RemoveStaged(const setEntries &stage, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove a set of transactions from the mempool.
std::optional< txiter > GetIter(const TxId &txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Returns an iterator to the given txid, if found.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(const CBlockIndex *GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(Chainstate ActiveChainstate)() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
const Consensus::Params & GetConsensus() const
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Double ended buffer combining vector and stream-like interfaces.
static RCUPtr make(Args &&...args)
Construct a new object that is owned by the pointer.
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, 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 CPubKey & getProofMaster() const
const DelegationId & getId() const
const CPubKey & getDelegatedPubkey() const
const LimitedProofId & getLimitedProofId() const
std::vector< RemoteProof > getRemoteProofs(const NodeId nodeid) const
bool isDangling(const ProofId &proofid) const
bool addNode(NodeId nodeid, const ProofId &proofid, size_t max_elements)
Node API.
bool unsetFlaky(const ProofId &proofid)
bool exists(const ProofId &proofid) const
Return true if the (valid) proof exists, but only for non-dangling proofs.
const ProofPool & getValidProofPool() const
bool forPeer(const ProofId &proofid, Callable &&func) const
void addUnbroadcastProof(const ProofId &proofid)
Proof broadcast API.
bool isBoundToPeer(const ProofId &proofid) const
size_t getPendingNodeCount() const
const ProofPool & getImmatureProofPool() const
void forEachPeer(Callable &&func) const
void setInvalid(const ProofId &proofid)
void forEachNode(const Peer &peer, Callable &&func) const
const Amount & getStakeUtxoDustThreshold() const
void forEachFlakyProof(Callable &&func) const
bool isInvalid(const ProofId &proofid) const
bool isImmature(const ProofId &proofid) const
bool rejectProof(const ProofId &proofid, RejectionMode mode=RejectionMode::DEFAULT)
const ProofPool & getConflictingProofPool() const
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)
bool verify(const Amount &stakeUtxoDustThreshold, ProofValidationState &state) const
Amount getStakedAmount() const
const CPubKey & getMaster() const
uint64_t getSequence() const
const LimitedProofId & getLimitedId() const
const SchnorrSig & getSignature() const
const CScript & getPayoutScript() const
uint32_t getScore() const
const ProofId & getId() const
const std::vector< SignedStake > & getStakes() const
Map a proof to each utxo.
size_t countProofs() const
void forEachProof(Callable &&func) const
ProofIdSet getProofIds() const
std::string ToString() const
std::string GetHex() const
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS, std::function< bool(const CTxOut &)> is_change_func={})
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
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, BlockHash &hashBlock, const BlockManager &blockman)
Return transaction with a given txid.
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr size_t AVALANCHE_MAX_ELEMENT_POLL_LEGACY
Legacy maximum element poll.
std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc, bool wallet)
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
UniValue JSONRPCError(int code, const std::string &message)
@ 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.
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.
ChainstateManager & EnsureAnyChainman(const std::any &context)
NodeContext & EnsureAnyNodeContext(const std::any &context)
CTxMemPool & EnsureMemPool(const NodeContext &node)
ChainstateManager & EnsureChainman(const NodeContext &node)
CTxMemPool & EnsureAnyMemPool(const std::any &context)
avalanche::Processor & EnsureAvalanche(const NodeContext &node)
CConnman & EnsureConnman(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.
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
POD that contains various stats about a node.
std::optional< double > m_availabilityScore
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 for which the default value is omitted from help text for one of two reasons:
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
bool forEachLeaf(Callable &&func) const
A TxId is the identifier of a transaction.
static ProofId fromHex(const std::string &str)
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...
NodeContext struct containing references to chain state and connection state.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
@ MANUAL
Manual removal via RPC.
std::string EncodeBase64(Span< const uint8_t > input)
template std::vector< std::byte > ParseHex(std::string_view)
bool IsHex(std::string_view str)
Returns true if each character in str is a hex character, and has an even number of hex digits.