6 #include <bitcoin-build-config.h> 9 #include <chainparams.h> 36 #include <txmempool.h> 41 #include <util/time.h> 66 if (lookup < -1 || lookup == 0) {
70 if (height < -1 || height > active_chain.
Height()) {
77 pb = active_chain[height];
80 if (pb ==
nullptr || !pb->
nHeight)
93 int64_t maxTime = minTime;
94 for (
int i = 0; i < lookup; i++) {
97 minTime = std::min(time, minTime);
98 maxTime = std::max(time, maxTime);
102 if (minTime == maxTime)
106 int64_t timeDiff = maxTime - minTime;
115 "Returns the estimated network hashes per second based on the last n blocks.\n" 116 "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n" 117 "Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
119 {
"nblocks",
RPCArg::Type::NUM,
RPCArg::Default{120},
"The number of previous blocks to calculate estimate from, or -1 for blocks since last difficulty change."},
149 if (block.nNonce == std::numeric_limits<uint32_t>::max()) {
153 block_out = std::make_shared<const CBlock>(std::move(block));
155 if (!process_new_block)
return true;
168 std::unique_ptr<BlockTemplate> block_template(miner.
createNewBlock({ .coinbase_output_script = coinbase_output_script, .include_dummy_extranonce = true },
false));
171 std::shared_ptr<const CBlock> block_out;
172 if (!
GenerateBlock(chainman, block_template->getBlock(), nMaxTries, block_out,
true)) {
178 blockHashes.
push_back(block_out->GetHash().GetHex());
187 const auto descs =
Parse(descriptor, key_provider, error,
false);
188 if (descs.empty())
return false;
189 if (descs.size() > 1) {
192 const auto& desc = descs.at(0);
193 if (desc->IsRange()) {
198 std::vector<CScript> scripts;
199 if (!desc->Expand(0, key_provider, scripts, provider)) {
206 if (scripts.size() == 1) {
208 }
else if (scripts.size() == 4) {
222 "generatetodescriptor",
223 "Mine to a specified descriptor and return the block hashes.",
236 "\nGenerate 11 blocks to mydesc\n" +
HelpExampleCli(
"generatetodescriptor",
"11 \"mydesc\"")},
239 const auto num_blocks{
self.Arg<
int>(
"num_blocks")};
240 const auto max_tries{
self.Arg<uint64_t>(
"maxtries")};
242 CScript coinbase_output_script;
252 return generateBlocks(chainman, miner, coinbase_output_script, num_blocks, max_tries);
267 "Mine to a specified address and return the block hashes.",
279 "\nGenerate 11 blocks to myaddress\n" 281 +
"If you are using the " CLIENT_NAME
" wallet, you can get a new address to send the newly generated bitcoin to with:\n" 286 const int num_blocks{request.params[0].
getInt<
int>()};
287 const uint64_t max_tries{request.params[2].isNull() ?
DEFAULT_MAX_TRIES : request.params[2].getInt<
int>()};
300 return generateBlocks(chainman, miner, coinbase_output_script, num_blocks, max_tries);
308 "Mine a set of ordered transactions to a specified address or descriptor and return the block hash.",
312 "Txids must reference transactions currently in the mempool.\n" 313 "All transactions must be valid and in valid order, otherwise the block will be rejected.",
328 "\nGenerate a block to myaddress, with txs rawtx and mempool_txid\n" 329 +
HelpExampleCli(
"generateblock", R
"("myaddress" '["rawtx", "mempool_txid"]')") 333 const auto address_or_descriptor = request.params[0].
get_str();
334 CScript coinbase_output_script;
350 std::vector<CTransactionRef> txs;
351 const auto raw_txs_or_txids = request.params[1].get_array();
352 for (
size_t i = 0; i < raw_txs_or_txids.size(); i++) {
353 const auto& str{raw_txs_or_txids[i].get_str()};
357 const auto tx{mempool.
get(*txid)};
362 txs.emplace_back(tx);
372 const bool process_new_block{request.params[2].isNull() ? true : request.params[2].get_bool()};
379 std::unique_ptr<BlockTemplate> block_template{miner.
createNewBlock({.use_mempool =
false, .coinbase_output_script = coinbase_output_script, .include_dummy_extranonce =
true},
false)};
382 block = block_template->getBlock();
388 block.
vtx.insert(block.
vtx.end(), txs.begin(), txs.end());
396 std::shared_ptr<const CBlock> block_out;
399 if (!
GenerateBlock(chainman, std::move(block), max_tries, block_out, process_new_block) || !block_out) {
404 obj.
pushKV(
"hash", block_out->GetHash().GetHex());
405 if (!process_new_block) {
419 "Returns a json object containing mining-related information.",
425 {
RPCResult::Type::NUM,
"currentblockweight",
true,
"The block weight (including reserved weight for block header, txs count and coinbase tx) of the last assembled block (only present if a block was ever assembled)"},
426 {
RPCResult::Type::NUM,
"currentblocktx",
true,
"The number of block transactions (excluding coinbase) of the last assembled block (only present if a block was ever assembled)"},
434 {
RPCResult::Type::STR_HEX,
"signet_challenge",
true,
"The block challenge (aka. block script), in hexadecimal (only present if the current network is a signet)"},
444 RPCResult{
RPCResult::Type::ARR,
"warnings",
"any network and blockchain warnings (run with `-deprecatedrpc=warnings` to return the latest warning as a single string)",
466 if (BlockAssembler::m_last_block_weight) obj.
pushKV(
"currentblockweight", *BlockAssembler::m_last_block_weight);
467 if (BlockAssembler::m_last_block_num_txs) obj.
pushKV(
"currentblocktx", *BlockAssembler::m_last_block_num_txs);
473 BlockAssembler::Options assembler_options;
489 const std::vector<uint8_t>& signet_challenge =
491 obj.
pushKV(
"signet_challenge",
HexStr(signet_challenge));
504 "Accepts the transaction into mined blocks at a higher (or lower) priority\n",
508 " DEPRECATED. For forward compatibility use named arguments and omit this parameter."},
510 " Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\n" 511 " The fee is not actually paid, only the algorithm for selecting transactions into a block\n" 512 " considers the transaction as it would have paid a higher (or lower) fee."},
525 const auto dummy{
self.MaybeArg<
double>(
"dummy")};
526 CAmount nAmount = request.params[2].getInt<int64_t>();
528 if (dummy && *dummy != 0) {
535 const auto& tx = mempool.
get(txid);
548 return RPCHelpMan{
"getprioritisedtransactions",
549 "Returns a map of all user-created (see prioritisetransaction) fee deltas by txid, and whether the tx is present in mempool.",
557 {
RPCResult::Type::NUM,
"modified_fee",
true,
"modified fee in satoshis. Only returned if in_mempool=true"},
572 result_inner.pushKV(
"fee_delta", delta_info.delta);
573 result_inner.pushKV(
"in_mempool", delta_info.in_mempool);
574 if (delta_info.in_mempool) {
575 result_inner.pushKV(
"modified_fee", *delta_info.modified_fee);
577 rpc_result.pushKV(delta_info.txid.GetHex(), std::move(result_inner));
596 if (strRejectReason.empty())
598 return strRejectReason;
608 if (!gbt_optional_rule) {
609 s.insert(
s.begin(),
'!');
618 "If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n" 619 "It returns data needed to construct a block to work on.\n" 620 "For full specification, see BIPs 22, 23, 9, and 145:\n" 621 " https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n" 622 " https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n" 623 " https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n" 624 " https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
651 {
RPCResult::Type::STR,
"",
"name of a rule the client must understand to some extent; see BIP 9 for format"},
655 {
RPCResult::Type::NUM,
"rulename",
"identifies the bit number as indicating acceptance and readiness for the named softfork rule"},
661 {
RPCResult::Type::NUM,
"vbrequired",
"bit mask of versionbits the server requires set in submissions"},
663 {
RPCResult::Type::ARR,
"transactions",
"contents of non-coinbase transactions that should be included in the next block",
672 {
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"},
674 {
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"},
675 {
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"},
676 {
RPCResult::Type::NUM,
"weight",
"total transaction weight, as counted for purposes of block limits"},
683 {
RPCResult::Type::NUM,
"coinbasevalue",
"maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)"},
684 {
RPCResult::Type::STR,
"longpollid",
"an id to include with a request to longpoll on an update to this template"},
689 {
RPCResult::Type::STR,
"value",
"A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'"},
699 {
RPCResult::Type::STR_HEX,
"default_witness_commitment",
true,
"a valid witness commitment for the unmodified block template"},
712 std::string strMode =
"template";
714 std::set<std::string> setClientRules;
715 if (!request.params[0].isNull())
721 else if (modeval.
isNull())
729 if (strMode ==
"proposal")
732 if (!dataval.
isStr())
746 return "duplicate-invalid";
747 return "duplicate-inconclusive";
755 for (
unsigned int i = 0; i < aClientRules.
size(); ++i) {
756 const UniValue& v = aClientRules[i];
757 setClientRules.insert(v.
get_str());
762 if (strMode !=
"template")
776 static unsigned int nTransactionsUpdatedLast;
799 unsigned int nTransactionsUpdatedLastLP;
804 const std::string& lpstr = lpval.
get_str();
808 hashWatchedChain =
ParseHashV(lpstr.substr(0, 64),
"longpollid");
809 nTransactionsUpdatedLastLP = LocaleIndependentAtoi<int64_t>(lpstr.substr(64));
814 hashWatchedChain = tip;
815 nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
825 std::optional<BlockRef> maybe_tip{miner.
waitTipChanged(hashWatchedChain, checktxtime)};
827 if (!maybe_tip)
break;
828 tip = maybe_tip->hash;
829 if (tip != hashWatchedChain)
break;
836 checktxtime = std::chrono::seconds(10);
849 if (consensusParams.
signet_blocks && !setClientRules.contains(
"signet")) {
854 if (!setClientRules.contains(
"segwit")) {
860 static int64_t time_start;
861 static std::unique_ptr<BlockTemplate> block_template;
866 pindexPrev =
nullptr;
877 block_template = miner.
createNewBlock({.include_dummy_extranonce =
true},
false);
882 pindexPrev = pindexPrevNew;
885 CBlock block{block_template->getBlock()};
888 UpdateTime(&block, consensusParams, pindexPrev);
897 std::map<Txid, int64_t> setTxIndex;
898 std::vector<CAmount> tx_fees{block_template->getTxFees()};
899 std::vector<CAmount> tx_sigops{block_template->getTxSigops()};
902 for (
const auto& it : block.vtx) {
905 setTxIndex[txHash] = i++;
922 entry.
pushKV(
"depends", std::move(deps));
924 int index_in_template = i - 2;
925 entry.
pushKV(
"fee", tx_fees.at(index_in_template));
926 int64_t nTxSigOps{tx_sigops.at(index_in_template)};
931 entry.
pushKV(
"sigops", nTxSigOps);
934 transactions.
push_back(std::move(entry));
947 result.pushKV(
"capabilities", std::move(aCaps));
951 if (!fPreSegWit) aRules.
push_back(
"!segwit");
961 for (
const auto& [
name, info] : gbtstatus.signalling) {
963 if (!info.gbt_optional_rule && !setClientRules.contains(
name)) {
965 block.nVersion &= ~info.mask;
969 for (
const auto& [
name, info] : gbtstatus.locked_in) {
970 block.nVersion |= info.mask;
972 if (!info.gbt_optional_rule && !setClientRules.contains(
name)) {
974 block.nVersion &= ~info.mask;
978 for (
const auto& [
name, info] : gbtstatus.active) {
980 if (!info.gbt_optional_rule && !setClientRules.contains(
name)) {
986 result.pushKV(
"version", block.nVersion);
987 result.pushKV(
"rules", std::move(aRules));
988 result.pushKV(
"vbavailable", std::move(vbavailable));
989 result.pushKV(
"vbrequired", 0);
991 result.pushKV(
"previousblockhash", block.hashPrevBlock.GetHex());
992 result.pushKV(
"transactions", std::move(transactions));
993 result.pushKV(
"coinbaseaux", std::move(aux));
994 result.pushKV(
"coinbasevalue", block.vtx[0]->vout[0].nValue);
995 result.pushKV(
"longpollid", tip.GetHex() +
ToString(nTransactionsUpdatedLast));
998 result.pushKV(
"mutable", std::move(aMutable));
999 result.pushKV(
"noncerange",
"00000000ffffffff");
1008 result.pushKV(
"sigoplimit", nSigOpLimit);
1009 result.pushKV(
"sizelimit", nSizeLimit);
1013 result.pushKV(
"curtime", block.GetBlockTime());
1021 if (
auto coinbase{block_template->getCoinbaseTx()}; coinbase.required_outputs.size() > 0) {
1023 result.pushKV(
"default_witness_commitment",
HexStr(coinbase.required_outputs[0].scriptPubKey));
1043 if (block->GetHash() !=
hash)
return;
1054 "Attempts to submit new block to network.\n" 1055 "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n",
1070 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
1071 CBlock& block = *blockptr;
1072 if (!
DecodeHexBlk(block, request.params[0].get_str())) {
1081 chainman.UpdateUncommittedBlockStructures(block, pindex);
1086 auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash());
1088 bool accepted = chainman.
ProcessNewBlock(blockptr,
true,
true, &new_block);
1090 if (!new_block && accepted) {
1094 return "inconclusive";
1105 "Decode the given hexdata as a header and submit it as a candidate chain tip if valid." 1106 "\nThrows when the header is invalid.\n",
1157 for (
const auto& c : commands) {
1158 t.appendCommand(c.name, &c);
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
std::string GetHex() const
static UniValue Parse(std::string_view raw, ParamFormat format=ParamFormat::JSON)
Parse string to UniValue or throw runtime_error if string contains invalid JSON.
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
void push_back(UniValue val)
Block template interface.
static RPCHelpMan getnetworkhashps()
bool ProcessNewBlockHeaders(std::span< const CBlockHeader > headers, bool min_pow_checked, BlockValidationState &state, const CBlockIndex **ppindex=nullptr) LOCKS_EXCLUDED(cs_main)
Process incoming block headers.
static const int WITNESS_SCALE_FACTOR
int64_t GetBlockTime() const
static std::string gbt_rule_value(const std::string &name, bool gbt_optional_rule)
Generate a new block, without valid proof-of-work.
UniValue ValueFromAmount(const CAmount amount)
CBlockIndex * pprev
pointer to the index of the predecessor of this block
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
ValidationSignals * signals
bool IsRPCRunning()
Query whether RPC is running.
BlockValidationState state
uint256 GetTarget(const CBlockIndex &blockindex, const uint256 pow_limit)
std::string GetChainTypeString() const
Return the chain type string.
CTxMemPool & EnsureMemPool(const NodeContext &node)
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
An in-memory indexed chain of blocks.
static UniValue BIP22ValidationResult(const BlockValidationState &state)
static RPCHelpMan getblocktemplate()
int64_t GetTime()
DEPRECATED, see GetTime.
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
static bool GenerateBlock(ChainstateManager &chainman, CBlock &&block, uint64_t &max_tries, std::shared_ptr< const CBlock > &block_out, bool process_new_block)
#define CHECK_NONFATAL(condition)
Identity function.
int Height() const
Return the maximal height in the chain.
#define REVERSE_LOCK(g, cs)
bool DeploymentActiveAfter(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::BuriedDeployment dep, [[maybe_unused]] VersionBitsCache &versionbitscache)
Determine if a deployment is active for the next block.
bool DecodeHexBlk(CBlock &block, const std::string &strHexBlk)
stage after last reached validness failed
unsigned long size() const
Hash/height pair to help track and identify blocks.
static RPCHelpMan submitheader()
const std::string & get_str() const
CTransactionRef get(const Txid &hash) const
#define LIST_CHAIN_NAMES
List of possible chain / network names.
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
submitblock_StateCatcher(const uint256 &hashIn)
static const int64_t MAX_BLOCK_SIGOPS_COST
The maximum allowed number of signature check operations in a block (network rule) ...
void NextEmptyBlockIndex(CBlockIndex &tip, const Consensus::Params &consensusParams, CBlockIndex &next_index)
Return an empty block index on top of the tip, with height, time and nBits set.
static int32_t GetTransactionWeight(const CTransaction &tx)
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
Implement this to subscribe to events generated in validation and mempool.
void PrioritiseTransaction(const Txid &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
const std::vector< CTxIn > vin
Invalid, missing or duplicate parameter.
const util::SignalInterrupt & m_interrupt
static UniValue generateBlocks(ChainstateManager &chainman, Mining &miner, const CScript &coinbase_output_script, int nGenerate, uint64_t nMaxTries)
VersionBitsCache m_versionbitscache
Track versionbit status.
static const unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
bool ProcessNewBlock(const std::shared_ptr< const CBlock > &block, bool force_processing, bool min_pow_checked, bool *new_block) LOCKS_EXCLUDED(cs_main)
Process an incoming block.
int64_t CAmount
Amount in satoshis (Can be negative)
const UniValue & find_value(std::string_view key) const
uint256 GetBlockHash() const
void RegisterMiningRPCCommands(CRPCTable &t)
General error during transaction or block submission.
static bool getScriptFromDescriptor(std::string_view descriptor, CScript &script, std::string &error)
Special type that is a STR with only hex chars.
NodeContext struct containing references to chain state and connection state.
uint256 powLimit
Proof of work parameters.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Interface giving clients (RPC, Stratum v2 Template Provider in the future) ability to create block te...
UniValue JSONRPCError(int code, const std::string &message)
static RPCHelpMan generatetodescriptor()
Special string with only hex chars.
static const uint64_t DEFAULT_MAX_TRIES
Default max iterations to try in RPC generatetodescriptor, generatetoaddress, and generateblock...
An input of a transaction.
Double ended buffer combining vector and stream-like interfaces.
std::string ToString() const
Unexpected type was passed as parameter.
interfaces::Mining & EnsureMining(const NodeContext &node)
bool signet_blocks
If true, witness commitments contain a payload equal to a Bitcoin Script solution to the signet chall...
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
const Consensus::Params & GetConsensus() const
const std::string CURRENCY_UNIT
std::vector< delta_info > GetPrioritisedTransactions() const EXCLUSIVE_LOCKS_REQUIRED(!cs)
Return a vector of all entries in mapDeltas with their corresponding delta_info.
General application defined errors.
std::string DefaultHint
Hint for default value.
#define WAIT_LOCK(cs, name)
static RPCHelpMan submitblock()
CTxMemPool & EnsureAnyMemPool(const std::any &context)
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
Parameters that influence chain consensus.
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.
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
bool IsDeprecatedRPCEnabled(const std::string &method)
static RPCHelpMan prioritisetransaction()
virtual bool isInitialBlockDownload()=0
Returns whether IBD is still in progress.
Special numeric to denote unix epoch time.
256-bit unsigned big integer.
static RPCHelpMan generateblock()
UniValue GetWarningsForRpc(const Warnings &warnings, bool use_deprecated)
RPC helper function that wraps warnings.GetMessages().
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
int64_t DifficultyAdjustmentInterval() const
std::vector< uint32_t > GetDust(const CTransaction &tx, CFeeRate dust_relay_rate)
Get the vout index numbers of all dust outputs.
int64_t GetMinimumTime(const CBlockIndex *pindexPrev, const int64_t difficulty_adjustment_interval)
Get the minimum time a miner should use in the next block.
const CChainParams & GetParams() const
Optional argument for which the default value is omitted from help text for one of two reasons: ...
size_t GetNodeCount(ConnectionDirection) const
ChainType GetChainType() const
Return the chain type.
std::vector< CTransactionRef > vtx
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Special string to represent a floating point amount.
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
void pushKV(std::string key, UniValue val)
Serialized script, used inside transaction inputs and outputs.
static transaction_identifier FromUint256(const uint256 &id)
uint256 ParseHashV(const UniValue &v, std::string_view name)
Utilities: convert hex-encoded Values (throws error if not hex).
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...
ChainstateManager & EnsureChainman(const NodeContext &node)
bool DecodeHexBlockHeader(CBlockHeader &header, const std::string &hex_header)
std::string EncodeHexTx(const CTransaction &tx)
const UniValue & get_obj() const
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness, bool try_witness)
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
virtual std::optional< BlockRef > getTip()=0
Returns the hash and height for the tip of this chain.
std::vector< uint8_t > signet_challenge
static RPCHelpMan generatetoaddress()
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
std::string GetHex() const
static RPCHelpMan getprioritisedtransactions()
static RPCHelpMan generate()
const UniValue NullUniValue
static RPCHelpMan getmininginfo()
unsigned int GetTransactionsUpdated() const
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...
void BlockChecked(const std::shared_ptr< const CBlock > &block, const BlockValidationState &stateIn) override
Notifies listeners of a block validation result.
A mutable version of CTransaction.
bool IsValid(enum BlockStatus nUpTo) const EXCLUSIVE_LOCKS_REQUIRED(
Check whether this block index entry is valid up to the passed validity level.
double GetDifficulty(const CBlockIndex &blockindex)
Get the difficulty of the net wrt to the given block index.
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 GetHex() const
Hex encoding of the number (with the most significant digits first).
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
const Consensus::Params & GetConsensus() const
BlockValidationState TestBlockValidity(Chainstate &chainstate, const CBlock &block, const bool check_pow, const bool check_merkle_root)
Verify a block, including transactions.
Chainstate & ActiveChainstate() const
Alternatives to CurrentChainstate() used by older code to query latest chainstate information without...
Special dictionary with keys that are not literals.
std::string GetRejectReason() const
Still downloading initial blocks.
virtual std::optional< BlockRef > waitTipChanged(uint256 current_tip, MillisecondsDouble timeout=MillisecondsDouble::max())=0
Waits for the connected tip to change.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
ChainstateManager & EnsureAnyChainman(const std::any &context)
virtual bool isTestChain()=0
If this chain is exclusively used for testing.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
void RegenerateCommitments(CBlock &block, ChainstateManager &chainman)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed...
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::chrono::duration< double, std::chrono::milliseconds::period > MillisecondsDouble
static std::optional< transaction_identifier > FromHex(std::string_view hex)
const Wtxid & GetWitnessHash() const LIFETIMEBOUND
std::string ToString(const T &t)
Locale-independent version of std::to_string.
NodeContext & EnsureAnyNodeContext(const std::any &context)
BIP9GBTStatus GBTStatus(const CBlockIndex &block_index, const Consensus::Params ¶ms) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
Error parsing or validating structure in raw format.
const Txid & GetHash() const LIFETIMEBOUND
CConnman & EnsureConnman(const NodeContext &node)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
virtual std::unique_ptr< BlockTemplate > createNewBlock(const node::BlockCreateOptions &options={}, bool cooldown=true)=0
Construct a new block template.
static constexpr TransactionSerParams TX_WITH_WITNESS
CFeeRate dust_relay_feerate