81 entry.
pushKV(
"confirmations", 0);
92 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
97 static std::vector<RPCResult>
DecodeTxDoc(
const std::string& txid_field_doc)
103 {
RPCResult::Type::NUM,
"vsize",
"The virtual transaction size (differs from size for witness transactions)"},
153 "That is, each address can only appear once and there can only be one 'data' object.\n"
154 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
155 " accepted as second parameter.",
171 "Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
180 "By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled\n"
181 "and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.\n"
182 "If a blockhash argument is passed, it will return the transaction if\n"
183 "the specified block is available and the transaction is in that block.\n\n"
184 "Hint: Use gettransaction for wallet transactions.\n\n"
186 "If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.\n"
187 "If verbosity is 1, returns a JSON Object with information about the transaction.\n"
188 "If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.",
196 RPCResult{
"if verbosity is not set or set to 0",
201 Cat<std::vector<RPCResult>>(
203 {
RPCResult::Type::BOOL,
"in_active_chain",
true,
"Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
210 DecodeTxDoc(
"The transaction id (same as provided)")),
237 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 0 \"myblockhash\"")
238 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 1 \"myblockhash\"")
239 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 2 \"myblockhash\"")
256 if (!request.params[1].isNull()) {
257 if (request.params[1].isBool()) {
258 verbosity = request.params[1].get_bool();
260 verbosity = request.params[1].getInt<
int>();
264 if (!request.params[2].isNull()) {
274 bool f_txindex_ready =
false;
276 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
285 if (!block_has_data) {
288 errmsg =
"No such transaction found in the provided block";
290 errmsg =
"No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries";
291 }
else if (!f_txindex_ready) {
292 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
294 errmsg =
"No such mempool or blockchain transaction";
299 if (verbosity <= 0) {
309 if (request.params[2].isNull()) {
313 if (verbosity == 1) {
322 if (tx->IsCoinBase() ||
323 !blockindex || is_block_pruned ||
331 if (it != block.
vtx.end()) {
333 undoTX = &blockUndo.
vtxundo.at(it - block.
vtx.begin() - 1);
344 "\nCreate a transaction spending the given inputs and creating new outputs.\n"
345 "Outputs can be addresses or data.\n"
346 "Returns hex-encoded raw transaction.\n"
347 "Note that the transaction's inputs are not signed, and\n"
348 "it is not stored in the wallet or transmitted to the network.\n",
354 HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
355 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
356 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
357 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
361 std::optional<bool> rbf;
362 if (!request.params[3].isNull()) {
375 "Return a JSON object representing the serialized, hex-encoded transaction.",
379 "If iswitness is not present, heuristic tests will be used in decoding.\n"
380 "If true, only witness deserialization will be tried.\n"
381 "If false, only non-witness deserialization will be tried.\n"
382 "This boolean should reflect whether the transaction has inputs\n"
383 "(e.g. fully valid, or on-chain transactions), if known by the caller."
398 bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool();
399 bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool();
401 if (!
DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) {
417 "\nDecode a hex-encoded script.\n",
427 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
429 "address of P2SH script wrapping this redeem script (not returned for types that should not be wrapped)"},
431 "Result of a witness script public key wrapping this redeem script (not returned for types that should not be wrapped)",
435 {
RPCResult::Type::STR,
"type",
"The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)"},
436 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
438 {
RPCResult::Type::STR,
"p2sh-segwit",
"address of the P2SH script wrapping this witness redeem script"},
450 if (request.params[0].get_str().size() > 0){
451 std::vector<unsigned char> scriptData(
ParseHexV(request.params[0],
"argument"));
452 script =
CScript(scriptData.begin(), scriptData.end());
458 std::vector<std::vector<unsigned char>> solutions_data;
461 const bool can_wrap{[&] {
462 switch (which_type) {
495 const bool can_wrap_P2WSH{[&] {
496 switch (which_type) {
501 for (
const auto& solution : solutions_data) {
522 if (can_wrap_P2WSH) {
549 "\nCombine multiple partially signed transactions into one transaction.\n"
550 "The combined transaction may be another partially signed transaction or a \n"
551 "fully signed transaction.",
563 HelpExampleCli(
"combinerawtransaction", R
"('["myhex1", "myhex2", "myhex3"]')")
569 std::vector<CMutableTransaction> txVariants(txs.
size());
571 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
572 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
577 if (txVariants.empty()) {
597 for (
const CTxIn& txin : mergedTx.
vin) {
608 for (
unsigned int i = 0; i < mergedTx.
vin.size(); i++) {
618 if (txv.vin.size() > i) {
634 return RPCHelpMan{
"signrawtransactionwithkey",
635 "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
636 "The second argument is an array of base58-encoded private\n"
637 "keys that will be the only keys used to sign the transaction.\n"
638 "The third optional argument (may be null) is an array of previous transaction outputs that\n"
639 "this transaction depends on but may not yet be in the block chain.\n",
666 " \"ALL|ANYONECANPAY\"\n"
667 " \"NONE|ANYONECANPAY\"\n"
668 " \"SINGLE|ANYONECANPAY\"\n"
694 HelpExampleCli(
"signrawtransactionwithkey",
"\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
695 +
HelpExampleRpc(
"signrawtransactionwithkey",
"\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
700 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
706 for (
unsigned int idx = 0; idx < keys.
size(); ++idx) {
716 std::map<COutPoint, Coin> coins;
738 {
RPCResult::Type::OBJ,
"non_witness_utxo",
true,
"Decoded network transaction for non-witness UTXOs",
751 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
808 {
RPCResult::Type::OBJ,
"signature",
true,
"The signature for the pubkey and leaf hash combination",
887 {
RPCResult::Type::ARR,
"taproot_tree",
true,
"The tuples that make up the Taproot tree, in depth first search order",
931 "Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.",
951 {
RPCResult::Type::NUM,
"psbt_version",
"The PSBT version number. Not to be confused with the unsigned transaction version"},
988 result.
pushKV(
"tx", tx_univ);
993 for (
auto& xpub : xpub_pair.second) {
994 std::vector<unsigned char> ser_xpub;
996 xpub.EncodeWithVersion(ser_xpub.data());
1005 result.
pushKV(
"global_xpubs", global_xpubs);
1014 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1015 this_prop.
pushKV(
"subtype", entry.subtype);
1020 result.
pushKV(
"proprietary", proprietary);
1024 for (
auto entry : psbtx.
unknown) {
1027 result.
pushKV(
"unknown", unknowns);
1031 bool have_all_utxos =
true;
1033 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
1037 bool have_a_utxo =
false;
1047 out.
pushKV(
"scriptPubKey", o);
1049 in.
pushKV(
"witness_utxo", out);
1058 in.
pushKV(
"non_witness_utxo", non_wit);
1064 total_in += txout.
nValue;
1067 have_all_utxos =
false;
1070 have_all_utxos =
false;
1079 in.
pushKV(
"partial_signatures", partial_sigs);
1091 in.
pushKV(
"redeem_script", r);
1096 in.
pushKV(
"witness_script", r);
1110 in.
pushKV(
"bip32_derivs", keypaths);
1118 in.
pushKV(
"final_scriptSig", scriptsig);
1125 in.
pushKV(
"final_scriptwitness", txinwitness);
1134 in.
pushKV(
"ripemd160_preimages", ripemd160_preimages);
1143 in.
pushKV(
"sha256_preimages", sha256_preimages);
1152 in.
pushKV(
"hash160_preimages", hash160_preimages);
1161 in.
pushKV(
"hash256_preimages", hash256_preimages);
1173 const auto& [xonly, leaf_hash] = pubkey_leaf;
1180 in.
pushKV(
"taproot_script_path_sigs", script_sigs);
1186 for (
const auto& [leaf, control_blocks] : input.
m_tap_scripts) {
1187 const auto& [script, leaf_ver] = leaf;
1190 script_info.
pushKV(
"leaf_ver", leaf_ver);
1192 for (
const auto& control_block : control_blocks) {
1195 script_info.
pushKV(
"control_blocks", control_blocks_univ);
1198 in.
pushKV(
"taproot_scripts", tap_scripts);
1205 const auto& [leaf_hashes, origin] = leaf_origin;
1211 for (
const auto& leaf_hash : leaf_hashes) {
1214 path_obj.
pushKV(
"leaf_hashes", leaf_hashes_arr);
1217 in.
pushKV(
"taproot_bip32_derivs", keypaths);
1235 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1236 this_prop.
pushKV(
"subtype", entry.subtype);
1241 in.
pushKV(
"proprietary", proprietary);
1245 if (input.
unknown.size() > 0) {
1247 for (
auto entry : input.
unknown) {
1250 in.
pushKV(
"unknown", unknowns);
1255 result.
pushKV(
"inputs", inputs);
1260 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
1267 out.
pushKV(
"redeem_script", r);
1272 out.
pushKV(
"witness_script", r);
1285 out.
pushKV(
"bip32_derivs", keypaths);
1296 for (
const auto& [depth, leaf_ver, script] : output.
m_tap_tree) {
1298 elem.
pushKV(
"depth", (
int)depth);
1299 elem.
pushKV(
"leaf_ver", (
int)leaf_ver);
1303 out.
pushKV(
"taproot_tree", tree);
1310 const auto& [leaf_hashes, origin] = leaf_origin;
1316 for (
const auto& leaf_hash : leaf_hashes) {
1319 path_obj.
pushKV(
"leaf_hashes", leaf_hashes_arr);
1322 out.
pushKV(
"taproot_bip32_derivs", keypaths);
1330 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1331 this_prop.
pushKV(
"subtype", entry.subtype);
1336 out.
pushKV(
"proprietary", proprietary);
1340 if (output.
unknown.size() > 0) {
1342 for (
auto entry : output.
unknown) {
1345 out.
pushKV(
"unknown", unknowns);
1352 output_value += psbtx.
tx->vout[i].nValue;
1355 have_all_utxos =
false;
1358 result.
pushKV(
"outputs", outputs);
1359 if (have_all_utxos) {
1371 "\nCombine multiple partially signed Bitcoin transactions into one transaction.\n"
1372 "Implements the Combiner role.\n",
1384 HelpExampleCli(
"combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")
1389 std::vector<PartiallySignedTransaction> psbtxs;
1394 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1400 psbtxs.push_back(psbtx);
1410 ssTx << merged_psbt;
1419 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n"
1420 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n"
1421 "created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n"
1422 "Implements the Finalizer and Extractor roles.\n",
1426 " extract and return the complete transaction in normal network serialization instead of the PSBT."},
1431 {
RPCResult::Type::STR,
"psbt",
true,
"The base64-encoded partially signed transaction if not extracted"},
1448 bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
1455 std::string result_str;
1459 result_str =
HexStr(ssTx);
1460 result.
pushKV(
"hex", result_str);
1464 result.
pushKV(
"psbt", result_str);
1466 result.
pushKV(
"complete", complete);
1476 "\nCreates a transaction in the Partially Signed Transaction format.\n"
1477 "Implements the Creator role.\n",
1483 HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
1488 std::optional<bool> rbf;
1489 if (!request.params[3].isNull()) {
1490 rbf = request.params[3].
get_bool();
1497 for (
unsigned int i = 0; i < rawTx.
vin.size(); ++i) {
1500 for (
unsigned int i = 0; i < rawTx.
vout.size(); ++i) {
1516 "\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n"
1517 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
1521 " will continue. If false, RPC will fail if any signatures are present."},
1523 "If iswitness is not present, heuristic tests will be used in decoding.\n"
1524 "If true, only witness deserialization will be tried.\n"
1525 "If false, only non-witness deserialization will be tried.\n"
1526 "This boolean should reflect whether the transaction has inputs\n"
1527 "(e.g. fully valid, or on-chain transactions), if known by the caller."
1534 "\nCreate a transaction\n"
1535 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1536 "\nConvert the transaction to a PSBT\n"
1543 bool permitsigdata = request.params[1].isNull() ? false : request.params[1].get_bool();
1544 bool witness_specified = !request.params[2].isNull();
1545 bool iswitness = witness_specified ? request.params[2].get_bool() :
false;
1546 const bool try_witness = witness_specified ? iswitness :
true;
1547 const bool try_no_witness = witness_specified ? !iswitness :
true;
1548 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
1564 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
1567 for (
unsigned int i = 0; i < tx.
vout.size(); ++i) {
1583 "\nUpdates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set or the mempool.\n",
1595 RPCResult::Type::STR,
"",
"The base64-encoded partially signed transaction with inputs updated"
1611 if (!request.params[1].isNull()) {
1612 auto descs = request.params[1].get_array();
1613 for (
size_t i = 0; i < descs.size(); ++i) {
1632 for (
const CTxIn& txin : psbtx.
tx->vin) {
1641 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
1661 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1675 "\nJoins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n"
1676 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1692 std::vector<PartiallySignedTransaction> psbtxs;
1695 if (txs.
size() <= 1) {
1699 uint32_t best_version = 1;
1700 uint32_t best_locktime = 0xffffffff;
1701 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1707 psbtxs.push_back(psbtx);
1709 if (
static_cast<uint32_t
>(psbtx.
tx->nVersion) > best_version) {
1710 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1713 if (psbtx.
tx->nLockTime < best_locktime) {
1714 best_locktime = psbtx.
tx->nLockTime;
1721 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1722 merged_psbt.
tx->nLockTime = best_locktime;
1725 for (
auto& psbt : psbtxs) {
1726 for (
unsigned int i = 0; i < psbt.tx->vin.size(); ++i) {
1727 if (!merged_psbt.
AddInput(psbt.tx->vin[i], psbt.inputs[i])) {
1731 for (
unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
1732 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1734 for (
auto& xpub_pair : psbt.m_xpubs) {
1735 if (merged_psbt.
m_xpubs.count(xpub_pair.first) == 0) {
1736 merged_psbt.
m_xpubs[xpub_pair.first] = xpub_pair.second;
1738 merged_psbt.
m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
1741 merged_psbt.
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
1745 std::vector<int> input_indices(merged_psbt.
inputs.size());
1746 std::iota(input_indices.begin(), input_indices.end(), 0);
1747 std::vector<int> output_indices(merged_psbt.
outputs.size());
1748 std::iota(output_indices.begin(), output_indices.end(), 0);
1756 shuffled_psbt.
tx->nVersion = merged_psbt.
tx->nVersion;
1757 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1758 for (
int i : input_indices) {
1761 for (
int i : output_indices) {
1767 ssTx << shuffled_psbt;
1776 "\nAnalyzes and provides information about the current status of a PSBT and its inputs\n",
1789 {
RPCResult::Type::OBJ,
"missing",
true,
"Things that are missing that are required to complete this input",
1793 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing"},
1797 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose signature is missing"},
1802 {
RPCResult::Type::STR,
"next",
true,
"Role of the next person that this input needs to go to"},
1805 {
RPCResult::Type::NUM,
"estimated_vsize",
true,
"Estimated vsize of the final signed transaction"},
1806 {
RPCResult::Type::STR_AMOUNT,
"estimated_feerate",
true,
"Estimated feerate of the final signed transaction in " +
CURRENCY_UNIT +
"/kvB. Shown only if all UTXO slots in the PSBT have been filled"},
1807 {
RPCResult::Type::STR_AMOUNT,
"fee",
true,
"The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled"},
1828 for (
const auto& input : psbta.
inputs) {
1832 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1833 input_univ.
pushKV(
"is_final", input.is_final);
1836 if (!input.missing_pubkeys.empty()) {
1838 for (
const CKeyID& pubkey : input.missing_pubkeys) {
1841 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
1843 if (!input.missing_redeem_script.IsNull()) {
1844 missing.
pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
1846 if (!input.missing_witness_script.IsNull()) {
1847 missing.
pushKV(
"witnessscript",
HexStr(input.missing_witness_script));
1849 if (!input.missing_sigs.empty()) {
1851 for (
const CKeyID& pubkey : input.missing_sigs) {
1854 missing.
pushKV(
"signatures", missing_sigs_univ);
1856 if (!missing.
getKeys().empty()) {
1857 input_univ.
pushKV(
"missing", missing);
1861 if (!inputs_result.
empty()) result.
pushKV(
"inputs", inputs_result);
1869 if (psbta.
fee != std::nullopt) {
1873 if (!psbta.
error.empty()) {
1900 for (
const auto& c : commands) {
1901 t.appendCommand(c.name, &c);
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
std::string EncodeBase58Check(Span< const unsigned char > input)
Encode a byte span into a base58-encoded string, including checksum.
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
@ BLOCK_HAVE_DATA
full block available in blk*.dat
const CChainParams & Params()
Return the currently selected parameters.
#define CHECK_NONFATAL(condition)
Identity function.
#define NONFATAL_UNREACHABLE()
NONFATAL_UNREACHABLE() is a macro that is used to mark unreachable code.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
int64_t GetBlockTime() const
int nHeight
height of the entry in the chain. The genesis block has height 0
Undo information for a CBlock.
std::vector< CTxUndo > vtxundo
int Height() const
Return the maximal height in the chain.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
const CBlock & GenesisBlock() const
void SetBackend(CCoinsView &viewIn)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
Abstract view on the open txout dataset.
CCoinsView that brings transactions from a mempool into view.
An encapsulated private key.
bool IsValid() const
Check whether this private key is valid.
A reference to a CKey: the Hash160 of its serialized public key.
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
Serialized script, used inside transaction inputs and outputs.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
bool HasValidOps() const
Check if the script contains valid OP_CODES.
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
CScriptWitness scriptWitness
Only serialized through CTransaction.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
An output of a transaction.
Undo information for a CTransaction.
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.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
node::BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all Chainstate instances.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
const CChainParams & GetParams() const
Chainstate & ActiveChainstate() const
The most-work chain.
const Consensus::Params & GetConsensus() const
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
CTxOut out
unspent transaction output
bool IsSpent() const
Either this coin never existed (see e.g.
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddCScript(const CScript &redeemScript)
virtual bool AddKey(const CKey &key)
A signature creator for transactions.
A Span is an object that can refer to a contiguous sequence of objects.
void push_back(UniValue val)
const std::vector< std::string > & getKeys() const
const UniValue & get_array() const
void pushKV(std::string key, UniValue val)
bool IsNull() const
Test whether this is the 0 key (the result of default construction).
constexpr bool IsNull() const
std::string GetHex() const
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::string SighashToStr(unsigned char sighash_type)
TxVerbosity
Verbose level for block's transaction.
@ SHOW_DETAILS_AND_PREVOUT
The same as previous option with information about prevouts if available.
@ SHOW_DETAILS
Include TXID, inputs, outputs, and other common block's transaction information.
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex=true, bool include_address=false, const SigningProvider *provider=nullptr)
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
UniValue ValueFromAmount(const CAmount amount)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
static uint32_t ReadBE32(const unsigned char *ptr)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
const std::string CURRENCY_UNIT
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
std::string EncodeDestination(const CTxDestination &dest)
CKey DecodeSecret(const std::string &str)
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const uint256 &hash, const Consensus::Params &consensusParams, uint256 &hashBlock)
Return transaction with a given hash.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex *pindex)
std::shared_ptr< const CTransaction > CTransactionRef
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
std::string PSBTRoleName(PSBTRole role)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, int sighash, SignatureData *out_sigdata, bool finalize)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
TransactionError CombinePSBTs(PartiallySignedTransaction &out, const std::vector< PartiallySignedTransaction > &psbtxs)
Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial sign...
const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
void Shuffle(I first, I last, R &&rng)
More efficient than using std::shuffle on a FastRandomContext.
static RPCHelpMan getrawtransaction()
static RPCHelpMan utxoupdatepsbt()
const RPCResult decodepsbt_inputs
static void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry, Chainstate &active_chainstate, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
static RPCHelpMan converttopsbt()
const RPCResult decodepsbt_outputs
static RPCHelpMan analyzepsbt()
static RPCHelpMan decoderawtransaction()
static RPCHelpMan combinepsbt()
static RPCHelpMan decodepsbt()
static RPCHelpMan decodescript()
static RPCHelpMan createpsbt()
static RPCHelpMan joinpsbts()
static RPCHelpMan combinerawtransaction()
static std::vector< RPCResult > ScriptPubKeyDoc()
static RPCHelpMan signrawtransactionwithkey()
static std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc)
static RPCHelpMan createrawtransaction()
static RPCHelpMan finalizepsbt()
void RegisterRawTransactionRPCCommands(CRPCTable &t)
static std::vector< RPCArg > CreateTxDoc()
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, std::optional< bool > rbf)
Create a transaction from univalue parameters.
void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, const std::map< COutPoint, Coin > &coins, const UniValue &hashType, UniValue &result)
Sign a transaction with the given keystore and previous transactions.
void ParsePrevouts(const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_MISC_ERROR
General application defined errors.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_VERIFY_ERROR
General error during transaction or block submission.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
std::vector< CScript > EvalDescriptorStringOrObject(const UniValue &scanobject, FlatSigningProvider &provider)
Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range ...
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()
Gets all existing output types formatted for RPC help sections.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
#define extract(n)
Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits.
bool IsOpSuccess(const opcodetype &opcode)
Test for OP_SUCCESSx opcodes as defined by BIP342.
opcodetype
Script opcodes.
int RPCSerializationFlags()
NodeContext & EnsureAnyNodeContext(const std::any &context)
CTxMemPool & EnsureMemPool(const NodeContext &node)
ChainstateManager & EnsureChainman(const NodeContext &node)
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
void UpdateInput(CTxIn &input, const SignatureData &data)
bool IsSegWitOutput(const SigningProvider &provider, const CScript &script)
Check whether a scriptPubKey is known to be segwit.
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
const SigningProvider & DUMMY_SIGNING_PROVIDER
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
@ NULL_DATA
unspendable OP_RETURN script that carries data
A mutable version of CTransaction.
std::vector< CTxOut > vout
std::vector< std::vector< unsigned char > > stack
A structure for PSBTs which contains per output information.
XOnlyPubKey m_tap_internal_key
std::map< XOnlyPubKey, std::pair< std::set< uint256 >, KeyOriginInfo > > m_tap_bip32_paths
std::set< PSBTProprietary > m_proprietary
std::map< CPubKey, KeyOriginInfo > hd_keypaths
std::vector< std::tuple< uint8_t, uint8_t, std::vector< unsigned char > > > m_tap_tree
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
A version of CTransaction with the PSBT format.
uint32_t GetVersion() const
std::map< KeyOriginInfo, std::set< CExtPubKey > > m_xpubs
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
std::vector< PSBTInput > inputs
std::optional< CMutableTransaction > tx
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
std::vector< PSBTOutput > outputs
std::set< PSBTProprietary > m_proprietary
@ RANGE
Special type that is a NUM or [NUM,NUM].
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e....
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
std::string DefaultHint
Hint for default value.
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
@ 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.
@ STR_AMOUNT
Special string to represent a floating point amount.
void MergeSignatureData(SignatureData sigdata)
NodeContext struct containing references to chain state and connection state.
Holds the results of AnalyzePSBT (miscellaneous information about a PSBT)
std::vector< PSBTInputAnalysis > inputs
More information about the individual inputs of the transaction.
std::string error
Error message.
std::optional< CAmount > fee
Amount of fee being paid by the transaction.
std::optional< size_t > estimated_vsize
Estimated weight of the transaction.
std::optional< CFeeRate > estimated_feerate
Estimated feerate (fee / weight) of the transaction.
PSBTRole next
Which of the BIP 174 roles needs to handle the transaction next.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
bool error(const char *fmt, const Args &... args)
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const unsigned char > input)
static const int PROTOCOL_VERSION
network protocol versioning