37 "Returns the key used to sign avalanche messages.\n",
51 const std::string keyHex = param.
get_str();
56 strprintf(
"Invalid public key: %s\n", keyHex));
65 auto localProof =
avalanche.getLocalProof();
66 if (localProof && localProof->getId() == 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) {
103 if (
node.avalanche) {
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>\"")},
141 const NodeId nodeid = request.params[0].
getInt<int64_t>();
151 if (key != proof->getMaster()) {
152 if (request.params.size() < 4 || request.params[3].isNull()) {
155 "The public key does not match the proof");
165 "The delegation does not match the proof");
171 "The public key does not match the delegation");
177 "The proof has conflicting utxos");
180 if (!
node.connman->ForNode(nodeid, [&](
CNode *pnode) {
181 LOCK(pnode->cs_avalanche_pubkey);
182 bool expected = false;
183 if (pnode->m_avalanche_enabled.compare_exchange_strong(
185 pnode->m_avalanche_pubkey = std::move(key);
191 strprintf(
"The node does not exist: %d", nodeid));
195 if (!pm.
addNode(nodeid, proofid)) {
208 "buildavalancheproof",
209 "Build a proof for avalanche's sybil resistance.\n",
212 "The proof's sequence"},
214 "A timestamp indicating when the proof expire"},
216 "The master private key in base58-encoding"},
221 "The stakes to be signed and associated private keys",
227 "A stake to be attached to this proof",
232 "The output number"},
236 "The height at which this UTXO was mined"},
239 "Indicate wether the UTXO is a coinbase"},
242 "private key in base58-encoding"},
251 "A string that is a serialized, hex-encoded proof data."},
253 "0 1234567800 \"<master>\" []")},
256 const uint64_t sequence = request.params[0].
getInt<int64_t>();
257 const int64_t expiration = request.params[1].getInt<int64_t>();
260 if (!masterKey.IsValid()) {
265 request.params[4].get_str(), config.GetChainParams());
269 "Invalid payout address");
276 for (
size_t i = 0; i < stakes.
size(); i++) {
293 "vout cannot be negative");
299 "height must be positive");
303 const COutPoint utxo(txid, nOut);
305 if (!stake.
exists(
"amount")) {
313 const bool iscoinbase =
320 "Invalid private key");
323 if (!pb.
addUTXO(utxo, amount, uint32_t(height), iscoinbase,
332 return proof->ToHex();
339 "decodeavalancheproof",
340 "Convert a serialized, hex-encoded proof, into JSON object. "
341 "The validity of the proof is not verified.\n",
344 "The proof hex string"},
352 "The proof's sequential number"},
354 "A timestamp indicating when the proof expires"},
357 "The proof signature (base64 encoded)"},
360 "The proof payout script",
364 "Raw payout script in hex format"},
368 "The required signatures"},
377 "A hash of the proof data excluding the master key."},
379 "A hash of the limitedid and master key."},
381 "The total staked amount of this proof in " +
393 "The transaction id"},
396 "The amount in this UTXO"},
398 "The height at which this UTXO was mined"},
400 "Indicate whether the UTXO is a coinbase"},
402 "This UTXO's public key"},
404 "Signature of the proofid with this UTXO's private "
405 "key (base64 encoded)"},
430 result.
pushKV(
"payoutscript", payoutScriptObj);
440 const COutPoint &utxo = s.getStake().getUTXO();
442 stake.
pushKV(
"txid", utxo.GetTxId().ToString());
443 stake.
pushKV(
"vout", uint64_t(utxo.GetN()));
444 stake.
pushKV(
"amount", s.getStake().getAmount());
445 stake.
pushKV(
"height", uint64_t(s.getStake().getHeight()));
446 stake.
pushKV(
"iscoinbase", s.getStake().isCoinbase());
447 stake.
pushKV(
"pubkey",
HexStr(s.getStake().getPubkey()));
455 result.
pushKV(
"stakes", stakes);
464 "delegateavalancheproof",
465 "Delegate the avalanche proof to another public key.\n",
468 "The limited id of the proof to be delegated."},
470 "The private key in base58-encoding. Must match the proof master "
471 "public key or the upper level parent delegation public key if "
474 "The public key to delegate the proof to."},
476 "A string that is the serialized, hex-encoded delegation for the "
477 "proof and which is a parent for the delegation to build."},
480 "A string that is a serialized, hex-encoded delegation."},
483 "\"<limitedproofid>\" \"<privkey>\" \"<pubkey>\"")},
487 ParseHashV(request.params[0],
"limitedproofid")};
492 "The private key is invalid");
497 std::unique_ptr<avalanche::DelegationBuilder> dgb;
498 if (request.params.size() >= 4 && !request.params[3].isNull()) {
507 "The delegation does not match the proof");
513 "The private key does not match the delegation");
516 dgb = std::make_unique<avalanche::DelegationBuilder>(dg);
518 dgb = std::make_unique<avalanche::DelegationBuilder>(
522 if (!dgb->addLevel(privkey, pubkey)) {
524 "Unable to build the delegation");
536 "decodeavalanchedelegation",
537 "Convert a serialized, hex-encoded avalanche proof delegation, into "
539 "The validity of the delegation is not verified.\n",
542 "The delegation hex string"},
550 "The public key the proof is delegated to."},
552 "The delegated proof master public key."},
554 "The identifier of this delegation."},
556 "A delegated proof data hash excluding the master key."},
558 "A hash of the delegated proof limitedid and master key."},
560 "The number of delegation levels."},
570 "The index of this delegation level."},
572 "This delegated public key for this level"},
574 "Signature of this delegation level (base64 "
580 "\"<hex delegation>\"") +
582 "\"<hex delegation>\"")},
588 delegation, request.params[0].get_str(),
error)) {
596 result.
pushKV(
"limitedid",
601 result.
pushKV(
"depth", uint64_t(levels.size()));
604 for (
auto &level : levels) {
610 result.
pushKV(
"levels", levelsArray);
620 "Returns an object containing various state info regarding avalanche "
629 "Whether the node is ready to start polling and voting."},
632 "Only available if -avaproof has been supplied to the node",
635 "Whether the node local proof has been locally verified "
638 "The proof verification status. Only available if the "
639 "\"verified\" flag is false."},
641 "The node local proof id."},
643 "The node local limited proof id."},
645 "The node local proof master public key."},
647 "The node local proof payout address. This might be "
648 "omitted if the payout script is not one of P2PK, P2PKH "
649 "or P2SH, in which case decodeavalancheproof can be used "
650 "to get more details."},
652 "The node local proof staked amount."},
659 "The number of valid avalanche proofs we know exist "
660 "(including this node's local proof if applicable)."},
662 "The number of avalanche proofs with at least one node "
663 "we are connected to (including this node's local proof "
666 "The number of avalanche proofs with no node attached."},
668 "The number of known avalanche proofs that have been "
669 "finalized by avalanche."},
671 "The number of known avalanche proofs that conflict with "
674 "The number of known avalanche proofs that have immature "
677 "The total staked amount over all the valid proofs in " +
679 " (including this node's local proof if "
682 "The total staked amount over all the connected proofs "
685 " (including this node's local proof if "
688 "The total staked amount over all the dangling proofs "
691 " (including this node's local proof if "
694 "The total staked amount over all the immature proofs "
697 " (including this node's local proof if "
700 "The number of avalanche nodes we are connected to "
701 "(including this node if a local proof is set)."},
703 "The number of avalanche nodes associated with an "
704 "avalanche proof (including this node if a local proof "
707 "The number of avalanche nodes pending for a proof."},
721 auto localProof =
avalanche.getLocalProof();
722 if (localProof !=
nullptr) {
724 const bool verified =
avalanche.withPeerManager(
729 local.
pushKV(
"verified", verified);
730 const bool sharing =
avalanche.canShareLocalProof();
733 avalanche.getLocalProofRegistrationState();
736 local.
pushKV(
"verification_status",
738 ? (sharing ?
"pending verification"
739 :
"pending inbound connections")
742 local.
pushKV(
"proofid", localProof->getId().ToString());
743 local.
pushKV(
"limited_proofid",
744 localProof->getLimitedId().ToString());
745 local.
pushKV(
"master",
HexStr(localProof->getMaster()));
749 local.
pushKV(
"payout_address",
752 local.
pushKV(
"stake_amount", localProof->getStakedAmount());
753 ret.
pushKV(
"local", local);
759 uint64_t proofCount{0};
760 uint64_t connectedProofCount{0};
761 uint64_t finalizedProofCount{0};
762 uint64_t connectedNodeCount{0};
769 const bool isLocalProof =
771 peer.
proof->getId() == localProof->getId();
774 const Amount proofStake = peer.
proof->getStakedAmount();
776 totalStakes += proofStake;
779 ++finalizedProofCount;
783 ++connectedProofCount;
784 connectedStakes += proofStake;
787 connectedNodeCount += peer.
node_count + isLocalProof;
793 immatureStakes += proof->getStakedAmount();
796 network.
pushKV(
"proof_count", proofCount);
797 network.
pushKV(
"connected_proof_count", connectedProofCount);
798 network.
pushKV(
"dangling_proof_count",
799 proofCount - connectedProofCount);
801 network.
pushKV(
"finalized_proof_count", finalizedProofCount);
803 "conflicting_proof_count",
806 "immature_proof_count",
809 network.
pushKV(
"total_stake_amount", totalStakes);
810 network.
pushKV(
"connected_stake_amount", connectedStakes);
811 network.
pushKV(
"dangling_stake_amount",
812 totalStakes - connectedStakes);
813 network.
pushKV(
"immature_stake_amount", immatureStakes);
816 network.
pushKV(
"node_count", connectedNodeCount + pendingNodes);
817 network.
pushKV(
"connected_node_count", connectedNodeCount);
818 network.
pushKV(
"pending_node_count", pendingNodes);
820 ret.
pushKV(
"network", network);
830 "getavalanchepeerinfo",
831 "Returns data about an avalanche peer as a json array of objects. If "
832 "no proofid is provided, returns data about all the peers.\n",
835 "The hex encoded avalanche proof identifier."},
847 "The avalanche internal peer identifier"},
849 "DEPRECATED: The agreggated availability score of this "
850 "peer's nodes. This score is no longer computed starting "
851 "with version 0.30.12 and is always 0. This field is only "
852 "returned if the -deprecatedrpc=peer_availability_score "
853 "option is enabled."},
855 "The avalanche proof id used by this peer"},
857 "The avalanche proof used by this peer"},
859 "The number of nodes for this peer"},
865 "Node id, as returned by getpeerinfo"},
884 obj.
pushKV(
"avalanche_peerid", uint64_t(peer.peerid));
886 "peer_availability_score")) {
887 obj.
pushKV(
"availability_score", 0);
889 obj.
pushKV(
"proofid", peer.getProofId().ToString());
890 obj.
pushKV(
"proof", peer.proof->ToHex());
897 obj.
pushKV(
"nodecount", uint64_t(peer.node_count));
898 obj.
pushKV(
"node_list", nodes);
907 if (!request.params[0].isNull()) {
908 const avalanche::ProofId proofid =
909 avalanche::ProofId::fromHex(
910 request.params[0].get_str());
911 if (!pm.isBoundToPeer(proofid)) {
912 throw JSONRPCError(RPC_INVALID_PARAMETER,
913 "Proofid not found");
917 ret.push_back(peerToUniv(pm, peer));
937 "getavalancheproofs",
938 "Returns an object containing all tracked proofids.\n",
950 "Avalanche proof id"},
957 "Avalanche proof id"},
964 "Avalanche proof id"},
978 const std::string &key) {
1000 "Return a list of possible staking reward winners based on the "
1005 "The previous block hash, hex encoded."},
1007 "Whether to recompute the staking reward winner if there is a "
1017 "The winning proof",
1020 "The winning proofid"},
1023 "Raw payout script in hex format"},
1027 "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."},
1139 config.GetChainParams().GetConsensus(), pprev)) {
1143 "Staking rewards are not activated for block %s\n",
1147 std::vector<std::pair<avalanche::ProofId, CScript>> winners;
1148 if (!
avalanche.getStakingRewardWinners(blockhash, winners)) {
1151 return winners.size() > 0;
1159 "Set the staking reward winner for the given previous block hash.\n",
1162 "The previous block hash, hex encoded."},
1164 "The payout script for the staking reward, hex encoded."},
1166 "Append to the list of possible winners instead of replacing."},
1169 "Whether the payout script was set or not"},
1171 HelpExampleRpc(
"setstakingreward",
"<blockhash> <payout script>")},
1194 config.GetChainParams().GetConsensus(), pprev)) {
1198 "Staking rewards are not activated for block %s\n",
1202 const std::vector<uint8_t> data =
1203 ParseHex(request.params[1].get_str());
1204 CScript payoutScript(data.begin(), data.end());
1206 std::vector<CScript> payoutScripts;
1208 if (!request.params[2].isNull() && request.params[2].get_bool()) {
1212 avalanche.getStakingRewardWinners(blockhash, payoutScripts);
1215 if (std::find(payoutScripts.begin(), payoutScripts.end(),
1216 payoutScript) != payoutScripts.end()) {
1220 "Staking rewards winner is already set for block %s\n",
1224 payoutScripts.push_back(std::move(payoutScript));
1229 avalanche.setStakingRewardWinners(pprev, payoutScripts);
1238 "Get the list of remote proofs for the given node id.\n",
1241 "The node identifier."},
1253 "The hex encoded proof identifier."},
1255 "Whether the node has the proof."},
1257 "The last time this proof status was updated."},
1267 const NodeId nodeid = request.params[0].getInt<int64_t>();
1268 auto remoteProofs =
avalanche.withPeerManager(
1275 for (
const auto &remoteProof : remoteProofs) {
1277 obj.
pushKV(
"proofid", remoteProof.proofid.ToString());
1278 obj.
pushKV(
"present", remoteProof.present);
1279 obj.
pushKV(
"last_update", remoteProof.lastUpdate.count());
1291 "getrawavalancheproof",
1292 "Lookup for a known avalanche proof by id.\n",
1295 "The hex encoded avalanche proof identifier."},
1303 "The hex encoded proof matching the identifier."},
1305 "Whether the proof has immature utxos."},
1307 "Whether the proof is bound to an avalanche peer."},
1309 "Whether the proof has a conflicting UTXO with an avalanche "
1312 "Whether the proof is finalized by vote."},
1324 bool isImmature =
false;
1325 bool isBoundToPeer =
false;
1326 bool conflicting =
false;
1327 bool finalized =
false;
1349 ret.
pushKV(
"immature", isImmature);
1350 ret.
pushKV(
"boundToPeer", isBoundToPeer);
1351 ret.
pushKV(
"conflicting", conflicting);
1352 ret.
pushKV(
"finalized", finalized);
1361 "invalidateavalancheproof",
1362 "Reject a known avalanche proof by id.\n",
1365 "The hex encoded avalanche proof identifier."},
1383 throw JSONRPCError(RPC_INVALID_PARAMETER,
1390 throw JSONRPCError(RPC_INTERNAL_ERROR,
1391 "Failed to reject the proof");
1397 if (
avalanche.isRecentlyFinalized(proofid)) {
1413 "Check if a block has been finalized by avalanche votes.\n",
1416 "The hash of the block."},
1419 "Whether the block has been finalized by avalanche votes."},
1429 "Avalanche is not ready to poll yet.");
1455 "isfinaltransaction",
1456 "Check if a transaction has been finalized by avalanche votes.\n",
1459 "The id of the transaction."},
1461 "The block in which to look for the transaction"},
1465 "Whether the transaction has been finalized by avalanche votes."},
1478 if (!request.params[1].isNull()) {
1490 bool f_txindex_ready =
false;
1492 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
1497 pindex, &mempool, txid, hash_block, chainman.
m_blockman);
1501 "Avalanche is not ready to poll yet.");
1508 return !pindex->nStatus.hasData())) {
1510 "Block data not downloaded yet.");
1512 errmsg =
"No such transaction found in the provided block.";
1514 errmsg =
"No such transaction. Use -txindex or provide a "
1515 "block hash to enable blockchain transaction "
1517 }
else if (!f_txindex_ready) {
1518 errmsg =
"No such transaction. Blockchain transactions are "
1519 "still in the process of being indexed.";
1521 errmsg =
"No such mempool or blockchain transaction.";
1542 return !
node.mempool->exists(txid) &&
1551 "reconsideravalancheproof",
1552 "Reconsider a known avalanche proof.\n",
1555 "The hex encoded avalanche proof."},
1560 "Whether the proof has been successfully registered.",
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."},
1643 node.peerman->RelayProof(proofid);
1653 "verifyavalancheproof",
1654 "Verify an avalanche proof is valid and return the error otherwise.\n",
1657 "Proof to verify."},
1660 "Whether the proof is valid or not."},
1666 request.params[0].get_str());
1675 "verifyavalanchedelegation",
1676 "Verify an avalanche delegation is valid and return the error "
1680 "The avalanche proof delegation to verify."},
1683 "Whether the delegation is valid or not."},
1700 "Add or remove a proofid from the flaky list. This means that an "
1701 "additional staking reward winner will be accepted if this proof is "
1702 "the selected one.\n",
1705 "The avalanche proof id."},
1707 "Whether to add (true) or remove (false) the proof from the flaky "
1711 "Whether the addition/removal is successful."},
1719 const auto proofid =
1721 const bool addNotRemove = request.params[1].get_bool();
1726 return pm.setFlaky(proofid);
1735 return avalanche.computeStakingReward(pprev);
1745 "List the flaky proofs (set via setflakyproof).\n",
1757 "The hex encoded proof identifier."},
1759 "The proof stake amount, only present if the proof is "
1763 "The proof payout script, only present if the proof is "
1768 "Raw payout script in hex format"},
1772 "The required signatures"},
1791 avalanche.withPeerManager([&flakyProofs](
1797 const auto proof = pm.
getProof(proofid);
1799 flakyProof.
pushKV(
"staked_amount",
1800 proof->getStakedAmount());
1804 flakyProof.
pushKV(
"payout", payout);
1817 "getavailabilityscore",
1818 "Return the node availability score.\n",
1823 "The node availability score (if any)."},
1830 const NodeId nodeid(request.params[0].getInt<int64_t>());
1845 "getstakecontendervote",
1846 "Return the stake contender avalanche vote.\n",
1849 "The prevblockhash used to compute the stake contender ID, hex "
1852 "The proofid used to compute the stake contender ID, hex "
1856 "The vote that would be returned if polled."},
1858 "<prevblockhash> <proofid>")},
1865 ParseHashV(request.params[0],
"prevblockhash"));
1870 return avalanche.getStakeContenderStatus(contenderId);
1908 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 getavailabilityscore()
static RPCHelpMan getstakecontendervote()
static RPCHelpMan verifyavalanchedelegation()
static RPCHelpMan setflakyproof()
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
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 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 ...
bool isAvalancheFinalized(const TxId &txid) const
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
SnapshotCompletionResult MaybeCompleteSnapshotValidation(std::function< void(bilingual_str)> shutdown_fnc=[](bilingual_str msg) { AbortNode(msg.original, msg);}) 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...
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.
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 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
bool addNode(NodeId nodeid, const ProofId &proofid)
Node API.
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)
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)
bool error(const char *fmt, const Args &...args)
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
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.
bool IsDeprecatedRPCEnabled(const ArgsManager &args, const std::string &method)
ChainstateManager & EnsureAnyChainman(const std::any &context)
NodeContext & EnsureAnyNodeContext(const std::any &context)
CTxMemPool & EnsureMemPool(const NodeContext &node)
ChainstateManager & EnsureChainman(const NodeContext &node)
ArgsManager & EnsureArgsman(const NodeContext &node)
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.
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.
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)
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.
static const int PROTOCOL_VERSION
network protocol versioning