7#include <chainparams.h>
19#include <validation.h>
26 "Returns a hex-encoded proof that \"txid\" was included in a block.\n"
27 "\nNOTE: By default this function only works sometimes. "
28 "This is when there is an\n"
29 "unspent output in the utxo for this transaction. To make it always "
31 "you need to maintain a transaction index, using the -txindex command "
33 "specify the block in which the transaction is included manually (by "
40 "The txids to filter",
43 "A transaction hash"},
48 "If specified, looks for txid in the block with this hash"},
52 "A string that is a serialized, hex-encoded data for the proof."},
59 for (
unsigned int idx = 0; idx < txids.
size(); idx++) {
65 std::string(
"Invalid parameter, duplicated txid: ") +
77 if (!request.params[1].isNull()) {
105 g_txindex->BlockUntilSyncedToCurrentChain();
113 if (!tx || hashBlock.
IsNull()) {
115 "Transaction not yet in block");
122 "Transaction index corrupt");
129 "Can't read block from disk");
133 for (
const auto &tx : block.
vtx) {
141 "Not all transactions found in specified or "
157 "Verifies that a proof points to a transaction in a block, returning "
158 "the transaction it commits to\n"
159 "and throwing an RPC error if the block is not in our best chain\n",
162 "The hex-encoded proof generated by gettxoutproof"},
169 "The txid(s) which the proof commits to, or empty array "
170 "if the proof can not be validated."},
182 std::vector<uint256>
vMatch;
183 std::vector<size_t>
vIndex;
197 "Block not found in chain");
203 res.push_back(hash.GetHex());
219 for (
const auto &
c : commands) {
220 t.appendCommand(
c.name, &
c);
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
unsigned int nTx
Number of transactions in this block.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
Double ended buffer combining vector and stream-like interfaces.
Used to create a Merkle proof (usually from a subset of transactions), which consists of a block head...
Chainstate stores and provides an API to update our local knowledge of the current best chain.
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(Chainstate & ActiveChainstate() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
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...
uint32_t GetHeight() const
const UniValue & get_array() const
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos) const
Functions for disk access for blocks.
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
const Coin & AccessByTxid(const CCoinsViewCache &view, const TxId &txid)
Utility function to find any unspent output with a given txid.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const TxId &txid, BlockHash &hashBlock, const BlockManager &blockman)
Return transaction with a given txid.
std::shared_ptr< const CTransaction > CTransactionRef
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::vector< uint8_t > ParseHexV(const UniValue &v, std::string strName)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
ChainstateManager & EnsureAnyChainman(const std::any &context)
A BlockHash is a unqiue identifier for a block.
@ STR_HEX
Special type that is a STR with only hex chars.
@ OMITTED
The arg is optional for one of two reasons:
@ STR_HEX
Special string with only hex chars.
A TxId is the identifier of a transaction.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
void RegisterTxoutProofRPCCommands(CRPCTable &t)
static RPCHelpMan gettxoutproof()
static RPCHelpMan verifytxoutproof()
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
static const int PROTOCOL_VERSION
network protocol versioning