50 if (height >= 0 && height < ::
ChainActive().Height())
53 if (pb ==
nullptr || !pb->
nHeight)
66 int64_t maxTime = minTime;
67 for (
int i = 0; i < lookup; i++) {
70 minTime = std::min(time, minTime);
71 maxTime = std::max(time, maxTime);
75 if (minTime == maxTime)
79 int64_t timeDiff = maxTime - minTime;
87 "\nReturns the estimated network hashes per second based on the last n blocks.\n"
88 "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change.\n"
89 "Pass in [height] to estimate the network speed at the time when a certain block was found.\n",
91 {
"nblocks",
RPCArg::Type::NUM,
"120",
"The number of blocks, or -1 for blocks since last difficulty change."},
92 {
"height",
RPCArg::Type::NUM,
"-1",
"To estimate at the time of the given height."},
103 return GetNetworkHashPS(!request.params[0].isNull() ? request.params[0].get_int() : 120, !request.params[1].isNull() ? request.params[1].get_int() : -1);
126 if (block.
nNonce == std::numeric_limits<uint32_t>::max()) {
130 std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
131 if (!chainman.
ProcessNewBlock(chainparams, shared_pblock,
true,
nullptr)) {
147 nHeightEnd =
nHeight+nGenerate;
149 unsigned int nExtraNonce = 0;
153 std::unique_ptr<CBlockTemplate> pblocktemplate(
BlockAssembler(mempool,
Params()).CreateNewBlock(coinbase_script));
154 if (!pblocktemplate.get())
156 CBlock *pblock = &pblocktemplate->block;
159 if (!
GenerateBlock(chainman, *pblock, nMaxTries, nExtraNonce, block_hash)) {
163 if (!block_hash.
IsNull()) {
174 const auto desc =
Parse(descriptor, key_provider,
error,
false);
176 if (desc->IsRange()) {
181 std::vector<CScript> scripts;
182 if (!desc->Expand(0, key_provider, scripts, provider)) {
189 if (scripts.size() == 1) {
190 script = scripts.at(0);
191 }
else if (scripts.size() == 4) {
193 script = scripts.at(2);
196 script = scripts.at(1);
208 "generatetodescriptor",
209 "\nMine blocks immediately to a specified descriptor (before the RPC call returns)\n",
222 "\nGenerate 11 blocks to mydesc\n" +
HelpExampleCli(
"generatetodescriptor",
"11 \"mydesc\"")},
225 const int num_blocks{request.params[0].
get_int()};
226 const uint64_t max_tries{request.params[2].isNull() ?
DEFAULT_MAX_TRIES : request.params[2].get_int()};
237 return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
247 throw std::runtime_error(
self.
ToString());
257 "\nMine blocks immediately to a specified address (before the RPC call returns)\n",
269 "\nGenerate 11 blocks to myaddress\n"
271 +
"If you are using the " PACKAGE_NAME " wallet, you can get a new address to send the newly generated bitcoin to with:\n"
276 const int num_blocks{request.params[0].
get_int()};
277 const uint64_t max_tries{request.params[2].isNull() ?
DEFAULT_MAX_TRIES : request.params[2].get_int()};
289 return generateBlocks(chainman, mempool, coinbase_script, num_blocks, max_tries);
297 "\nMine a block with a set of ordered transactions immediately to a specified address or descriptor (before the RPC call returns)\n",
301 "Txids must reference transactions currently in the mempool.\n"
302 "All transactions must be valid and in valid order, otherwise the block will be rejected.",
315 "\nGenerate a block to myaddress, with txs rawtx and mempool_txid\n"
316 +
HelpExampleCli(
"generateblock", R
"("myaddress" '["rawtx", "mempool_txid"]')")
320 const auto address_or_descriptor = request.params[0].
get_str();
335 std::vector<CTransactionRef> txs;
336 const auto raw_txs_or_txids = request.params[1].get_array();
337 for (
size_t i = 0; i < raw_txs_or_txids.size(); i++) {
338 const auto str(raw_txs_or_txids[i].get_str());
344 const auto tx = mempool.
get(hash);
349 txs.emplace_back(tx);
366 std::unique_ptr<CBlockTemplate> blocktemplate(
BlockAssembler(empty_mempool, chainparams).CreateNewBlock(coinbase_script));
367 if (!blocktemplate) {
370 block = blocktemplate->block;
376 block.
vtx.insert(block.
vtx.end(), txs.begin(), txs.end());
390 unsigned int extra_nonce{0};
406 "\nReturns a json object containing mining-related information.",
412 {
RPCResult::Type::NUM,
"currentblockweight",
true,
"The block weight of the last assembled block (only present if a block was ever assembled)"},
413 {
RPCResult::Type::NUM,
"currentblocktx",
true,
"The number of block transactions of the last assembled block (only present if a block was ever assembled)"},
435 obj.
pushKV(
"pooledtx", (uint64_t)mempool.
size());
448 "Accepts the transaction into mined blocks at a higher (or lower) priority\n",
452 " DEPRECATED. For forward compatibility use named arguments and omit this parameter."},
454 " Note, that this value is not a fee rate. It is a value to modify absolute fee of the TX.\n"
455 " The fee is not actually paid, only the algorithm for selecting transactions into a block\n"
456 " considers the transaction as it would have paid a higher (or lower) fee."},
469 CAmount nAmount = request.params[2].get_int64();
471 if (!(request.params[1].isNull() || request.params[1].get_real() == 0)) {
493 if (strRejectReason.empty())
495 return strRejectReason;
503 std::string s = vbinfo.
name;
505 s.insert(s.begin(),
'!');
513 "\nIf the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.\n"
514 "It returns data needed to construct a block to work on.\n"
515 "For full specification, see BIPs 22, 23, 9, and 145:\n"
516 " https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki\n"
517 " https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki\n"
518 " https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes\n"
519 " https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki\n",
536 "\"template_request\""},
544 {
RPCResult::Type::STR,
"",
"name of a rule the client must understand to some extent; see BIP 9 for format"},
548 {
RPCResult::Type::NUM,
"rulename",
"identifies the bit number as indicating acceptance and readiness for the named softfork rule"},
550 {
RPCResult::Type::NUM,
"vbrequired",
"bit mask of versionbits the server requires set in submissions"},
552 {
RPCResult::Type::ARR,
"transactions",
"contents of non-coinbase transactions that should be included in the next block",
561 {
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"},
563 {
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"},
564 {
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"},
565 {
RPCResult::Type::NUM,
"weight",
"total transaction weight, as counted for purposes of block limits"},
572 {
RPCResult::Type::NUM,
"coinbasevalue",
"maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis)"},
573 {
RPCResult::Type::STR,
"longpollid",
"an id to include with a request to longpoll on an update to this template"},
578 {
RPCResult::Type::STR,
"value",
"A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock'"},
587 {
RPCResult::Type::STR,
"default_witness_commitment",
true,
"a valid witness commitment for the unmodified block template"}
597 std::string strMode =
"template";
599 std::set<std::string> setClientRules;
600 int64_t nMaxVersionPreVB = -1;
601 if (!request.params[0].isNull())
607 else if (modeval.
isNull())
615 if (strMode ==
"proposal")
618 if (!dataval.
isStr())
631 return "duplicate-invalid";
632 return "duplicate-inconclusive";
638 return "inconclusive-not-best-prevblk";
646 for (
unsigned int i = 0; i < aClientRules.
size(); ++i) {
647 const UniValue& v = aClientRules[i];
648 setClientRules.insert(v.
get_str());
653 if (uvMaxVersion.
isNum()) {
654 nMaxVersionPreVB = uvMaxVersion.
get_int64();
659 if (strMode !=
"template")
672 static unsigned int nTransactionsUpdatedLast;
679 std::chrono::steady_clock::time_point checktxtime;
680 unsigned int nTransactionsUpdatedLastLP;
685 std::string lpstr = lpval.
get_str();
687 hashWatchedChain =
ParseHashV(lpstr.substr(0, 64),
"longpollid");
688 nTransactionsUpdatedLastLP =
atoi64(lpstr.substr(64));
694 nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
705 if (
g_best_block_cv.wait_until(lock, checktxtime) == std::cv_status::timeout)
711 checktxtime += std::chrono::seconds(10);
723 if (setClientRules.count(
"segwit") != 1) {
729 static int64_t nStart;
730 static std::unique_ptr<CBlockTemplate> pblocktemplate;
735 pindexPrev =
nullptr;
749 pindexPrev = pindexPrevNew;
752 CBlock* pblock = &pblocktemplate->block;
756 UpdateTime(pblock, consensusParams, pindexPrev);
765 std::map<uint256, int64_t> setTxIndex;
767 for (
const auto&
it : pblock->
vtx) {
770 setTxIndex[txHash] = i++;
787 entry.
pushKV(
"depends", deps);
789 int index_in_template = i - 1;
790 entry.
pushKV(
"fee", pblocktemplate->vTxFees[index_in_template]);
791 int64_t nTxSigOps = pblocktemplate->vTxSigOpsCost[index_in_template];
796 entry.
pushKV(
"sigops", nTxSigOps);
812 result.
pushKV(
"capabilities", aCaps);
816 if (!fPreSegWit) aRules.
push_back(
"!segwit");
834 if (setClientRules.find(vbinfo.
name) == setClientRules.end()) {
847 if (setClientRules.find(vbinfo.
name) == setClientRules.end()) {
859 result.
pushKV(
"rules", aRules);
860 result.
pushKV(
"vbavailable", vbavailable);
861 result.
pushKV(
"vbrequired",
int(0));
863 if (nMaxVersionPreVB >= 2) {
872 result.
pushKV(
"transactions", transactions);
873 result.
pushKV(
"coinbaseaux", aux);
874 result.
pushKV(
"coinbasevalue", (int64_t)pblock->
vtx[0]->vout[0].nValue);
878 result.
pushKV(
"mutable", aMutable);
879 result.
pushKV(
"noncerange",
"00000000ffffffff");
888 result.
pushKV(
"sigoplimit", nSigOpLimit);
889 result.
pushKV(
"sizelimit", nSizeLimit);
897 if (!pblocktemplate->vchCoinbaseCommitment.empty()) {
898 result.
pushKV(
"default_witness_commitment",
HexStr(pblocktemplate->vchCoinbaseCommitment));
928 "\nAttempts to submit new block to network.\n"
929 "See https://en.bitcoin.it/wiki/BIP_0022 for full specification.\n",
932 {
"dummy",
RPCArg::Type::STR,
"ignored",
"dummy value, for compatibility with BIP22. This value is ignored."},
941 std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
942 CBlock& block = *blockptr;
943 if (!
DecodeHexBlk(block, request.params[0].get_str())) {
947 if (block.
vtx.empty() || !block.
vtx[0]->IsCoinBase()) {
960 return "duplicate-invalid";
974 auto sc = std::make_shared<submitblock_StateCatcher>(block.
GetHash());
978 if (!new_block && accepted) {
982 return "inconclusive";
992 "\nDecode the given hexdata as a header and submit it as a candidate chain tip if valid."
993 "\nThrows when the header is invalid.\n",
1030 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
1031 "confirmation within conf_target blocks if possible and return the number of blocks\n"
1032 "for which the estimate is valid. Uses virtual transaction size as defined\n"
1033 "in BIP 141 (witness data is discounted).\n",
1037 " Whether to return a more conservative estimate which also satisfies\n"
1038 " a longer history. A conservative estimate potentially returns a\n"
1039 " higher feerate and is more likely to be sufficient for the desired\n"
1040 " target, but is not as responsive to short term drops in the\n"
1041 " prevailing fee market. Must be one of:\n"
1044 " \"CONSERVATIVE\""},
1050 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
1055 "The request target will be clamped between 2 and the highest target\n"
1056 "fee estimation is able to return based on how long it has been running.\n"
1057 "An error is returned if not enough transactions and blocks\n"
1058 "have been observed to make an estimate for any number of blocks."},
1065 RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VSTR});
1069 bool conservative =
true;
1070 if (!request.params[1].isNull()) {
1085 errors.
push_back(
"Insufficient data or no feerate found");
1086 result.
pushKV(
"errors", errors);
1097 "\nWARNING: This interface is unstable and may disappear or change!\n"
1098 "\nWARNING: This is an advanced API call that is tightly coupled to the specific\n"
1099 " implementation of fee estimation. The parameters it can be called with\n"
1100 " and the results it returns will change if the internal implementation changes.\n"
1101 "\nEstimates the approximate fee per kilobyte needed for a transaction to begin\n"
1102 "confirmation within conf_target blocks if possible. Uses virtual transaction size as\n"
1103 "defined in BIP 141 (witness data is discounted).\n",
1106 {
"threshold",
RPCArg::Type::NUM,
"0.95",
"The proportion of transactions in a given feerate range that must have been\n"
1107 " confirmed within conf_target in order to consider those feerates as high enough and proceed to check\n"
1111 RPCResult::Type::OBJ,
"",
"Results are returned for any horizon which tracks blocks up to the confirmation target",
1116 {
RPCResult::Type::NUM,
"decay",
"exponential decay (per block) for historical moving average of confirmation data"},
1117 {
RPCResult::Type::NUM,
"scale",
"The resolution of confirmation targets at this time horizon"},
1118 {
RPCResult::Type::OBJ,
"pass",
true,
"information about the lowest range of feerates to succeed in meeting the threshold",
1122 {
RPCResult::Type::NUM,
"withintarget",
"number of txs over history horizon in the feerate range that were confirmed within target"},
1123 {
RPCResult::Type::NUM,
"totalconfirmed",
"number of txs over history horizon in the feerate range that were confirmed at any point"},
1124 {
RPCResult::Type::NUM,
"inmempool",
"current number of txs in mempool in the feerate range unconfirmed for at least target blocks"},
1125 {
RPCResult::Type::NUM,
"leftmempool",
"number of txs over history horizon in the feerate range that left mempool unconfirmed after target"},
1127 {
RPCResult::Type::OBJ,
"fail",
true,
"information about the highest range of feerates to fail to meet the threshold",
1131 {
RPCResult::Type::ARR,
"errors",
true,
"Errors encountered during processing (if there are any)",
1150 RPCTypeCheck(request.params, {UniValue::VNUM, UniValue::VNUM},
true);
1154 double threshold = 0.95;
1155 if (!request.params[1].isNull()) {
1156 threshold = request.params[1].get_real();
1158 if (threshold < 0 || threshold > 1) {
1193 horizon_result.
pushKV(
"scale", (
int)buckets.
scale);
1194 horizon_result.
pushKV(
"pass", passbucket);
1196 if (buckets.
fail.
start != -1) horizon_result.
pushKV(
"fail", failbucket);
1200 horizon_result.
pushKV(
"scale", (
int)buckets.
scale);
1201 horizon_result.
pushKV(
"fail", failbucket);
1202 errors.
push_back(
"Insufficient data or no feerate found which meets threshold");
1203 horizon_result.
pushKV(
"errors",errors);
1222 {
"mining",
"submitblock", &
submitblock, {
"hexdata",
"dummy"} },
1223 {
"mining",
"submitheader", &
submitheader, {
"hexdata"} },
1226 {
"generating",
"generatetoaddress", &
generatetoaddress, {
"nblocks",
"address",
"maxtries"} },
1227 {
"generating",
"generatetodescriptor", &
generatetodescriptor, {
"num_blocks",
"descriptor",
"maxtries"} },
1228 {
"generating",
"generateblock", &
generateblock, {
"output",
"transactions"} },
1230 {
"util",
"estimatesmartfee", &
estimatesmartfee, {
"conf_target",
"estimate_mode"} },
1232 {
"hidden",
"estimaterawfee", &
estimaterawfee, {
"conf_target",
"threshold"} },
1233 {
"hidden",
"generate", &
generate, {} },
1236 for (
const auto& c : commands) {
int64_t CAmount
Amount in satoshis (Can be negative)
NodeContext & EnsureNodeContext(const util::Ref &context)
CTxMemPool & EnsureMemPool(const util::Ref &context)
double GetDifficulty(const CBlockIndex *blockindex)
Get the difficulty of the net wrt to the given block index.
ChainstateManager & EnsureChainman(const util::Ref &context)
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok. Implies all parents are also at least SCRIPTS.
const CChainParams & Params()
Return the currently selected parameters.
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
Generate a new block, without valid proof-of-work.
static Optional< int64_t > m_last_block_weight
std::unique_ptr< CBlockTemplate > CreateNewBlock(const CScript &scriptPubKeyIn)
Construct a new block template with coinbase to scriptPubKeyIn.
static Optional< int64_t > m_last_block_num_txs
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
uint256 GetBlockHash() const
int64_t GetBlockTime() const
int64_t GetMedianTimePast() const
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
int nHeight
height of the entry in the chain. The genesis block has height 0
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
CFeeRate estimateRawFee(int confTarget, double successThreshold, FeeEstimateHorizon horizon, EstimationResult *result=nullptr) const
Return a specific fee estimate calculation with a given success threshold and time horizon,...
CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const
Estimate feerate needed to get be included in a block within confTarget blocks.
unsigned int HighestTargetTracked(FeeEstimateHorizon horizon) const
Calculation of highest target that estimates are tracked for.
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
Fee rate in satoshis per kilobyte: CAmount / kB.
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
const uint256 & GetHash() const
const std::vector< CTxIn > vin
const uint256 & GetWitnessHash() const
An input of a transaction.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
void PrioritiseTransaction(const uint256 &hash, const CAmount &nFeeDelta)
Affect CreateNewBlock prioritisation of transactions.
CTransactionRef get(const uint256 &hash) const
unsigned long size() const
unsigned int GetTransactionsUpdated() const
Implement this to subscribe to events generated in validation.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
bool ProcessNewBlock(const CChainParams &chainparams, const std::shared_ptr< const CBlock > pblock, bool fForceProcessing, bool *fNewBlock) LOCKS_EXCLUDED(cs_main)
Process an incoming block.
bool ProcessNewBlockHeaders(const std::vector< CBlockHeader > &block, BlockValidationState &state, const CChainParams &chainparams, const CBlockIndex **ppindex=nullptr) LOCKS_EXCLUDED(cs_main)
Process incoming block headers.
const std::string & get_str() const
int64_t get_int64() const
const UniValue & get_obj() const
bool push_back(const UniValue &val)
bool pushKV(const std::string &key, const 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
void BlockChecked(const CBlock &block, const BlockValidationState &stateIn) override
Notifies listeners of a block validation result.
submitblock_StateCatcher(const uint256 &hashIn)
BlockValidationState state
static int64_t GetTransactionWeight(const CTransaction &tx)
static const unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE
The maximum allowed size for a serialized block, in bytes (only for buffer size limits)
static const int64_t MAX_BLOCK_SIGOPS_COST
The maximum allowed number of signature check operations in a block (network rule)
static const int WITNESS_SCALE_FACTOR
NODISCARD bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
UniValue ValueFromAmount(const CAmount &amount)
NODISCARD 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)
std::unique_ptr< Descriptor > Parse(const std::string &descriptor, FlatSigningProvider &out, std::string &error, bool require_checksum)
Parse a descriptor string.
const std::string CURRENCY_UNIT
@ ECONOMICAL
Force estimateSmartFee to use non-conservative estimates.
CTxDestination DecodeDestination(const std::string &str)
void RegenerateCommitments(CBlock &block)
Update an old GenerateCoinbaseCommitment from CreateNewBlock after the block txs have changed.
void IncrementExtraNonce(CBlock *pblock, const CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
Modify the extranonce in a block.
int64_t UpdateTime(CBlockHeader *pblock, const Consensus::Params &consensusParams, const CBlockIndex *pindexPrev)
static UniValue generateBlocks(ChainstateManager &chainman, const CTxMemPool &mempool, const CScript &coinbase_script, int nGenerate, uint64_t nMaxTries)
static RPCHelpMan generateblock()
static RPCHelpMan generatetodescriptor()
static bool getScriptFromDescriptor(const std::string &descriptor, CScript &script, std::string &error)
static RPCHelpMan estimatesmartfee()
static RPCHelpMan getnetworkhashps()
static UniValue BIP22ValidationResult(const BlockValidationState &state)
static RPCHelpMan submitblock()
static RPCHelpMan getblocktemplate()
static RPCHelpMan generate()
static RPCHelpMan submitheader()
static bool GenerateBlock(ChainstateManager &chainman, CBlock &block, uint64_t &max_tries, unsigned int &extra_nonce, uint256 &block_hash)
static RPCHelpMan prioritisetransaction()
static RPCHelpMan getmininginfo()
static RPCHelpMan generatetoaddress()
static std::string gbt_vb_name(const Consensus::DeploymentPos pos)
static UniValue GetNetworkHashPS(int lookup, int height)
Return average network hashes per second based on the last 'lookup' blocks, or from the last difficul...
void RegisterMiningRPCCommands(CRPCTable &t)
Register mining RPC commands.
static RPCHelpMan estimaterawfee()
static const uint64_t DEFAULT_MAX_TRIES
Default max iterations to try in RPC generatetodescriptor, generatetoaddress, and generateblock.
@ MAX_VERSION_BITS_DEPLOYMENTS
const std::chrono::seconds now
std::deque< CInv >::iterator it
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon)
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 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.
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
@ RPC_CLIENT_NOT_CONNECTED
P2P client errors.
@ 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.
@ RPC_CLIENT_P2P_DISABLED
No valid connection manager instance found.
bool IsRPCRunning()
Query whether RPC is running.
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.
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
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)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
A mutable version of CTransaction.
int bit
Bit position to select the particular bit in nVersion.
Parameters that influence chain consensus.
int64_t DifficultyAdjustmentInterval() const
int SegwitHeight
Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active.
BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]
NodeContext struct containing references to chain state and connection state.
std::unique_ptr< CConnman > connman
@ STR_HEX
Special type that is a STR with only hex chars.
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
bool gbt_force
Whether GBT clients can safely ignore this rule in simplified usage.
const char * name
Deployment name.
#define WAIT_LOCK(cs, name)
#define ENTER_CRITICAL_SECTION(cs)
#define LEAVE_CRITICAL_SECTION(cs)
bool error(const char *fmt, const Args &... args)
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
const UniValue & find_value(const UniValue &obj, const std::string &name)
const UniValue NullUniValue
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
const std::string InvalidEstimateModeErrorMessage()
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
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.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
CBlockPolicyEstimator feeEstimator
std::condition_variable g_best_block_cv
CChain & ChainActive()
Please prefer the identical ChainstateManager::ActiveChain.
CChainState & ChainstateActive()
Please prefer the identical ChainstateManager::ActiveChainstate.
void UpdateUncommittedBlockStructures(CBlock &block, const CBlockIndex *pindexPrev, const Consensus::Params &consensusParams)
Update uncommitted block structures (currently: only the witness reserved value).
CBlockIndex * LookupBlockIndex(const uint256 &hash)
bool TestBlockValidity(BlockValidationState &state, const CChainParams &chainparams, 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)
VersionBitsCache versionbitscache
void UnregisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Unregister subscriber.
void RegisterSharedValidationInterface(std::shared_ptr< CValidationInterface > callbacks)
Register subscriber.
uint32_t VersionBitsMask(const Consensus::Params ¶ms, Consensus::DeploymentPos pos)
ThresholdState VersionBitsState(const CBlockIndex *pindexPrev, const Consensus::Params ¶ms, Consensus::DeploymentPos pos, VersionBitsCache &cache)
ThresholdState
BIP 9 defines a finite-state-machine to deploy a softfork in multiple stages.
const struct VBDeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION_BITS_DEPLOYMENTS]
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.