38 "Returns the key used to sign avalanche messages.\n",
53 const std::string &keyHex = param.
get_str();
58 strprintf(
"Invalid public key: %s\n", keyHex));
67 auto localProof =
avalanche.getLocalProof();
68 if (localProof && localProof->getId() == proof->getId()) {
84 const std::string &dgHex,
CPubKey &auth) {
91 if (!dg.
verify(state, auth)) {
93 "The delegation is invalid: " + state.
ToString());
98 const std::string &proofHex) {
105 if (
node.avalanche) {
118 "The proof is invalid: " + state.
ToString());
126 "Add a node in the set of peers to poll for avalanche.\n",
129 "Node to be added to avalanche."},
131 "The public key of the node."},
133 "Proof that the node is not a sybil."},
135 "The proof delegation the the node public key"},
138 "Whether the addition succeeded or not."},
140 HelpExampleCli(
"addavalanchenode",
"5, \"<pubkey>\", \"<proof>\"") +
141 HelpExampleRpc(
"addavalanchenode",
"5, \"<pubkey>\", \"<proof>\"")},
144 const NodeId nodeid = request.params[0].
getInt<int64_t>();
154 if (key != proof->getMaster()) {
155 if (request.params.size() < 4 || request.params[3].isNull()) {
158 "The public key does not match the proof");
168 "The delegation does not match the proof");
174 "The public key does not match the delegation");
180 "The proof has conflicting utxos");
183 if (!
node.connman->ForNode(nodeid, [&](
CNode *pnode) {
184 LOCK(pnode->cs_avalanche_pubkey);
185 bool expected = false;
186 if (pnode->m_avalanche_enabled.compare_exchange_strong(
188 pnode->m_avalanche_pubkey = std::move(key);
194 strprintf(
"The node does not exist: %d", nodeid));
200 if (!pm.
addNode(nodeid, proofid,
214 "buildavalancheproof",
215 "Build a proof for avalanche's sybil resistance.\n",
218 "The proof's sequence"},
220 "A timestamp indicating when the proof expires"},
222 "The master private key in base58-encoding"},
227 "The stakes to be signed and associated private keys",
233 "A stake to be attached to this proof",
238 "The output number"},
242 "The height at which this UTXO was mined"},
245 "Indicate whether the UTXO is a coinbase"},
248 "private key in base58-encoding"},
257 "A string that is a serialized, hex-encoded proof data."},
259 "0 1234567800 \"<master>\" []") +
261 "0 1234567800 \"<master>\" []")},
264 const uint64_t sequence = request.params[0].
getInt<int64_t>();
265 const int64_t expiration = request.params[1].getInt<int64_t>();
268 if (!masterKey.IsValid()) {
273 request.params[4].get_str(), config.GetChainParams());
277 "Invalid payout address");
284 for (
size_t i = 0; i < stakes.
size(); i++) {
301 "vout cannot be negative");
307 "height must be positive");
311 const COutPoint utxo(txid, nOut);
313 if (!stake.
exists(
"amount")) {
321 const bool iscoinbase =
328 "Invalid private key");
331 if (!pb.
addUTXO(utxo, amount, uint32_t(height), iscoinbase,
340 return proof->ToHex();
347 "decodeavalancheproof",
348 "Convert a serialized, hex-encoded proof into a JSON object. "
349 "The validity of the proof is not verified.\n",
352 "The proof hex string"},
360 "The proof's sequential number"},
362 "A timestamp indicating when the proof expires"},
365 "The proof signature (base64 encoded)"},
368 "The proof payout script",
372 "Raw payout script in hex format"},
376 "The required signatures"},
385 "A hash of the proof data excluding the master key."},
387 "A hash of the limitedid and master key."},
389 "The total staked amount of this proof in " +
401 "The transaction id"},
404 "The amount in this UTXO"},
406 "The height at which this UTXO was mined"},
408 "Indicate whether the UTXO is a coinbase"},
410 "This UTXO's public key"},
412 "Signature of the proofid with this UTXO's private "
413 "key (base64 encoded)"},
438 result.
pushKV(
"payoutscript", payoutScriptObj);
448 const COutPoint &utxo = s.getStake().getUTXO();
450 stake.
pushKV(
"txid", utxo.GetTxId().ToString());
451 stake.
pushKV(
"vout", uint64_t(utxo.GetN()));
452 stake.
pushKV(
"amount", s.getStake().getAmount());
453 stake.
pushKV(
"height", uint64_t(s.getStake().getHeight()));
454 stake.
pushKV(
"iscoinbase", s.getStake().isCoinbase());
455 stake.
pushKV(
"pubkey",
HexStr(s.getStake().getPubkey()));
463 result.
pushKV(
"stakes", stakes);
472 "delegateavalancheproof",
473 "Delegate the avalanche proof to another public key.\n",
476 "The limited id of the proof to be delegated."},
478 "The private key in base58-encoding. Must match the proof master "
479 "public key or the upper level parent delegation public key if "
482 "The public key to delegate the proof to."},
484 "A string that is the serialized, hex-encoded delegation for the "
485 "proof and which is a parent for the delegation to build."},
488 "A string that is a serialized, hex-encoded delegation."},
491 "\"<limitedproofid>\" \"<privkey>\" \"<pubkey>\"") +
493 "\"<limitedproofid>\" \"<privkey>\" \"<pubkey>\"")},
497 ParseHashV(request.params[0],
"limitedproofid")};
502 "The private key is invalid");
507 std::unique_ptr<avalanche::DelegationBuilder> dgb;
508 if (request.params.size() >= 4 && !request.params[3].isNull()) {
517 "The delegation does not match the proof");
523 "The private key does not match the delegation");
526 dgb = std::make_unique<avalanche::DelegationBuilder>(dg);
528 dgb = std::make_unique<avalanche::DelegationBuilder>(
532 if (!dgb->addLevel(privkey, pubkey)) {
534 "Unable to build the delegation");
546 "decodeavalanchedelegation",
547 "Convert a serialized, hex-encoded avalanche proof delegation into "
549 "The validity of the delegation is not verified.\n",
552 "The delegation hex string"},
560 "The public key the proof is delegated to."},
562 "The delegated proof master public key."},
564 "The identifier of this delegation."},
566 "A delegated proof data hash excluding the master key."},
568 "A hash of the delegated proof limitedid and master key."},
570 "The number of delegation levels."},
580 "The index of this delegation level."},
582 "This delegated public key for this level"},
584 "Signature of this delegation level (base64 "
590 "\"<hex delegation>\"") +
592 "\"<hex delegation>\"")},
598 delegation, request.params[0].get_str(), error)) {
606 result.
pushKV(
"limitedid",
611 result.
pushKV(
"depth", uint64_t(levels.size()));
614 for (
auto &level : levels) {
620 result.
pushKV(
"levels", levelsArray);
630 "Returns an object containing various state info regarding avalanche "
639 "Whether the node is ready to start polling and voting."},
642 "Only available if -avaproof has been supplied to the node",
645 "Whether the node local proof has been locally verified "
648 "The proof verification status. Only available if the "
649 "\"verified\" flag is false."},
651 "The node local proof id."},
653 "The node local limited proof id."},
655 "The node local proof master public key."},
657 "The node local proof payout address. This might be "
658 "omitted if the payout script is not one of P2PK, P2PKH "
659 "or P2SH, in which case decodeavalancheproof can be used "
660 "to get more details."},
662 "The node local proof staked amount."},
669 "The number of valid avalanche proofs we know exist "
670 "(including this node's local proof if applicable)."},
672 "The number of avalanche proofs with at least one node "
673 "we are connected to (including this node's local proof "
676 "The number of avalanche proofs with no node attached."},
678 "The number of known avalanche proofs that have been "
679 "finalized by avalanche."},
681 "The number of known avalanche proofs that conflict with "
684 "The number of known avalanche proofs that have immature "
687 "The total staked amount over all the valid proofs in " +
689 " (including this node's local proof if "
692 "The total staked amount over all the connected proofs "
695 " (including this node's local proof if "
698 "The total staked amount over all the dangling proofs "
701 " (including this node's local proof if "
704 "The total staked amount over all the immature proofs "
707 " (including this node's local proof if "
710 "The number of avalanche nodes we are connected to "
711 "(including this node if a local proof is set)."},
713 "The number of avalanche nodes associated with an "
714 "avalanche proof (including this node if a local proof "
717 "The number of avalanche nodes pending for a proof."},
731 auto localProof =
avalanche.getLocalProof();
732 if (localProof !=
nullptr) {
734 const bool verified =
avalanche.withPeerManager(
739 local.
pushKV(
"verified", verified);
740 const bool sharing =
avalanche.canShareLocalProof();
743 avalanche.getLocalProofRegistrationState();
746 local.
pushKV(
"verification_status",
748 ? (sharing ?
"pending verification"
749 :
"pending inbound connections")
752 local.
pushKV(
"proofid", localProof->getId().ToString());
753 local.
pushKV(
"limited_proofid",
754 localProof->getLimitedId().ToString());
755 local.
pushKV(
"master",
HexStr(localProof->getMaster()));
759 local.
pushKV(
"payout_address",
762 local.
pushKV(
"stake_amount", localProof->getStakedAmount());
763 ret.
pushKV(
"local", local);
769 uint64_t proofCount{0};
770 uint64_t connectedProofCount{0};
771 uint64_t finalizedProofCount{0};
772 uint64_t connectedNodeCount{0};
779 const bool isLocalProof =
781 peer.
proof->getId() == localProof->getId();
784 const Amount proofStake = peer.
proof->getStakedAmount();
786 totalStakes += proofStake;
789 ++finalizedProofCount;
793 ++connectedProofCount;
794 connectedStakes += proofStake;
797 connectedNodeCount += peer.
node_count + isLocalProof;
803 immatureStakes += proof->getStakedAmount();
806 network.
pushKV(
"proof_count", proofCount);
807 network.
pushKV(
"connected_proof_count", connectedProofCount);
808 network.
pushKV(
"dangling_proof_count",
809 proofCount - connectedProofCount);
811 network.
pushKV(
"finalized_proof_count", finalizedProofCount);
813 "conflicting_proof_count",
816 "immature_proof_count",
819 network.
pushKV(
"total_stake_amount", totalStakes);
820 network.
pushKV(
"connected_stake_amount", connectedStakes);
821 network.
pushKV(
"dangling_stake_amount",
822 totalStakes - connectedStakes);
823 network.
pushKV(
"immature_stake_amount", immatureStakes);
826 network.
pushKV(
"node_count", connectedNodeCount + pendingNodes);
827 network.
pushKV(
"connected_node_count", connectedNodeCount);
828 network.
pushKV(
"pending_node_count", pendingNodes);
830 ret.
pushKV(
"network", network);
840 "getavalanchepeerinfo",
841 "Returns data about an avalanche peer as a json array of objects. If "
842 "no proofid is provided, returns data about all the peers.\n",
845 "The hex encoded avalanche proof identifier."},
857 "The avalanche internal peer identifier"},
859 "The avalanche proof id used by this peer"},
861 "The avalanche proof used by this peer"},
863 "The number of nodes for this peer"},
869 "Node id, as returned by getpeerinfo"},
887 obj.
pushKV(
"avalanche_peerid", uint64_t(peer.peerid));
888 obj.
pushKV(
"proofid", peer.getProofId().ToString());
889 obj.
pushKV(
"proof", peer.proof->ToHex());
896 obj.
pushKV(
"nodecount", uint64_t(peer.node_count));
897 obj.
pushKV(
"node_list", nodes);
906 if (!request.params[0].isNull()) {
907 const avalanche::ProofId proofid =
908 avalanche::ProofId::fromHex(
909 request.params[0].get_str());
910 if (!pm.isBoundToPeer(proofid)) {
911 throw JSONRPCError(RPC_INVALID_PARAMETER,
912 "Proofid not found");
916 ret.push_back(peerToUniv(pm, peer));
936 "getavalancheproofs",
937 "Returns an object containing all tracked proofids.\n",
949 "Avalanche proof id"},
956 "Avalanche proof id"},
963 "Avalanche proof id"},
977 const std::string &key) {
999 "Return a list of possible staking reward winners based on the "
1004 "The previous block hash, hex encoded."},
1006 "Whether to recompute the staking reward winner if there is a "
1016 "The winning proof",
1019 "The winning proofid"},
1022 "Raw payout script in hex format"},
1026 "The required signatures"},
1059 config.GetChainParams().GetConsensus(), pprev)) {
1063 "Staking rewards are not activated for block %s\n",
1067 if (!request.params[1].isNull() && request.params[1].get_bool()) {
1070 avalanche.eraseStakingRewardWinner(blockhash);
1073 if (!
avalanche.computeStakingReward(pprev)) {
1076 strprintf(
"Unable to determine a staking reward winner "
1081 std::vector<std::pair<avalanche::ProofId, CScript>> winners;
1082 if (!
avalanche.getStakingRewardWinners(blockhash, winners)) {
1085 strprintf(
"Unable to retrieve the staking reward winner "
1091 for (
auto &winner : winners) {
1095 stakingRewardsObj.
pushKV(
"proofid", winner.first.GetHex());
1096 winnersArr.
push_back(stakingRewardsObj);
1107 "Return true if a staking reward winner exists based on the previous "
1111 "The previous block hash, hex encoded."},
1114 "Whether staking reward winner has been computed for "
1115 "previous block hash or not."},
1140 config.GetChainParams().GetConsensus(), pprev)) {
1144 "Staking rewards are not activated for block %s\n",
1148 std::vector<std::pair<avalanche::ProofId, CScript>> winners;
1149 if (!
avalanche.getStakingRewardWinners(blockhash, winners)) {
1152 return winners.size() > 0;
1160 "Set the staking reward winner for the given previous block hash.\n",
1163 "The previous block hash, hex encoded."},
1165 "The payout script for the staking reward, hex encoded."},
1167 "Append to the list of possible winners instead of replacing."},
1170 "Whether the payout script was set or not"},
1172 HelpExampleCli(
"setstakingreward",
"<blockhash> <payout script>") +
1173 HelpExampleRpc(
"setstakingreward",
"<blockhash> <payout script>")},
1196 config.GetChainParams().GetConsensus(), pprev)) {
1200 "Staking rewards are not activated for block %s\n",
1204 const std::vector<uint8_t> data =
1205 ParseHex(request.params[1].get_str());
1206 CScript payoutScript(data.begin(), data.end());
1208 std::vector<CScript> payoutScripts;
1210 if (!request.params[2].isNull() && request.params[2].get_bool()) {
1214 avalanche.getStakingRewardWinners(blockhash, payoutScripts);
1217 if (std::find(payoutScripts.begin(), payoutScripts.end(),
1218 payoutScript) != payoutScripts.end()) {
1222 "Staking rewards winner is already set for block %s\n",
1226 payoutScripts.push_back(std::move(payoutScript));
1231 avalanche.setStakingRewardWinners(pprev, payoutScripts);
1240 "Get the list of remote proofs for the given node id.\n",
1243 "The node identifier."},
1255 "The hex encoded proof identifier."},
1257 "Whether the node has the proof."},
1259 "The last time this proof status was updated."},
1270 const NodeId nodeid = request.params[0].getInt<int64_t>();
1271 auto remoteProofs =
avalanche.withPeerManager(
1278 for (
const auto &remoteProof : remoteProofs) {
1280 obj.
pushKV(
"proofid", remoteProof.proofid.ToString());
1281 obj.
pushKV(
"present", remoteProof.present);
1282 obj.
pushKV(
"last_update", remoteProof.lastUpdate.count());
1294 "getrawavalancheproof",
1295 "Lookup for a known avalanche proof by id.\n",
1298 "The hex encoded avalanche proof identifier."},
1306 "The hex encoded proof matching the identifier."},
1308 "Whether the proof has immature utxos."},
1310 "Whether the proof is bound to an avalanche peer."},
1312 "Whether the proof has a conflicting UTXO with an avalanche "
1315 "Whether the proof is finalized by vote."},
1328 bool isImmature =
false;
1329 bool isBoundToPeer =
false;
1330 bool conflicting =
false;
1331 bool finalized =
false;
1353 ret.
pushKV(
"immature", isImmature);
1354 ret.
pushKV(
"boundToPeer", isBoundToPeer);
1355 ret.
pushKV(
"conflicting", conflicting);
1356 ret.
pushKV(
"finalized", finalized);
1365 "invalidateavalancheproof",
1366 "Reject a known avalanche proof by id.\n",
1369 "The hex encoded avalanche proof identifier."},
1388 throw JSONRPCError(RPC_INVALID_PARAMETER,
1395 throw JSONRPCError(RPC_INTERNAL_ERROR,
1396 "Failed to reject the proof");
1402 if (
avalanche.isRecentlyFinalized(proofid)) {
1418 "Check if a block has been finalized by avalanche votes.\n",
1421 "The hash of the block."},
1424 "Whether the block has been finalized by avalanche votes."},
1434 "Avalanche is not ready to poll yet.");
1460 "isfinaltransaction",
1461 "Check if a transaction has been finalized by avalanche votes.\n",
1464 "The id of the transaction."},
1466 "The block in which to look for the transaction"},
1470 "Whether the transaction has been finalized by avalanche votes."},
1483 if (!request.params[1].isNull()) {
1495 bool f_txindex_ready =
false;
1497 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
1502 pindex, &mempool, txid, hash_block, chainman.
m_blockman);
1506 "Avalanche is not ready to poll yet.");
1513 return !pindex->nStatus.hasData())) {
1515 "Block data not downloaded yet.");
1517 errmsg =
"No such transaction found in the provided block.";
1519 errmsg =
"No such transaction. Use -txindex or provide a "
1520 "block hash to enable blockchain transaction "
1522 }
else if (!f_txindex_ready) {
1523 errmsg =
"No such transaction. Blockchain transactions are "
1524 "still in the process of being indexed.";
1526 errmsg =
"No such mempool or blockchain transaction.";
1549 return !
node.mempool->exists(txid) &&
1558 "reconsideravalancheproof",
1559 "Reconsider a known avalanche proof.\n",
1562 "The hex encoded avalanche proof."},
1567 "Whether the proof has been successfully registered.",
1588 pm.clearAllInvalid();
1613 "sendavalancheproof",
1614 "Broadcast an avalanche proof.\n",
1617 "The avalanche proof to broadcast."},
1620 "Whether the proof was sent successfully or not."},
1652 node.peerman->RelayProof(proofid);
1662 "verifyavalancheproof",
1663 "Verify an avalanche proof is valid and return the error otherwise.\n",
1666 "Proof to verify."},
1669 "Whether the proof is valid or not."},
1676 request.params[0].get_str());
1685 "verifyavalanchedelegation",
1686 "Verify an avalanche delegation is valid and return the error "
1690 "The avalanche proof delegation to verify."},
1693 "Whether the delegation is valid or not."},
1711 "Add or remove a proofid from the flaky list. This means that an "
1712 "additional staking reward winner will be accepted if this proof is "
1713 "the selected one.\n",
1716 "The avalanche proof id."},
1718 "Whether to add (true) or remove (false) the proof from the flaky "
1722 "Whether the addition/removal is successful."},
1731 const auto proofid =
1733 const bool addNotRemove = request.params[1].get_bool();
1738 return pm.setFlaky(proofid);
1747 return avalanche.computeStakingReward(pprev);
1757 "List the flaky proofs (set via setflakyproof).\n",
1769 "The hex encoded proof identifier."},
1771 "The proof stake amount, only present if the proof is "
1775 "The proof payout script, only present if the proof is "
1780 "Raw payout script in hex format"},
1784 "The required signatures"},
1804 avalanche.withPeerManager([&flakyProofs](
1810 const auto proof = pm.
getProof(proofid);
1812 flakyProof.
pushKV(
"staked_amount",
1813 proof->getStakedAmount());
1817 flakyProof.
pushKV(
"payout", payout);
1830 "getavailabilityscore",
1831 "Return the node availability score.\n",
1836 "The node availability score (if any)."},
1844 const NodeId nodeid(request.params[0].getInt<int64_t>());
1859 "getstakecontendervote",
1860 "Return the stake contender avalanche vote.\n",
1863 "The prevblockhash used to compute the stake contender ID, hex "
1866 "The proofid used to compute the stake contender ID, hex "
1870 "The vote that would be returned if polled."},
1872 "<prevblockhash> <proofid>") +
1874 "<prevblockhash> <proofid>")},
1881 ParseHashV(request.params[0],
"prevblockhash"));
1886 return avalanche.getStakeContenderStatus(contenderId);
1893 "finalizetransaction",
1894 "Force finalize a mempool transaction. No attempt is made to poll for "
1895 "this transaction and this could cause the node to disagree with the "
1896 "network. This can fail if the transaction to be finalized would "
1897 "overflow the block size. Upon success it will be included in the "
1898 "block template.\n",
1901 "The id of the transaction to be finalized."},
1905 "The list of the successfully finalized txids if any (it can "
1906 "include ancestors of the target txid).",
1910 "The finalized transaction id.",
1923 auto entry = mempool.
GetIter(txid);
1926 "The transaction is not in the mempool.");
1932 "There is no active chain tip.");
1937 std::vector<TxId> finalizedTxids;
1938 if (!mempool.setAvalancheFinalized(**entry, chainman.
GetConsensus(),
1939 *tip, finalizedTxids)) {
1945 for (
TxId &finalizedTxid : finalizedTxids) {
1946 ret.
push_back(finalizedTxid.ToString());
1963 "removetransaction",
1964 "Remove a transaction and all its descendants from the mempool. If the "
1965 "transaction is final it is removed anyway. No attempt is made to poll "
1966 "for this transaction and this could cause the node to disagree with "
1970 "The id of the transaction to be removed."},
1974 "The list of the removed txids if any (it can include "
1975 "descendants of the target txid).",
1979 "The removed transaction id.",
1990 auto iter = mempool.
GetIter(txid);
1993 "The transaction is not in the mempool.");
2002 for (
auto &it : setDescendants) {
2003 ret.
push_back((*it)->GetSharedTx()->GetId().ToString());
2015 "getfinaltransactions",
2016 "Returns all finalized transactions that have not been included in a "
2017 "finalized block yet.",
2020 "True for a json object, false for an array of transaction ids"},
2046 const bool fVerbose =
2047 !request.params[0].
isNull() && request.params[0].get_bool();
2058 entryRef->GetTx().GetId().GetHex());
2110 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.