 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
59 if (height >= 0 && height < active_chain.
Height()) {
60 pb = active_chain[height];
63 if (pb ==
nullptr || !pb->
nHeight)
76 int64_t maxTime = minTime;
77 for (
int i = 0; i < lookup; i++) {
80 minTime = std::min(time, minTime);
81 maxTime = std::max(time, maxTime);
85 if (minTime == maxTime)
89 int64_t timeDiff = maxTime - minTime;
97 "\nReturns the estimated network hashes per second based on the last n blocks.\n"
98 "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
99 "Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
114 return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1, chainman.
ActiveChain());
137 if (block.
nNonce == std::numeric_limits<uint32_t>::max()) {
141 std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
142 if (!chainman.
ProcessNewBlock(chainparams, shared_pblock,
true,
nullptr)) {
158 nHeightEnd =
nHeight+nGenerate;
160 unsigned int nExtraNonce = 0;
165 if (!pblocktemplate.get())
167 CBlock *pblock = &pblocktemplate->block;
170 if (!
GenerateBlock(chainman, *pblock, nMaxTries, nExtraNonce, block_hash)) {
174 if (!block_hash.
IsNull()) {
185 const auto desc =
Parse(descriptor, key_provider,
error,
false);
187 if (desc->IsRange()) {
192 std::vector<CScript> scripts;
193 if (!desc->Expand(0, key_provider, scripts, provider)) {
200 if (scripts.size() == 1) {
201 script = scripts.at(0);
202 }
else if (scripts.size() == 4) {
204 script = scripts.at(2);
207 script = scripts.at(1);
219 "generatetodescriptor",
220 "\nMine blocks immediately to a specified descriptor (before the RPC call returns)\n",
233 "\nGenerate 11 blocks to mydesc\n" +
HelpExampleCli(
"generatetodescriptor",
"11 \"mydesc\"")},
236 const int num_blocks{request.params[0].
get_int()};
237 const uint64_t max_tries{request.params[2].isNull() ?
DEFAULT_MAX_TRIES : request.params[2].get_int()};
249 return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
264 "\nMine blocks immediately to a specified address (before the RPC call returns)\n",
276 "\nGenerate 11 blocks to myaddress\n"
278 +
"If you are using the " PACKAGE_NAME " wallet, you can get a new address to send the newly generated bitcoin to with:\n"
283 const int num_blocks{request.params[0].
get_int()};
284 const uint64_t max_tries{request.params[2].isNull() ?
DEFAULT_MAX_TRIES : request.params[2].get_int()};
297 return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
305 "\nMine a block with a set of ordered transactions immediately to a specified address or descriptor (before the RPC call returns)\n",
309 "Txids must reference transactions currently in the mempool.\n"
310 "All transactions must be valid and in valid order, otherwise the block will be rejected.",
323 "\nGenerate a block to myaddress, with txs rawtx and mempool_txid\n"
324 +
HelpExampleCli(
"generateblock", R
"("myaddress" '["rawtx", "mempool_txid"]')")
328 const auto address_or_descriptor = request.params[0].
get_str();
344 std::vector<CTransactionRef> txs;
345 const auto raw_txs_or_txids = request.params[1].get_array();
346 for (
size_t i = 0; i < raw_txs_or_txids.size(); i++) {
347 const auto str(raw_txs_or_txids[i].get_str());
353 const auto tx = mempool.
get(hash);
358 txs.emplace_back(tx);
377 if (!blocktemplate) {
380 block = blocktemplate->block;
386 block.
vtx.insert(block.
vtx.end(), txs.begin(), txs.end());
400 unsigned int extra_nonce{0};
402 if (!
GenerateBlock(chainman, block, max_tries, extra_nonce, block_hash) || block_hash.
IsNull()) {
416 "\nReturns a json object containing mining-related information.",
422 {
RPCResult::Type::NUM,
"currentblockweight",
true,
"The block weight of the last assembled block (only present if a block was ever assembled)"},
423 {
RPCResult::Type::NUM,
"currentblocktx",
true,
"The number of block transactions of the last assembled block (only present if a block was ever assembled)"},
444 if (BlockAssembler::m_last_block_weight) obj.
pushKV(
"currentblockweight", *BlockAssembler::m_last_block_weight);
445 if (BlockAssembler::m_last_block_num_txs) obj.
pushKV(
"currentblocktx", *BlockAssembler::m_last_block_num_txs);
448 obj.
pushKV(
"pooledtx", (uint64_t)mempool.
size());
461 "Accepts the transaction into mined blocks at a higher (or lower) priority\n",
465 " DEPRECATED. For forward compatibility use named arguments and omit this parameter."},
467 " Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\n"
468 " The fee is not actually paid, only the algorithm for selecting transactions into a block\n"
469 " considers the transaction as it would have paid a higher (or lower) fee."},
482 CAmount nAmount = request.params[2].get_int64();
484 if (!(request.params[1].isNull() || request.params[1].get_real() == 0)) {
506 if (strRejectReason.empty())
508 return strRejectReason;
516 std::string s = vbinfo.
name;
518 s.insert(s.begin(),
'!');
526 "\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
527 "It returns data needed to construct a block to work on.\n"
528 "For full specification, see BIPs 22, 23, 9, and 145:\n"
529 " https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n"
530 " https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n"
531 " https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
532 " https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
547 "\"template_request\""},
557 {
RPCResult::Type::STR,
"",
"name of a rule the client must understand to some extent; see BIP 9 for format"},
561 {
RPCResult::Type::NUM,
"rulename",
"identifies the bit number as indicating acceptance and readiness for the named softfork rule"},
567 {
RPCResult::Type::NUM,
"vbrequired",
"bit mask of versionbits the server requires set in submissions"},
569 {
RPCResult::Type::ARR,
"transactions",
"contents of non-coinbase transactions that should be included in the next block",
578 {
RPCResult::Type::NUM,
"",
"transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is"},
580 {
RPCResult::Type::NUM,
"fee",
"difference in value between transaction inputs and outputs (in satoshis); for coinbase transactions, this is a negative Number of the total collected block fees (ie, not including the block subsidy); if key is not present, fee is unknown and clients MUST NOT assume there isn't one"},
581 {
RPCResult::Type::NUM,
"sigops",
"total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero"},
582 {
RPCResult::Type::NUM,
"weight",
"total transaction weight, as counted for purposes of block limits"},
589 {
RPCResult::Type::NUM,
"coinbasevalue",
"maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)"},
590 {
RPCResult::Type::STR,
"longpollid",
"an id to include with a request to longpoll on an update to this template"},
595 {
RPCResult::Type::STR,
"value",
"A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'"},
605 {
RPCResult::Type::STR_HEX,
"default_witness_commitment",
true,
"a valid witness commitment for the unmodified block template"},
618 std::string strMode =
"template";
620 std::set<std::string> setClientRules;
621 int64_t nMaxVersionPreVB = -1;
624 if (!request.params[0].isNull())
630 else if (modeval.
isNull())
638 if (strMode ==
"proposal")
641 if (!dataval.
isStr())
654 return "duplicate-invalid";
655 return "duplicate-inconclusive";
661 return "inconclusive-not-best-prevblk";
669 for (
unsigned int i = 0; i < aClientRules.
size(); ++i) {
670 const UniValue& v = aClientRules[i];
671 setClientRules.insert(v.
get_str());
676 if (uvMaxVersion.
isNum()) {
677 nMaxVersionPreVB = uvMaxVersion.
get_int64();
682 if (strMode !=
"template")
685 if (!
Params().IsTestChain()) {
691 if (active_chainstate.IsInitialBlockDownload()) {
696 static unsigned int nTransactionsUpdatedLast;
703 std::chrono::steady_clock::time_point checktxtime;
704 unsigned int nTransactionsUpdatedLastLP;
709 std::string lpstr = lpval.
get_str();
711 hashWatchedChain =
ParseHashV(lpstr.substr(0, 64),
"longpollid");
712 nTransactionsUpdatedLastLP = LocaleIndependentAtoi<int64_t>(lpstr.substr(64));
718 nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
724 checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
729 if (
g_best_block_cv.wait_until(lock, checktxtime) == std::cv_status::timeout)
735 checktxtime += std::chrono::seconds(10);
749 if (consensusParams.
signet_blocks && setClientRules.count(
"signet") != 1) {
754 if (setClientRules.count(
"segwit") != 1) {
760 static int64_t nStart;
761 static std::unique_ptr<CBlockTemplate> pblocktemplate;
762 if (pindexPrev != active_chain.
Tip() ||
766 pindexPrev =
nullptr;
780 pindexPrev = pindexPrevNew;
783 CBlock* pblock = &pblocktemplate->block;
786 UpdateTime(pblock, consensusParams, pindexPrev);
795 std::map<uint256, int64_t> setTxIndex;
797 for (
const auto& it : pblock->
vtx) {
800 setTxIndex[txHash] = i++;
817 entry.
pushKV(
"depends", deps);
819 int index_in_template = i - 1;
820 entry.
pushKV(
"fee", pblocktemplate->vTxFees[index_in_template]);
821 int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template];
826 entry.
pushKV(
"sigops", nTxSigOps);
842 result.
pushKV(
"capabilities", aCaps);
846 if (!fPreSegWit) aRules.
push_back(
"!segwit");
870 if (setClientRules.find(vbinfo.
name) == setClientRules.end()) {
883 if (setClientRules.find(vbinfo.
name) == setClientRules.end()) {
895 result.
pushKV(
"rules", aRules);
896 result.
pushKV(
"vbavailable", vbavailable);
897 result.
pushKV(
"vbrequired",
int(0));
899 if (nMaxVersionPreVB >= 2) {
908 result.
pushKV(
"transactions", transactions);
909 result.
pushKV(
"coinbaseaux", aux);
910 result.
pushKV(
"coinbasevalue", (int64_t)pblock->
vtx[0]->vout[0].nValue);
914 result.
pushKV(
"mutable", aMutable);
915 result.
pushKV(
"noncerange",
"00000000ffffffff");
924 result.
pushKV(
"sigoplimit", nSigOpLimit);
925 result.
pushKV(
"sizelimit", nSizeLimit);
937 if (!pblocktemplate->vchCoinbaseCommitment.empty()) {
938 result.
pushKV(
"default_witness_commitment",
HexStr(pblocktemplate->vchCoinbaseCommitment));
968 "\nAttempts to submit new block to network.\n"
969 "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n",
984 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
985 CBlock& block = *blockptr;
986 if (!
DecodeHexBlk(block, request.params[0].get_str())) {
990 if (block.
vtx.empty() || !block.
vtx[0]->IsCoinBase()) {
1004 return "duplicate-invalid";
1018 auto sc = std::make_shared<submitblock_StateCatcher>(block.
GetHash());
1022 if (!new_block && accepted) {
1026 return "inconclusive";
1036 "\nDecode the given hexdata as a header and submit it as a candidate chain tip if valid."
1037 "\nThrows when the header is invalid.\n",
1075 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
1076 "confirmation within conf_target blocks if possible and return the number of blocks\n"
1077 "for which the estimate is valid. Uses virtual transaction size as defined\n"
1078 "in BIP 141 (witness data is discounted).\n",
1082 " Whether to return a more conservative estimate which also satisfies\n"
1083 " a longer history. A conservative estimate potentially returns a\n"
1084 " higher feerate and is more likely to be sufficient for the desired\n"
1085 " target, but is not as responsive to short term drops in the\n"
1086 " prevailing fee market. Must be one of (case insensitive):\n"
1093 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
1098 "The request target will be clamped between 2 and the highest target\n"
1099 "fee estimation is able to return based on how long it has been running.\n"
1100 "An error is returned if not enough transactions and blocks\n"
1101 "have been observed to make an estimate for any number of blocks."},
1109 RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
1118 bool conservative =
true;
1119 if (!request.params[1].isNull()) {
1134 feeRate = std::max({feeRate, min_mempool_feerate, min_relay_feerate});
1137 errors.
push_back(
"Insufficient data or no feerate found");
1138 result.
pushKV(
"errors", errors);
1149 "\nWARNING: This interface is unstable and may disappear or change!\n"
1150 "\nWARNING: This is an advanced API call that is tightly coupled to the specific\n"
1151 " implementation of fee estimation. The parameters it can be called with\n"
1152 " and the results it returns will change if the internal implementation changes.\n"
1153 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
1154 "confirmation within conf_target blocks if possible. Uses virtual transaction size as\n"
1155 "defined in BIP 141 (witness data is discounted).\n",
1159 " confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n"
1163 RPCResult::Type::OBJ,
"",
"Results are returned for any horizon which tracks blocks up to the confirmation target",
1168 {
RPCResult::Type::NUM,
"decay",
"exponential decay (per block) for historical moving average of confirmation data"},
1169 {
RPCResult::Type::NUM,
"scale",
"The resolution of confirmation targets at this time horizon"},
1170 {
RPCResult::Type::OBJ,
"pass",
true,
"information about the lowest range of feerates to succeed in meeting the threshold",
1174 {
RPCResult::Type::NUM,
"withintarget",
"number of txs over history horizon in the feerate range that were confirmed within target"},
1175 {
RPCResult::Type::NUM,
"totalconfirmed",
"number of txs over history horizon in the feerate range that were confirmed at any point"},
1176 {
RPCResult::Type::NUM,
"inmempool",
"current number of txs in mempool in the feerate range unconfirmed for at least target blocks"},
1177 {
RPCResult::Type::NUM,
"leftmempool",
"number of txs over history horizon in the feerate range that left mempool unconfirmed after target"},
1179 {
RPCResult::Type::OBJ,
"fail",
true,
"information about the highest range of feerates to fail to meet the threshold",
1183 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
1202 RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM},
true);
1209 double threshold = 0.95;
1210 if (!request.params[1].isNull()) {
1211 threshold = request.params[1].get_real();
1213 if (threshold < 0 || threshold > 1) {
1226 feeRate = fee_estimator.
estimateRawFee(conf_target, threshold, horizon, &buckets);
1248 horizon_result.
pushKV(
"scale", (
int)buckets.
scale);
1249 horizon_result.
pushKV(
"pass", passbucket);
1251 if (buckets.
fail.
start != -1) horizon_result.
pushKV(
"fail", failbucket);
1255 horizon_result.
pushKV(
"scale", (
int)buckets.
scale);
1256 horizon_result.
pushKV(
"fail", failbucket);
1257 errors.
push_back(
"Insufficient data or no feerate found which meets threshold");
1258 horizon_result.
pushKV(
"errors",errors);
1291 for (
const auto& c : commands) {
1292 t.appendCommand(c.name, &c);
Implement this to subscribe to events generated in validation.
int64_t GetBlockTime() const
An input of a transaction.
@ RPC_MISC_ERROR
General application defined errors.
bool ParseHashStr(const std::string &strHex, uint256 &result)
Parse a hex string into 256 bits.
bool ShutdownRequested()
Returns true if a shutdown is requested, false otherwise.
BlockValidationState state
const std::vector< CTxIn > vin
@ ELISION
Special type to denote elision (...)
CFeeRate GetMinFee(size_t sizelimit) const
The minimum fee to get into the mempool, which may itself not be enough for larger-sized transactions...
std::unique_ptr< Descriptor > Parse(const std::string &descriptor, FlatSigningProvider &out, std::string &error, bool require_checksum)
Parse a descriptor string.
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
void RegisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Register subscriber.
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &block, BlockValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=nullptr) LOCKS_EXCLUDED(cs_main)
Process incoming block headers.
CBlockIndex * LookupBlockIndex(const uint256 &hash) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
ThresholdState State(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
Get the BIP9 state for a given deployment for the block after pindexPrev.
static RPCHelpMan getnetworkhashps()
int bit
Bit position to select the particular bit in nVersion.
static UniValue BIP22ValidationResult(const BlockValidationState &state)
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
@ MAX_VERSION_BITS_DEPLOYMENTS
std::string GetHex() const
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
@ RPC_VERIFY_ERROR
General error during transaction or block submission.
const UniValue NullUniValue
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
256-bit unsigned big integer.
CBlockIndex * pprev
pointer to the index of the predecessor of this block
static bool getScriptFromDescriptor(const std::string &descriptor, CScript &script, std::string &error)
static RPCHelpMan submitheader()
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::BuriedDeployment dep)
Determine if a deployment is active for the next block.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
int nHeight
height of the entry in the chain. The genesis block has height 0
NodeContext struct containing references to chain state and connection state.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
static const uint64_t DEFAULT_MAX_TRIES
Default max iterations to try in RPC generatetodescriptor, generatetoaddress, and generateblock.
CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Estimate feerate needed to get be included in a block within confTarget blocks.
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
int64_t GetTime()
DEPRECATED Use either GetTimeSeconds (not mockable) or GetTime<T> (mockable)
@ RPC_CLIENT_IN_INITIAL_DOWNLOAD
Still downloading initial blocks.
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
static CTransactionRef MakeTransactionRef(Tx &&txIn)
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params ¶ms)
Check whether a block hash satisfies the proof-of-work requirement specified by nBits.
static RPCHelpMan getblocktemplate()
const Consensus::Params & GetConsensus() const
ChainstateManager & EnsureChainman(const NodeContext &node)
CBlockPolicyEstimator & EnsureAnyFeeEstimator(const std::any &context)
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
CChainState & ActiveChainstate() const
The most-work chain.
unsigned int GetTransactionsUpdated() const
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
bool pushKV(const std::string &key, const UniValue &val)
Fee rate in satoshis per kilobyte: CAmount / kB.
UniValue ValueFromAmount(const CAmount amount)
bool IsRPCRunning()
Query whether RPC is running.
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
Modify the extranonce in a block.
The basic transaction that is broadcasted on the network and contained in blocks.
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE
The maximum allowed size for a serialized block, in bytes (only for buffer size limits)
std::string ToString() const
CChain & ActiveChain() const
static RPCHelpMan estimatesmartfee()
NodeContext & EnsureAnyNodeContext(const std::any &context)
@ ECONOMICAL
Force estimateSmartFee to use non-conservative estimates.
static std::string gbt_vb_name(const Consensus::DeploymentPos pos)
const std::string & get_str() const
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
Parameters that influence chain consensus.
#define ENTER_CRITICAL_SECTION(cs)
VersionBitsCache g_versionbitscache
Global cache for versionbits deployment status.
int64_t get_int64() const
const std::string CURRENCY_UNIT
const UniValue & get_obj() const
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
CTransactionRef get(const uint256 &hash) const
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
@ STR_HEX
Special type that is a STR with only hex chars.
void RegisterMiningRPCCommands(CRPCTable &t)
Register mining RPC commands.
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index.
static RPCHelpMan estimaterawfee()
int64_t GetMedianTimePast() const
static const int64_t MAX_BLOCK_SIGOPS_COST
The maximum allowed number of signature check operations in a block (network rule)
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
ChainstateManager & EnsureAnyChainman(const std::any &context)
static uint32_t Mask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
static RPCHelpMan generatetodescriptor()
@ STR_HEX
Special string with only hex chars.
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
uint256 g_best_block
Used to notify getblocktemplate RPC of new tips.
void UnregisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Unregister subscriber.
const std::string InvalidEstimateModeErrorMessage()
static RPCHelpMan submitblock()
int64_t CAmount
Amount in satoshis (Can be negative)
std::vector< uint8_t > signet_challenge
std::string GetHex() const
std::unique_ptr< CBlockTemplate > CreateNewBlock(const CScript &scriptPubKeyIn)
Construct a new block template with coinbase to scriptPubKeyIn.
CConnman & EnsureConnman(const NodeContext &node)
bool ProcessNewBlock(const CChainParams &chainparams, const std::shared_ptr< const CBlock > &block, bool force_processing, bool *new_block) LOCKS_EXCLUDED(cs_main)
Process an incoming block.
static RPCHelpMan generateblock()
@ NUM_TIME
Special numeric to denote unix epoch time.
CChainState stores and provides an API to update our local knowledge of the current best chain.
bool gbt_force
Whether GBT clients can safely ignore this rule in simplified usage.
Generate a new block, without valid proof-of-work.
Serialized script, used inside transaction inputs and outputs.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
CFeeRate estimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult *result=nullptr) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Return a specific fee estimate calculation with a given success threshold and time horizon,...
uint256 GetBlockHash() const
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
int Height() const
Return the maximal height in the chain.
static UniValue generateBlocks(ChainstateManager &chainman, const CTxMemPool &mempool, const CScript &coinbase_script, int nGenerate, uint64_t nMaxTries)
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
static RPCHelpMan prioritisetransaction()
@ RPC_OUT_OF_MEMORY
Ran out of memory during operation.
An in-memory indexed chain of blocks.
static int64_t GetTransactionWeight(const CTransaction &tx)
std::vector< CTransactionRef > vtx
const char * name
Deployment name.
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
void UpdateUncommittedBlockStructures(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Update uncommitted block structures (currently: only the witness reserved value).
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...
std::string FeeModes(const std::string &delimiter)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
static RPCHelpMan generatetoaddress()
UniValue JSONRPCError(int code, const std::string &message)
bool TestBlockValidity(BlockValidationState &state, const CChainParams &chainparams, CChainState &chainstate, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
Check a block is completely valid from start to finish (only works on top of our current best block)
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...
static const unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
static RPCHelpMan getmininginfo()
unsigned long size() const
bool push_back(const UniValue &val)
void RegenerateCommitments(CBlock &block, ChainstateManager &chainman)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed.
const CChainParams & Params()
Return the currently selected parameters.
CTxMemPool & EnsureMemPool(const NodeContext &node)
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const EXCLUSIVE_LOCKS_REQUIRED(!m_cs_fee_estimator)
Calculation of highest target that estimates are tracked for.
static RPCHelpMan generate()
submitblock_StateCatcher(const uint256 &hashIn)
@ OBJ_DYN
Special dictionary with keys that are not literals.
const uint256 & GetWitnessHash() const
std::string GetRejectReason() const
const uint256 & GetHash() const
void BlockChecked(const CBlock &block, const BlockValidationState &stateIn) override
Notifies listeners of a block validation result.
#define LEAVE_CRITICAL_SECTION(cs)
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
const UniValue & find_value(const UniValue &obj, const std::string &name)
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
bool error(const char *fmt, const Args &... args)
A mutable version of CTransaction.
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const EXCLUSIVE_LOCKS_REQUIRED(
Check whether this block index entry is valid up to the passed validity level.
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
The block chain is a tree shaped structure starting with the genesis block at the root,...
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
static bool GenerateBlock(ChainstateManager &chainman, CBlock &block, uint64_t &max_tries, unsigned int &extra_nonce, uint256 &block_hash)
int64_t DifficultyAdjustmentInterval() const
CTxMemPool & EnsureAnyMemPool(const std::any &context)
static constexpr auto ALL_FEE_ESTIMATE_HORIZONS
static const int WITNESS_SCALE_FACTOR
size_t GetNodeCount(ConnectionDirection) const
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
#define WAIT_LOCK(cs, name)
CChain m_chain
The current chain of blockheaders we consult and build on.
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE
Default for -maxmempool, maximum megabytes of mempool memory usage.
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
bool signet_blocks
If true, witness commitments contain a payload equal to a Bitcoin Script solution to the signet chall...
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors.
std::condition_variable g_best_block_cv