10#include <chainparams.h>
62 const CChain &active_chain) {
65 if (height >= 0 && height < active_chain.
Height()) {
66 pb = active_chain[height];
69 if (pb ==
nullptr || !pb->
nHeight) {
87 int64_t maxTime = minTime;
88 for (
int i = 0; i < lookup; i++) {
91 minTime = std::min(time, minTime);
92 maxTime = std::max(time, maxTime);
97 if (minTime == maxTime) {
102 int64_t timeDiff = maxTime - minTime;
110 "Returns the estimated network hashes per second based on the last n "
112 "Pass in [blocks] to override # of blocks, -1 specifies since last "
113 "difficulty change.\n"
114 "Pass in [height] to estimate the network speed at the time when a "
115 "certain block was found.\n",
118 "The number of blocks, or -1 for blocks since last difficulty "
121 "To estimate at the time of the given height."},
131 self.
Arg<
int>(
"height"),
139 uint64_t &max_tries,
BlockHash &block_hash) {
145 while (max_tries > 0 &&
146 block.
nNonce < std::numeric_limits<uint32_t>::max() &&
155 if (block.
nNonce == std::numeric_limits<uint32_t>::max()) {
159 std::shared_ptr<const CBlock> shared_pblock =
160 std::make_shared<const CBlock>(block);
166 "ProcessNewBlock, block not accepted");
176 const CScript &coinbase_script,
int nGenerate,
177 uint64_t nMaxTries) {
180 std::unique_ptr<CBlockTemplate> pblocktemplate(
183 .CreateNewBlock(coinbase_script));
185 if (!pblocktemplate.get()) {
189 CBlock *pblock = &pblocktemplate->block;
197 if (!block_hash.
IsNull()) {
210 CScript &script, std::string &
error) {
213 Parse(descriptor, key_provider,
error,
false);
215 if (desc->IsRange()) {
217 "Ranged descriptor not accepted. Maybe pass "
218 "through deriveaddresses first?");
222 std::vector<CScript> scripts;
223 if (!desc->Expand(0, key_provider, scripts, provider)) {
226 strprintf(
"Cannot derive script without private keys"));
233 if (scripts.size() == 1) {
234 script = scripts.at(0);
237 script = scripts.at(1);
248 "generatetodescriptor",
249 "Mine blocks immediately to a specified descriptor (before the RPC "
253 "How many blocks are generated immediately."},
255 "The descriptor to send the newly generated bitcoin to."},
257 "How many iterations to try."},
261 "hashes of blocks generated",
269 const int num_blocks{self.
Arg<
int>(
"num_blocks")};
270 const auto max_tries{self.
Arg<uint64_t>(
"maxtries")};
272 CScript coinbase_script;
275 coinbase_script,
error)) {
284 coinbase_script, num_blocks, max_tries);
291 "has been replaced by the -generate cli option. Refer to "
292 "-help for more information.",
306 "Mine blocks immediately to a specified address before the "
307 "RPC call returns)\n",
310 "How many blocks are generated immediately."},
312 "The address to send the newly generated bitcoin to."},
314 "How many iterations to try."},
318 "hashes of blocks generated",
323 "\nGenerate 11 blocks to myaddress\n" +
325 "If you are using the " PACKAGE_NAME
" wallet, you can "
326 "get a new address to send the newly generated bitcoin to with:\n" +
330 const int num_blocks{request.params[0].
getInt<
int>()};
331 const uint64_t max_tries{request.params[2].isNull()
333 : request.params[2].getInt<int64_t>()};
336 request.params[1].get_str(), config.GetChainParams());
339 "Error: Invalid address");
349 coinbase_script, num_blocks, max_tries);
357 "Mine a block with a set of ordered transactions immediately to a "
358 "specified address or descriptor (before the RPC call returns)\n",
361 "The address or descriptor to send the newly generated bitcoin "
367 "An array of hex strings which are either txids or raw "
369 "Txids must reference transactions currently in the mempool.\n"
370 "All transactions must be valid and in valid order, otherwise "
371 "the block will be rejected.",
386 "\nGenerate a block to myaddress, with txs rawtx and "
389 R
"("myaddress" '["rawtx", "mempool_txid"]')")},
392 const auto address_or_descriptor = request.params[0].
get_str();
393 CScript coinbase_script;
396 const CChainParams &chainparams = config.GetChainParams();
400 const auto destination =
404 "Error: Invalid address or descriptor");
413 std::vector<CTransactionRef> txs;
414 const auto raw_txs_or_txids = request.params[1].get_array();
415 for (
size_t i = 0; i < raw_txs_or_txids.size(); i++) {
416 const auto str(raw_txs_or_txids[i].get_str());
421 const auto tx = mempool.
get(
TxId(hash));
425 strprintf(
"Transaction %s not in mempool.", str));
428 txs.emplace_back(tx);
435 strprintf(
"Transaction decode failed for %s", str));
445 std::unique_ptr<CBlockTemplate> blocktemplate(
447 node.avalanche.get()}
448 .CreateNewBlock(coinbase_script));
449 if (!blocktemplate) {
451 "Couldn't create new block");
453 block = blocktemplate->block;
459 block.
vtx.insert(block.
vtx.end(), txs.begin(), txs.end());
472 .withCheckMerkleRoot(
false))) {
474 strprintf(
"TestBlockValidity failed: %s",
501 "Returns a json object containing mining-related "
511 "The block size of the last assembled block (only present if "
512 "a block was ever assembled)"},
514 "The number of block transactions of the last assembled block "
515 "(only present if a block was ever assembled)"},
518 "The network hashes per second"},
521 "current network name (main, test, regtest)"},
523 "any network and blockchain warnings"},
537 if (BlockAssembler::m_last_block_size) {
538 obj.
pushKV(
"currentblocksize",
539 *BlockAssembler::m_last_block_size);
541 if (BlockAssembler::m_last_block_num_txs) {
542 obj.
pushKV(
"currentblocktx",
543 *BlockAssembler::m_last_block_num_txs);
546 obj.
pushKV(
"networkhashps",
548 obj.
pushKV(
"pooledtx", uint64_t(mempool.
size()));
549 obj.
pushKV(
"chain", config.GetChainParams().NetworkIDString());
560 "prioritisetransaction",
561 "Accepts the transaction into mined blocks at a higher "
562 "(or lower) priority\n",
565 "The transaction id."},
567 "API-Compatibility for previous API. Must be zero or null.\n"
568 " DEPRECATED. For forward compatibility "
569 "use named arguments and omit this parameter."},
571 "The fee value (in satoshis) to add (or subtract, if negative).\n"
572 " The fee is not actually paid, only the "
573 "algorithm for selecting transactions into a block\n"
574 " considers the transaction as it would "
575 "have paid a higher (or lower) fee."},
586 const auto dummy{self.
MaybeArg<
double>(1)};
587 Amount nAmount = request.params[2].getInt<int64_t>() *
SATOSHI;
589 if (dummy && *dummy != 0) {
592 "Priority is no longer supported, dummy argument to "
593 "prioritisetransaction must be 0.");
617 if (strRejectReason.empty()) {
620 return strRejectReason;
630 "If the request parameters include a 'mode' key, that is used to "
631 "explicitly select between the default 'template' request or a "
633 "It returns data needed to construct a block to work on.\n"
634 "For full specification, see BIPs 22, 23, 9, and 145:\n"
636 "https://github.com/bitcoin/bips/blob/master/"
637 "bip-0022.mediawiki\n"
639 "https://github.com/bitcoin/bips/blob/master/"
640 "bip-0023.mediawiki\n"
642 "https://github.com/bitcoin/bips/blob/master/"
643 "bip-0009.mediawiki#getblocktemplate_changes\n"
649 "Format of the template",
653 "This must be set to \"template\", \"proposal\" (see BIP "
664 "client side supported feature, 'longpoll', "
665 "'coinbasetxn', 'coinbasevalue', 'proposal', "
666 "'serverlist', 'workid'"},
673 RPCResult{
"If the proposal was accepted with mode=='proposal'",
675 RPCResult{
"If the proposal was not accepted with mode=='proposal'",
684 "The preferred block version"},
686 "The hash of current highest block"},
689 "contents of non-coinbase transactions that should be "
690 "included in the next block",
697 "transaction data encoded in hexadecimal "
700 "transaction id encoded in little-endian "
703 "hash encoded in little-endian hexadecimal"},
709 "transactions before this one (by 1-based "
710 "index in 'transactions' list) that must "
711 "be present in the final block if this one "
715 "difference in value between transaction inputs "
716 "and outputs (in satoshis); for coinbase "
717 "transactions, this is a negative Number of the "
718 "total collected block fees (ie, not including "
719 "the block subsidy); "
720 "if key is not present, fee is unknown and "
721 "clients MUST NOT assume there isn't one"},
723 "total sigChecks, as counted for purposes of "
724 "block limits; if key is not present, sigChecks "
725 "are unknown and clients MUST NOT assume it is "
731 "data that should be included in the coinbase's scriptSig "
737 "maximum allowable input to coinbase transaction, "
738 "including the generation award and transaction fees (in "
742 "information for coinbase transaction",
746 "information related to the coinbase miner fund."
747 "This will NOT be set if -simplegbt is enabled",
752 "List of valid addresses for the miner fund "
759 "The minimum value the miner fund output must "
765 "information related to the coinbase staking reward "
766 "output, only set if the -avalanchestakingrewards "
767 "option is enabled and if the node is able to "
768 "determine a winner. This will NOT be set if "
769 "-simplegbt is enabled",
773 "The proof payout script",
776 "Decoded payout script"},
778 "Raw payout script in hex format"},
780 "The output type (e.g. " +
783 "The required signatures"},
793 "The minimum value the staking reward output "
800 "The minimum timestamp appropriate for the next block "
801 "time, expressed in " +
805 "list of ways the block template may be changed",
808 "A way the block template may be changed, e.g. "
809 "'time', 'transactions', 'prevblock'"},
812 "A range of valid nonces"},
814 "limit of sigChecks in blocks"},
819 "compressed target of next block"},
821 "The height of the next block"},
824 "The real-time target parameters. Only present after the "
825 "Nov. 15, 2024 upgrade activated and if -enablertt is set",
829 "The time the preview block headers were received, "
832 ". Contains 4 values for headers at height N-2, "
833 "N-5, N-11 and N-17.",
836 "The time the block header was received, "
841 "The previous block compressed target"},
845 "The real-time target in compact format"},
849 "information related to the coinbase miner fund."
850 "This will ONLY be set if -simplegbt is enabled",
853 "The scriptpubkey for the miner fund output in "
856 "The minimum value the miner fund output must "
862 "information related to the coinbase staking reward "
863 "output, only set if the -avalanchestakingrewards "
864 "option is enabled and if the node is able to "
865 "determine a winner. This will ONLY be set if "
866 "-simplegbt is enabled",
869 "The scriptpubkey for the staking reward "
870 "output in hex format"},
872 "The minimum value the staking reward output must "
886 const CChainParams &chainparams = config.GetChainParams();
888 std::string strMode =
"template";
890 std::set<std::string> setClientRules;
893 if (!request.params[0].isNull()) {
896 if (modeval.
isStr()) {
898 }
else if (modeval.
isNull()) {
905 if (strMode ==
"proposal") {
907 if (!dataval.
isStr()) {
910 "Missing data String key for proposal");
916 "Block decode failed");
926 if (pindex->nStatus.isInvalid()) {
927 return "duplicate-invalid";
929 return "duplicate-inconclusive";
936 return "inconclusive-not-best-prevblk";
943 .withCheckMerkleRoot(
true));
948 if (strMode !=
"template") {
955 "Bitcoin is not connected!");
961 " is in initial sync and waiting for blocks...");
964 static unsigned int nTransactionsUpdatedLast;
974 std::chrono::steady_clock::time_point checktxtime;
975 unsigned int nTransactionsUpdatedLastLP;
979 std::string lpstr = lpval.
get_str();
982 ParseHashV(lpstr.substr(0, 64),
"longpollid");
983 nTransactionsUpdatedLastLP =
atoi64(lpstr.substr(64));
988 nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
992 const auto initialLongpollDelay = isRegtest ? 5s : 1min;
993 const auto newTxCheckLongpollDelay = isRegtest ? 1s : 10s;
999 std::chrono::steady_clock::now() + initialLongpollDelay;
1006 std::cv_status::timeout) {
1011 nTransactionsUpdatedLastLP) {
1014 checktxtime += newTxCheckLongpollDelay;
1043 static int64_t nStart;
1044 static std::unique_ptr<CBlockTemplate> pblocktemplate;
1045 if (pindexPrev != active_chain.
Tip() ||
1050 pindexPrev =
nullptr;
1059 CScript scriptDummy = CScript() <<
OP_TRUE;
1061 &mempool,
node.avalanche.get()}
1062 .CreateNewBlock(scriptDummy);
1063 if (!pblocktemplate) {
1068 pindexPrev = pindexPrevNew;
1073 CBlock *pblock = &pblocktemplate->block;
1076 int64_t adjustedTime =
1078 UpdateTime(pblock, chainparams, pindexPrev, adjustedTime);
1088 int index_in_template = 0;
1089 for (
const auto &it : pblock->
vtx) {
1090 const CTransaction &tx = *it;
1091 const TxId txId = tx.GetId();
1093 if (tx.IsCoinBase()) {
1094 index_in_template++;
1096 for (
const auto &o : pblock->
vtx[0]->vout) {
1097 coinbasevalue += o.nValue;
1107 entry.
pushKVEnd(
"hash", tx.GetHash().GetHex());
1110 pblocktemplate->entries[index_in_template].fees /
SATOSHI);
1112 pblocktemplate->entries[index_in_template].sigChecks;
1116 index_in_template++;
1119 const bool simplifyGbt = argsman.
GetBoolArg(
"-simplegbt",
false);
1126 const auto minerFundWhitelist =
1128 int64_t minerFundMinValue = 0;
1137 std::vector<CScript> stakingRewardsPayoutScripts;
1138 int64_t stakingRewardsAmount =
1140 if (
node.avalanche &&
1142 if (!
node.avalanche->getStakingRewardWinners(
1144 stakingRewardsPayoutScripts)) {
1145 stakingRewardsPayoutScripts.clear();
1151 if (!minerFundWhitelist.empty()) {
1152 minerFund.
pushKV(
"script",
1154 *minerFundWhitelist.begin())));
1155 minerFund.
pushKV(
"amount", minerFundMinValue);
1157 result.
pushKV(
"minerfund", minerFund);
1159 if (!stakingRewardsPayoutScripts.empty()) {
1162 "script",
HexStr(stakingRewardsPayoutScripts[0]));
1163 stakingRewards.
pushKV(
"amount", stakingRewardsAmount);
1164 result.
pushKV(
"stakingrewards", stakingRewards);
1169 for (
const auto &fundDestination : minerFundWhitelist) {
1174 minerFund.
pushKV(
"addresses", minerFundList);
1175 minerFund.
pushKV(
"minimumvalue", minerFundMinValue);
1177 coinbasetxn.
pushKV(
"minerfund", minerFund);
1179 if (!stakingRewardsPayoutScripts.empty()) {
1183 stakingRewardsPayoutScriptObj,
1185 stakingRewards.
pushKV(
"payoutscript",
1186 stakingRewardsPayoutScriptObj);
1187 stakingRewards.
pushKV(
"minimumvalue", stakingRewardsAmount);
1189 coinbasetxn.
pushKV(
"stakingrewards", stakingRewards);
1201 result.
pushKV(
"capabilities", aCaps);
1206 result.
pushKV(
"transactions", transactions);
1207 result.
pushKV(
"coinbaseaux", aux);
1208 result.
pushKV(
"coinbasetxn", coinbasetxn);
1209 result.
pushKV(
"coinbasevalue", int64_t(coinbasevalue /
SATOSHI));
1210 result.
pushKV(
"longpollid",
1212 ToString(nTransactionsUpdatedLast));
1216 result.
pushKV(
"mutable", aMutable);
1217 result.
pushKV(
"noncerange",
"00000000ffffffff");
1218 const uint64_t sigCheckLimit =
1220 result.
pushKV(
"sigchecklimit", sigCheckLimit);
1228 uint32_t nextTarget = pblock->
nBits;
1234 pindexPrev, adjustedTime, consensusParams);
1237 nextTarget = *rttTarget;
1242 std::vector<int64_t> prevHeaderReceivedTime(18, 0);
1243 for (
size_t i = 1; i < 18; i++) {
1244 if (!previousIndex) {
1248 prevHeaderReceivedTime[i] =
1250 previousIndex = previousIndex->
pprev;
1258 for (
size_t i : {2, 5, 11, 17}) {
1259 prevHeaderTimes.
push_back(prevHeaderReceivedTime[i]);
1262 rtt.
pushKV(
"prevheadertime", prevHeaderTimes);
1264 rtt.
pushKV(
"nodetime", adjustedTime);
1267 result.
pushKV(
"rtt", rtt);
1300 "Attempts to submit new block to network.\n"
1301 "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n",
1304 "the hex-encoded block data to submit"},
1306 "dummy value, for compatibility with BIP22. This value is "
1313 "According to BIP22"},
1319 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
1320 CBlock &block = *blockptr;
1321 if (!
DecodeHexBlk(block, request.params[0].get_str())) {
1323 "Block decode failed");
1326 if (block.
vtx.empty() || !block.
vtx[0]->IsCoinBase()) {
1328 "Block does not start with a coinbase");
1342 if (pindex->nStatus.isInvalid()) {
1343 return "duplicate-invalid";
1350 std::make_shared<submitblock_StateCatcher>(block.
GetHash());
1356 node.avalanche.get());
1358 if (!new_block && accepted) {
1363 return "inconclusive";
1377 "Decode the given hexdata as a header and submit it as a candidate "
1378 "chain tip if valid."
1379 "\nThrows when the header is invalid.\n",
1382 "the hex-encoded block header data"},
1392 "Block header decode failed");
1399 "Must submit previous header (" +
1422 "Estimates the approximate fee per kilobyte needed for a "
1456 for (
const auto &c : commands) {
static bool IsAxionEnabled(const Consensus::Params ¶ms, int32_t nHeight)
static constexpr Amount SATOSHI
double GetDifficulty(const CBlockIndex *blockindex)
Calculate the difficulty for a given block index.
@ SCRIPTS
Scripts & signatures ok.
const CChainParams & Params()
Return the currently selected parameters.
#define CHECK_NONFATAL(condition)
Identity function.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
bool IsValid(enum BlockValidity nUpTo=BlockValidity::TRANSACTIONS) const EXCLUSIVE_LOCKS_REQUIRED(
Check whether this block index entry is valid up to the passed validity level.
CBlockIndex * pprev
pointer to the index of the predecessor of this block
int64_t GetHeaderReceivedTime() const
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
int64_t GetBlockTime() const
int64_t GetMedianTimePast() const
BlockHash GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
An in-memory indexed chain of blocks.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
int Height() const
Return the maximal height in the chain.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const Consensus::Params & GetConsensus() const
bool MineBlocksOnDemand() const
Whether it is possible to mine blocks on demand (no retargeting)
size_t GetNodeCount(ConnectionDirection) const
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
A mutable version of CTransaction.
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 ...
CFeeRate estimateFee() const
CTransactionRef get(const TxId &txid) const
void PrioritiseTransaction(const TxId &txid, const Amount nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
unsigned long size() const
unsigned int GetTransactionsUpdated() const
Implement this to subscribe to events generated in validation.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
CChain m_chain
The current chain of blockheaders we consult and build on.
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...
const Config & GetConfig() const
bool IsInitialBlockDownload() const
Check whether we are doing an initial block download (synchronizing from disk or network)
bool ProcessNewBlock(const std::shared_ptr< const CBlock > &block, bool force_processing, bool min_pow_checked, bool *new_block, avalanche::Processor *const avalanche=nullptr) LOCKS_EXCLUDED(cs_main)
Process an incoming block.
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &block, bool min_pow_checked, BlockValidationState &state, const CBlockIndex **ppindex=nullptr, const std::optional< CCheckpointData > &test_checkpoints=std::nullopt) LOCKS_EXCLUDED(cs_main)
Process incoming block headers.
const Consensus::Params & GetConsensus() const
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
auto Arg(size_t i) const
Helper to get a required or default-valued request argument.
auto MaybeArg(size_t i) const
Helper to get an optional request argument.
std::string ToString() const
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const UniValue & get_obj() const
void pushKVEnd(std::string key, UniValue val)
void pushKV(std::string key, UniValue val)
std::string GetRejectReason() const
std::string ToString() const
256-bit unsigned big integer.
arith_uint256 & SetCompact(uint32_t nCompact, bool *pfNegative=nullptr, bool *pfOverflow=nullptr)
The "compact" format is a representation of a whole number N using an unsigned 32bit number similar t...
std::string GetHex() const
std::string GetHex() const
Generate a new block, without valid proof-of-work.
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void BlockChecked(const CBlock &block, const BlockValidationState &stateIn) override
Notifies listeners of a block validation result.
submitblock_StateCatcher(const uint256 &hashIn)
BlockValidationState state
static UniValue Parse(std::string_view raw)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
static const uint64_t DEFAULT_MAX_BLOCK_SIZE
Default setting for maximum allowed size for a block, in bytes.
uint64_t GetMaxBlockSigChecksCount(uint64_t maxBlockSize)
Compute the maximum number of sigchecks that can be contained in a block given the MAXIMUM block size...
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
bool ParseHashStr(const std::string &strHex, uint256 &result)
Parse a hex string into 256 bits.
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
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)
bool error(const char *fmt, const Args &...args)
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
Compute the Merkle root of the transactions in a block.
std::unordered_set< CTxDestination, TxDestinationHasher > GetMinerFundWhitelist(const Consensus::Params ¶ms)
Amount GetMinerFundAmount(const Consensus::Params ¶ms, const Amount &coinbaseValue, const CBlockIndex *pprev)
static RPCHelpMan estimatefee()
static UniValue GetNetworkHashPS(int lookup, int height, const CChain &active_chain)
Return average network hashes per second based on the last 'lookup' blocks, or from the last difficul...
static RPCHelpMan generateblock()
static RPCHelpMan generatetodescriptor()
static bool getScriptFromDescriptor(const std::string &descriptor, CScript &script, std::string &error)
static UniValue BIP22ValidationResult(const Config &config, const BlockValidationState &state)
static RPCHelpMan getnetworkhashps()
static RPCHelpMan submitblock()
static RPCHelpMan getblocktemplate()
static RPCHelpMan generate()
static RPCHelpMan submitheader()
static RPCHelpMan prioritisetransaction()
static bool GenerateBlock(ChainstateManager &chainman, avalanche::Processor *const avalanche, CBlock &block, uint64_t &max_tries, BlockHash &block_hash)
static UniValue generateBlocks(ChainstateManager &chainman, const CTxMemPool &mempool, avalanche::Processor *const avalanche, const CScript &coinbase_script, int nGenerate, uint64_t nMaxTries)
static RPCHelpMan getmininginfo()
static RPCHelpMan generatetoaddress()
void RegisterMiningRPCCommands(CRPCTable &t)
static const uint64_t DEFAULT_MAX_TRIES
Default max iterations to try in RPC generatetodescriptor, generatetoaddress, and generateblock.
int64_t UpdateTime(CBlockHeader *pblock, const CChainParams &chainParams, const CBlockIndex *pindexPrev, int64_t adjustedTime)
bool CheckProofOfWork(const BlockHash &hash, uint32_t nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
static CTransactionRef MakeTransactionRef()
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_OUT_OF_MEMORY
Ran out of memory during operation.
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors Bitcoin is not connected.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_VERIFY_ERROR
General error during transaction or block submission.
@ RPC_CLIENT_IN_INITIAL_DOWNLOAD
Still downloading initial blocks.
@ 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)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
std::string GetAllOutputTypes()
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
std::optional< uint32_t > GetNextRTTWorkRequired(const CBlockIndex *pprev, int64_t now, const Consensus::Params &consensusParams)
Compute the real time block hash target given the previous block parameters.
bool isRTTEnabled(const Consensus::Params ¶ms, const CBlockIndex *pprev)
Whether the RTT feature is enabled.
bool IsRPCRunning()
Query whether RPC is running.
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)
ArgsManager & EnsureArgsman(const NodeContext &node)
CConnman & EnsureConnman(const NodeContext &node)
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
bool IsStakingRewardsActivated(const Consensus::Params ¶ms, const CBlockIndex *pprev)
Amount GetStakingRewardsAmount(const Amount &coinbaseValue)
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
Parameters that influence chain consensus.
int64_t DifficultyAdjustmentInterval() const
int64_t nPowTargetSpacing
bool fPowAllowMinDifficultyBlocks
@ STR_HEX
Special type that is a STR with only hex chars.
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ 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.
NodeContext struct containing references to chain state and connection state.
#define WAIT_LOCK(cs, name)
#define ENTER_CRITICAL_SECTION(cs)
#define LEAVE_CRITICAL_SECTION(cs)
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
NodeClock::time_point GetAdjustedTime()
const UniValue NullUniValue
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
int64_t atoi64(const std::string &str)
GlobalMutex g_best_block_mutex
std::condition_variable g_best_block_cv
const CBlockIndex * g_best_block
Used to notify getblocktemplate RPC of new tips.
bool ContextualCheckTransactionForCurrentBlock(const CBlockIndex &active_chain_tip, const Consensus::Params ¶ms, const CTransaction &tx, TxValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(bool TestBlockValidity(BlockValidationState &state, const CChainParams ¶ms, Chainstate &chainstate, const CBlock &block, CBlockIndex *pindexPrev, const std::function< NodeClock::time_point()> &adjusted_time_callback, BlockValidationOptions validationOptions) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
This is a variant of ContextualCheckTransaction which computes the contextual check for a transaction...
void UnregisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Unregister subscriber.
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
void RegisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Register subscriber.
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.