82 entry.
pushKV(
"confirmations", 0);
102 "Each key may only appear once, i.e. there can only be one 'data' output, and no address may be duplicated.\n"
103 "At least one output of either type must be specified.\n"
104 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
105 " accepted as second parameter.",
121 "Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
143 std::map<COutPoint, Coin> coins;
147 for (
unsigned int i = 0; i <
psbtx.tx->vin.size(); ++i) {
163 tx =
node.mempool->get(
tx_in.prevout.hash);
168 coins[
tx_in.prevout];
173 if (!coins.empty()) {
174 FindCoins(
node, coins);
175 for (
unsigned int i = 0; i <
psbtx.tx->vin.size(); ++i) {
181 const Coin& coin = coins.at(
tx_in.prevout);
191 for (
unsigned int i = 0; i <
psbtx.tx->vin.size(); ++i) {
207 for (
unsigned int i = 0; i <
psbtx.tx->vout.size(); ++i) {
221 "By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled\n"
222 "and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.\n"
223 "If a blockhash argument is passed, it will return the transaction if\n"
224 "the specified block is available and the transaction is in that block.\n\n"
225 "Hint: Use gettransaction for wallet transactions.\n\n"
227 "If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.\n"
228 "If verbosity is 1, returns a JSON Object with information about the transaction.\n"
229 "If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.",
237 RPCResult{
"if verbosity is not set or set to 0",
244 {
RPCResult::Type::BOOL,
"in_active_chain",
true,
"Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
251 DecodeTxDoc(
"The transaction id (same as provided)",
false)),
263 {
RPCResult::Type::OBJ,
"prevout",
true,
"The previous output, omitted if block undo data is not available",
278 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 0 \"myblockhash\"")
279 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 1 \"myblockhash\"")
280 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 2 \"myblockhash\"")
297 if (!request.params[2].isNull()) {
321 errmsg =
"No such transaction found in the provided block";
323 errmsg =
"No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries";
325 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
327 errmsg =
"No such mempool or blockchain transaction";
342 if (request.params[2].isNull()) {
359 throw JSONRPCError(
RPC_INTERNAL_ERROR,
"Undo data expected but can't be read. This could be due to disk corruption or a conflict with a pruning event.");
362 throw JSONRPCError(
RPC_INTERNAL_ERROR,
"Block data expected but can't be read. This could be due to disk corruption or a conflict with a pruning event.");
367 if (it != block.
vtx.end()) {
380 "createrawtransaction",
381 "Create a transaction spending the given inputs and creating new outputs.\n"
382 "Outputs can be addresses or data.\n"
383 "Returns hex-encoded raw transaction.\n"
384 "Note that the transaction's inputs are not signed, and\n"
385 "it is not stored in the wallet or transmitted to the network.\n",
391 HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
392 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
393 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
394 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
398 std::optional<bool>
rbf;
399 if (!request.params[3].isNull()) {
412 "Return a JSON object representing the serialized, hex-encoded transaction.",
416 "If iswitness is not present, heuristic tests will be used in decoding.\n"
417 "If true, only witness deserialization will be tried.\n"
418 "If false, only non-witness deserialization will be tried.\n"
419 "This boolean should reflect whether the transaction has inputs\n"
420 "(e.g. fully valid, or on-chain transactions), if known by the caller."
435 bool try_witness = request.params[1].isNull() ?
true : request.params[1].get_bool();
436 bool try_no_witness = request.params[1].isNull() ?
true : !request.params[1].get_bool();
454 "Decode a hex-encoded script.\n",
464 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
466 "address of P2SH script wrapping this redeem script (not returned for types that should not be wrapped)"},
468 "Result of a witness output script wrapping this redeem script (not returned for types that should not be wrapped)",
472 {
RPCResult::Type::STR,
"type",
"The type of the output script (e.g. witness_v0_keyhash or witness_v0_scripthash)"},
473 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
475 {
RPCResult::Type::STR,
"p2sh-segwit",
"address of the P2SH script wrapping this witness redeem script"},
487 if (request.params[0].get_str().size() > 0){
588 "combinerawtransaction",
589 "Combine multiple partially signed transactions into one transaction.\n"
590 "The combined transaction may be another partially signed transaction or a \n"
591 "fully signed transaction.",
603 HelpExampleCli(
"combinerawtransaction", R
"('["myhex1", "myhex2", "myhex3"]')")
611 for (
unsigned int idx = 0; idx <
txs.size(); idx++) {
648 for (
unsigned int i = 0; i <
mergedTx.vin.size(); i++) {
658 if (
txv.vin.size() > i) {
675 "signrawtransactionwithkey",
676 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
677 "The second argument is an array of base58-encoded private\n"
678 "keys that will be the only keys used to sign the transaction.\n"
679 "The third optional argument (may be null) is an array of previous transaction outputs that\n"
680 "this transaction depends on but may not yet be in the block chain.\n",
707 " \"ALL|ANYONECANPAY\"\n"
708 " \"NONE|ANYONECANPAY\"\n"
709 " \"SINGLE|ANYONECANPAY\"\n"
735 HelpExampleCli(
"signrawtransactionwithkey",
"\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
736 +
HelpExampleRpc(
"signrawtransactionwithkey",
"\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
747 for (
unsigned int idx = 0; idx < keys.
size(); ++idx) {
761 std::map<COutPoint, Coin> coins;
766 FindCoins(
node, coins);
783 {
RPCResult::Type::OBJ,
"non_witness_utxo",
true,
"Decoded network transaction for non-witness UTXOs",
796 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
853 {
RPCResult::Type::OBJ,
"signature",
true,
"The signature for the pubkey and leaf hash combination",
891 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which the participants create."},
902 {
RPCResult::Type::STR_HEX,
"participant_pubkey",
"The compressed public key of the participant that created this pubnonce."},
903 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which this pubnonce is for."},
904 {
RPCResult::Type::STR_HEX,
"leaf_hash",
true,
"The hash of the leaf script that contains the aggregate pubkey being signed for. Omitted when signing for the internal key."},
912 {
RPCResult::Type::STR_HEX,
"participant_pubkey",
"The compressed public key of the participant that created this partial signature."},
913 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which this partial signature is for."},
914 {
RPCResult::Type::STR_HEX,
"leaf_hash",
true,
"The hash of the leaf script that contains the aggregate pubkey being signed for. Omitted when signing for the internal key."},
963 {
RPCResult::Type::ARR,
"taproot_tree",
true,
"The tuples that make up the Taproot tree, in depth first search order",
989 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which the participants create."},
1018 "Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.",
1038 {
RPCResult::Type::NUM,
"psbt_version",
"The PSBT version number. Not to be confused with the unsigned transaction version"},
1081 std::vector<unsigned char>
ser_xpub;
1095 result.
pushKV(
"psbt_version",
psbtx.GetVersion());
1099 for (
const auto& entry :
psbtx.m_proprietary) {
1102 this_prop.pushKV(
"subtype", entry.subtype);
1111 for (
auto entry :
psbtx.unknown) {
1120 for (
unsigned int i = 0; i <
psbtx.inputs.size(); ++i) {
1134 out.pushKV(
"scriptPubKey", std::move(
o));
1136 in.
pushKV(
"witness_utxo", std::move(out));
1166 in.
pushKV(
"partial_signatures", std::move(partial_sigs));
1178 in.
pushKV(
"redeem_script", std::move(r));
1183 in.
pushKV(
"witness_script", std::move(r));
1221 in.
pushKV(
"ripemd160_preimages", std::move(ripemd160_preimages));
1230 in.
pushKV(
"sha256_preimages", std::move(sha256_preimages));
1239 in.
pushKV(
"hash160_preimages", std::move(hash160_preimages));
1248 in.
pushKV(
"hash256_preimages", std::move(hash256_preimages));
1324 for (
const auto& pub :
parts) {
1369 this_prop.pushKV(
"subtype", entry.subtype);
1378 if (input.
unknown.size() > 0) {
1380 for (
auto entry : input.
unknown) {
1388 result.
pushKV(
"inputs", std::move(inputs));
1393 for (
unsigned int i = 0; i <
psbtx.outputs.size(); ++i) {
1400 out.pushKV(
"redeem_script", std::move(r));
1405 out.pushKV(
"witness_script", std::move(r));
1418 out.pushKV(
"bip32_derivs", std::move(
keypaths));
1431 elem.pushKV(
"depth", depth);
1436 out.pushKV(
"taproot_tree", std::move(
tree));
1455 out.pushKV(
"taproot_bip32_derivs", std::move(
keypaths));
1465 for (
const auto& pub :
parts) {
1480 this_prop.pushKV(
"subtype", entry.subtype);
1485 out.pushKV(
"proprietary", std::move(
proprietary));
1489 if (output.
unknown.size() > 0) {
1491 for (
auto entry : output.
unknown) {
1494 out.pushKV(
"unknown", std::move(
unknowns));
1507 result.
pushKV(
"outputs", std::move(outputs));
1521 "Combine multiple partially signed Bitcoin transactions into one transaction.\n"
1522 "Implements the Combiner role.\n",
1534 HelpExampleCli(
"combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")
1539 std::vector<PartiallySignedTransaction>
psbtxs;
1544 for (
unsigned int i = 0; i <
txs.size(); ++i) {
1568 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n"
1569 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n"
1570 "created which has the final_scriptSig and final_scriptwitness fields filled for inputs that are complete.\n"
1571 "Implements the Finalizer and Extractor roles.\n",
1575 " extract and return the complete transaction in normal network serialization instead of the PSBT."},
1580 {
RPCResult::Type::STR,
"psbt",
true,
"The base64-encoded partially signed transaction if not extracted"},
1597 bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
1615 result.
pushKV(
"complete", complete);
1626 "Creates a transaction in the Partially Signed Transaction format.\n"
1627 "Implements the Creator role.\n"
1628 "Note that the transaction's inputs are not signed, and\n"
1629 "it is not stored in the wallet or transmitted to the network.\n",
1635 HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
1640 std::optional<bool>
rbf;
1641 if (!request.params[3].isNull()) {
1649 for (
unsigned int i = 0; i <
rawTx.vin.size(); ++i) {
1650 psbtx.inputs.emplace_back();
1652 for (
unsigned int i = 0; i <
rawTx.vout.size(); ++i) {
1653 psbtx.outputs.emplace_back();
1669 "Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n"
1670 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
1674 " will continue. If false, RPC will fail if any signatures are present."},
1676 "If iswitness is not present, heuristic tests will be used in decoding.\n"
1677 "If true, only witness deserialization will be tried.\n"
1678 "If false, only non-witness deserialization will be tried.\n"
1679 "This boolean should reflect whether the transaction has inputs\n"
1680 "(e.g. fully valid, or on-chain transactions), if known by the caller."
1687 "\nCreate a transaction\n"
1688 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1689 "\nConvert the transaction to a PSBT\n"
1696 bool permitsigdata = request.params[1].isNull() ?
false : request.params[1].get_bool();
1707 if ((!input.scriptSig.empty() || !input.scriptWitness.IsNull()) && !
permitsigdata) {
1710 input.scriptSig.clear();
1711 input.scriptWitness.SetNull();
1717 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
1718 psbtx.inputs.emplace_back();
1720 for (
unsigned int i = 0; i < tx.
vout.size(); ++i) {
1721 psbtx.outputs.emplace_back();
1737 "Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.\n",
1749 RPCResult::Type::STR,
"",
"The base64-encoded partially signed transaction with inputs updated"
1758 if (!request.params[1].isNull()) {
1759 auto descs = request.params[1].get_array();
1760 for (
size_t i = 0; i <
descs.size(); ++i) {
1767 request.params[0].get_str(),
1784 "Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n"
1785 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1801 std::vector<PartiallySignedTransaction>
psbtxs;
1804 if (
txs.size() <= 1) {
1810 for (
unsigned int i = 0; i <
txs.size(); ++i) {
1835 for (
unsigned int i = 0; i <
psbt.tx->vin.size(); ++i) {
1840 for (
unsigned int i = 0; i <
psbt.tx->vout.size(); ++i) {
1886 "Analyzes and provides information about the current status of a PSBT and its inputs\n",
1899 {
RPCResult::Type::OBJ,
"missing",
true,
"Things that are missing that are required to complete this input",
1903 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing"},
1907 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose signature is missing"},
1912 {
RPCResult::Type::STR,
"next",
true,
"Role of the next person that this input needs to go to"},
1915 {
RPCResult::Type::NUM,
"estimated_vsize",
true,
"Estimated vsize of the final signed transaction"},
1916 {
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"},
1917 {
RPCResult::Type::STR_AMOUNT,
"fee",
true,
"The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled"},
1938 for (
const auto& input :
psbta.inputs) {
1942 input_univ.pushKV(
"has_utxo", input.has_utxo);
1943 input_univ.pushKV(
"is_final", input.is_final);
1946 if (!input.missing_pubkeys.empty()) {
1948 for (
const CKeyID& pubkey : input.missing_pubkeys) {
1953 if (!input.missing_redeem_script.IsNull()) {
1954 missing.pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
1956 if (!input.missing_witness_script.IsNull()) {
1957 missing.pushKV(
"witnessscript",
HexStr(input.missing_witness_script));
1959 if (!input.missing_sigs.empty()) {
1961 for (
const CKeyID& pubkey : input.missing_sigs) {
1966 if (!
missing.getKeys().empty()) {
1973 if (
psbta.estimated_vsize != std::nullopt) {
1974 result.
pushKV(
"estimated_vsize", *
psbta.estimated_vsize);
1976 if (
psbta.estimated_feerate != std::nullopt) {
1979 if (
psbta.fee != std::nullopt) {
1983 if (!
psbta.error.empty()) {
1995 "descriptorprocesspsbt",
1996 "Update all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool. \n"
1997 "Then, sign the inputs we are able to with information from the output descriptors. ",
2007 {
"sighashtype",
RPCArg::Type::STR,
RPCArg::Default{
"DEFAULT for Taproot, ALL otherwise"},
"The signature hash type to sign with if not specified by the PSBT. Must be one of\n"
2012 " \"ALL|ANYONECANPAY\"\n"
2013 " \"NONE|ANYONECANPAY\"\n"
2014 " \"SINGLE|ANYONECANPAY\""},
2027 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[\\\"descriptor1\\\", \\\"descriptor2\\\"]\"") +
2028 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[{\\\"desc\\\":\\\"mydescriptor\\\", \\\"range\\\":21}]\"")
2035 auto descs = request.params[1].get_array();
2036 for (
size_t i = 0; i <
descs.size(); ++i) {
2041 bool bip32derivs = request.params[3].isNull() ?
true : request.params[3].get_bool();
2042 bool finalize = request.params[4].isNull() ?
true : request.params[4].get_bool();
2045 request.params[0].get_str(),
2052 bool complete =
true;
2053 for (
const auto& input :
psbtx.inputs) {
2063 result.
pushKV(
"complete", complete);
2097 t.appendCommand(
c.name, &
c);
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
std::string EncodeBase58Check(std::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, bool apostrophe)
Write HD keypaths as strings.
@ BLOCK_HAVE_DATA
full block available in blk*.dat
#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.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
const CBlock & GenesisBlock() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
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.
CPubKey GetPubKey() const
Compute the public key from a private key.
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.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Serialized script, used inside transaction inputs and outputs.
A reference to a CScript: the Hash160 of its serialization.
The basic transaction that is broadcasted on the network and contained in blocks.
static const uint32_t CURRENT_VERSION
An input of a transaction.
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.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
Chainstate & ActiveChainstate() const
Alternatives to CurrentChainstate() used by older code to query latest chainstate information without...
const CChainParams & GetParams() const
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...
CTxOut out
unspent transaction output
bool IsSpent() const
Either this coin never existed (see e.g.
Double ended buffer combining vector and stream-like interfaces.
A signature creator for transactions.
void push_back(UniValue val)
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)
bool ReadBlockUndo(CBlockUndo &blockundo, const CBlockIndex &index) const
bool ReadBlock(CBlock &block, const FlatFilePos &pos, const std::optional< uint256 > &expected_hash) const
Functions for disk access for blocks.
static transaction_identifier FromUint256(const uint256 &id)
std::string EncodeHexTx(const CTransaction &tx)
std::string SighashToStr(unsigned char sighash_type)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness, bool try_witness)
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex, bool include_address, const SigningProvider *provider)
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex, const CTxUndo *txundo, TxVerbosity verbosity, std::function< bool(const CTxOut &)> is_change_func)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
UniValue ValueFromAmount(const CAmount amount)
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.
uint32_t ReadBE32(const B *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 HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeDestination(const CTxDestination &dest)
CKey DecodeSecret(const std::string &str)
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const Txid &hash, const BlockManager &blockman, uint256 &hashBlock)
Return transaction with a given hash.
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.
is a home for public enum and struct type definitions that are used internally by node code,...
static constexpr TransactionSerParams TX_WITH_WITNESS
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 CombinePSBTs(PartiallySignedTransaction &out, const std::vector< PartiallySignedTransaction > &psbtxs)
Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial sign...
void RemoveUnnecessaryTransactions(PartiallySignedTransaction &psbtx)
Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e.
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed by checking for non-null finalized fields.
PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
PSBTError SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, std::optional< int > sighash, SignatureData *out_sigdata, bool finalize)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
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()
PartiallySignedTransaction ProcessPSBT(const std::string &psbt_string, const std::any &context, const HidingSigningProvider &provider, std::optional< int > sighash_type, bool finalize)
const RPCResult decodepsbt_outputs
static std::vector< RPCArg > CreateTxDoc()
static RPCHelpMan analyzepsbt()
static RPCHelpMan decoderawtransaction()
RPCHelpMan descriptorprocesspsbt()
static RPCHelpMan combinepsbt()
static RPCHelpMan decodepsbt()
static RPCHelpMan decodescript()
static RPCHelpMan createpsbt()
static RPCHelpMan joinpsbts()
static RPCHelpMan combinerawtransaction()
static constexpr decltype(CTransaction::version) DEFAULT_RAWTX_VERSION
static RPCHelpMan signrawtransactionwithkey()
static RPCHelpMan createrawtransaction()
static RPCHelpMan finalizepsbt()
void RegisterRawTransactionRPCCommands(CRPCTable &t)
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.
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, std::optional< bool > rbf, const uint32_t version)
Create a transaction from univalue parameters.
std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc, bool wallet)
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
void ParsePrevouts(const UniValue &prevTxsUnival, FlatSigningProvider *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< CScript > EvalDescriptorStringOrObject(const UniValue &scanobject, FlatSigningProvider &provider, const bool expand_priv)
Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range ...
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string_view name)
UniValue JSONRPCPSBTError(PSBTError err)
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.
int ParseVerbosity(const UniValue &arg, int default_verbosity, bool allow_bool)
Parses verbosity from provided UniValue.
std::optional< int > ParseSighashString(const UniValue &sighash)
Returns a sighash value corresponding to the passed in argument.
uint256 ParseHashV(const UniValue &v, std::string_view name)
Utilities: convert hex-encoded Values (throws error if not hex).
std::vector< RPCResult > ScriptPubKeyDoc()
#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.
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.
@ WITNESS_UNKNOWN
Only for Witness versions not already defined above.
@ ANCHOR
anyone can spend script
@ 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
std::map< CScriptID, CScript > scripts
A structure for PSBTs which contains per output information.
std::map< CPubKey, std::vector< CPubKey > > m_musig2_participants
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.
std::optional< CMutableTransaction > tx
@ 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)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
std::string EncodeBase64(std::span< const unsigned char > input)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.