80 entry.
pushKV(
"confirmations", 0);
85static std::vector<RPCResult>
DecodeTxDoc(
const std::string& txid_field_doc)
91 {
RPCResult::Type::NUM,
"vsize",
"The virtual transaction size (differs from size for witness transactions)"},
141 "Each key may only appear once, i.e. there can only be one 'data' output, and no address may be duplicated.\n"
142 "At least one output of either type must be specified.\n"
143 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
144 " accepted as second parameter.",
160 "Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
181 std::map<COutPoint, Coin> coins;
185 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
187 const CTxIn& tx_in = psbtx.
tx->vin.at(i);
211 if (!coins.empty()) {
213 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
218 const CTxIn& tx_in = psbtx.
tx->vin.at(i);
229 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
238 SignPSBTInput(provider, psbtx, i, &txdata, sighash_type,
nullptr, finalize);
242 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
256 "By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled\n"
257 "and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.\n"
258 "If a blockhash argument is passed, it will return the transaction if\n"
259 "the specified block is available and the transaction is in that block.\n\n"
260 "Hint: Use gettransaction for wallet transactions.\n\n"
262 "If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.\n"
263 "If verbosity is 1, returns a JSON Object with information about the transaction.\n"
264 "If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.",
272 RPCResult{
"if verbosity is not set or set to 0",
277 Cat<std::vector<RPCResult>>(
279 {
RPCResult::Type::BOOL,
"in_active_chain",
true,
"Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
286 DecodeTxDoc(
"The transaction id (same as provided)")),
298 {
RPCResult::Type::OBJ,
"prevout",
true,
"The previous output, omitted if block undo data is not available",
313 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 0 \"myblockhash\"")
314 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 1 \"myblockhash\"")
315 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 2 \"myblockhash\"")
332 if (!request.params[2].isNull()) {
342 bool f_txindex_ready =
false;
344 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
353 if (!block_has_data) {
356 errmsg =
"No such transaction found in the provided block";
358 errmsg =
"No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries";
359 }
else if (!f_txindex_ready) {
360 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
362 errmsg =
"No such mempool or blockchain transaction";
367 if (verbosity <= 0) {
377 if (request.params[2].isNull()) {
381 if (verbosity == 1) {
394 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.");
397 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.");
402 if (it != block.
vtx.end()) {
404 undoTX = &blockUndo.
vtxundo.at(it - block.
vtx.begin() - 1);
415 "\nCreate a transaction spending the given inputs and creating new outputs.\n"
416 "Outputs can be addresses or data.\n"
417 "Returns hex-encoded raw transaction.\n"
418 "Note that the transaction's inputs are not signed, and\n"
419 "it is not stored in the wallet or transmitted to the network.\n",
425 HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
426 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
427 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
428 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
432 std::optional<bool> rbf;
433 if (!request.params[3].isNull()) {
446 "Return a JSON object representing the serialized, hex-encoded transaction.",
450 "If iswitness is not present, heuristic tests will be used in decoding.\n"
451 "If true, only witness deserialization will be tried.\n"
452 "If false, only non-witness deserialization will be tried.\n"
453 "This boolean should reflect whether the transaction has inputs\n"
454 "(e.g. fully valid, or on-chain transactions), if known by the caller."
469 bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool();
470 bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool();
472 if (!
DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) {
488 "\nDecode a hex-encoded script.\n",
498 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
500 "address of P2SH script wrapping this redeem script (not returned for types that should not be wrapped)"},
502 "Result of a witness output script wrapping this redeem script (not returned for types that should not be wrapped)",
506 {
RPCResult::Type::STR,
"type",
"The type of the output script (e.g. witness_v0_keyhash or witness_v0_scripthash)"},
507 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
509 {
RPCResult::Type::STR,
"p2sh-segwit",
"address of the P2SH script wrapping this witness redeem script"},
521 if (request.params[0].get_str().size() > 0){
522 std::vector<unsigned char> scriptData(
ParseHexV(request.params[0],
"argument"));
529 std::vector<std::vector<unsigned char>> solutions_data;
532 const bool can_wrap{[&] {
533 switch (which_type) {
567 const bool can_wrap_P2WSH{[&] {
568 switch (which_type) {
573 for (
const auto& solution : solutions_data) {
595 if (can_wrap_P2WSH) {
610 r.
pushKV(
"segwit", std::move(sr));
622 "\nCombine multiple partially signed transactions into one transaction.\n"
623 "The combined transaction may be another partially signed transaction or a \n"
624 "fully signed transaction.",
636 HelpExampleCli(
"combinerawtransaction", R
"('["myhex1", "myhex2", "myhex3"]')")
642 std::vector<CMutableTransaction> txVariants(txs.
size());
644 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
645 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
650 if (txVariants.empty()) {
670 for (
const CTxIn& txin : mergedTx.
vin) {
681 for (
unsigned int i = 0; i < mergedTx.
vin.size(); i++) {
691 if (txv.vin.size() > i) {
707 return RPCHelpMan{
"signrawtransactionwithkey",
708 "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
709 "The second argument is an array of base58-encoded private\n"
710 "keys that will be the only keys used to sign the transaction.\n"
711 "The third optional argument (may be null) is an array of previous transaction outputs that\n"
712 "this transaction depends on but may not yet be in the block chain.\n",
739 " \"ALL|ANYONECANPAY\"\n"
740 " \"NONE|ANYONECANPAY\"\n"
741 " \"SINGLE|ANYONECANPAY\"\n"
767 HelpExampleCli(
"signrawtransactionwithkey",
"\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
768 +
HelpExampleRpc(
"signrawtransactionwithkey",
"\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
773 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
779 for (
unsigned int idx = 0; idx < keys.
size(); ++idx) {
788 keystore.
pubkeys.emplace(key_id, pubkey);
789 keystore.
keys.emplace(key_id, key);
793 std::map<COutPoint, Coin> coins;
815 {
RPCResult::Type::OBJ,
"non_witness_utxo",
true,
"Decoded network transaction for non-witness UTXOs",
828 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
885 {
RPCResult::Type::OBJ,
"signature",
true,
"The signature for the pubkey and leaf hash combination",
923 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which the participants create."},
934 {
RPCResult::Type::STR_HEX,
"participant_pubkey",
"The compressed public key of the participant that created this pubnonce."},
935 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which this pubnonce is for."},
936 {
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."},
944 {
RPCResult::Type::STR_HEX,
"participant_pubkey",
"The compressed public key of the participant that created this partial signature."},
945 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which this partial signature is for."},
946 {
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."},
995 {
RPCResult::Type::ARR,
"taproot_tree",
true,
"The tuples that make up the Taproot tree, in depth first search order",
1021 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which the participants create."},
1050 "Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.",
1070 {
RPCResult::Type::NUM,
"psbt_version",
"The PSBT version number. Not to be confused with the unsigned transaction version"},
1107 result.
pushKV(
"tx", std::move(tx_univ));
1112 for (
auto& xpub : xpub_pair.second) {
1113 std::vector<unsigned char> ser_xpub;
1115 xpub.EncodeWithVersion(ser_xpub.data());
1119 keypath.
pushKV(
"master_fingerprint",
HexStr(std::span<unsigned char>(xpub_pair.first.fingerprint, xpub_pair.first.fingerprint + 4)));
1121 global_xpubs.
push_back(std::move(keypath));
1124 result.
pushKV(
"global_xpubs", std::move(global_xpubs));
1133 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1134 this_prop.
pushKV(
"subtype", entry.subtype);
1137 proprietary.
push_back(std::move(this_prop));
1139 result.
pushKV(
"proprietary", std::move(proprietary));
1143 for (
auto entry : psbtx.
unknown) {
1146 result.
pushKV(
"unknown", std::move(unknowns));
1150 bool have_all_utxos =
true;
1152 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
1156 bool have_a_utxo =
false;
1166 out.pushKV(
"scriptPubKey", std::move(o));
1168 in.
pushKV(
"witness_utxo", std::move(
out));
1177 in.
pushKV(
"non_witness_utxo", std::move(non_wit));
1183 total_in += txout.
nValue;
1186 have_all_utxos =
false;
1189 have_all_utxos =
false;
1198 in.
pushKV(
"partial_signatures", std::move(partial_sigs));
1210 in.
pushKV(
"redeem_script", std::move(r));
1215 in.
pushKV(
"witness_script", std::move(r));
1229 in.
pushKV(
"bip32_derivs", std::move(keypaths));
1237 in.
pushKV(
"final_scriptSig", std::move(scriptsig));
1244 in.
pushKV(
"final_scriptwitness", std::move(txinwitness));
1253 in.
pushKV(
"ripemd160_preimages", std::move(ripemd160_preimages));
1262 in.
pushKV(
"sha256_preimages", std::move(sha256_preimages));
1271 in.
pushKV(
"hash160_preimages", std::move(hash160_preimages));
1280 in.
pushKV(
"hash256_preimages", std::move(hash256_preimages));
1292 const auto& [xonly, leaf_hash] = pubkey_leaf;
1297 script_sigs.
push_back(std::move(sigobj));
1299 in.
pushKV(
"taproot_script_path_sigs", std::move(script_sigs));
1305 for (
const auto& [leaf, control_blocks] : input.
m_tap_scripts) {
1306 const auto& [
script, leaf_ver] = leaf;
1309 script_info.
pushKV(
"leaf_ver", leaf_ver);
1311 for (
const auto& control_block : control_blocks) {
1314 script_info.
pushKV(
"control_blocks", std::move(control_blocks_univ));
1315 tap_scripts.
push_back(std::move(script_info));
1317 in.
pushKV(
"taproot_scripts", std::move(tap_scripts));
1324 const auto& [leaf_hashes, origin] = leaf_origin;
1330 for (
const auto& leaf_hash : leaf_hashes) {
1333 path_obj.
pushKV(
"leaf_hashes", std::move(leaf_hashes_arr));
1334 keypaths.
push_back(std::move(path_obj));
1336 in.
pushKV(
"taproot_bip32_derivs", std::move(keypaths));
1356 for (
const auto& pub : parts) {
1359 musig_part.
pushKV(
"participant_pubkeys", part_pubkeys);
1362 in.
pushKV(
"musig2_participant_pubkeys", musig_pubkeys);
1367 const auto& [agg, lh] = agg_lh;
1368 for (
const auto& [part, pubnonce] : part_pubnonce) {
1372 if (!lh.IsNull()) info.
pushKV(
"leaf_hash",
HexStr(lh));
1377 in.
pushKV(
"musig2_pubnonces", musig_pubnonces);
1382 const auto& [agg, lh] = agg_lh;
1383 for (
const auto& [part, psig] : part_psig) {
1387 if (!lh.IsNull()) info.
pushKV(
"leaf_hash",
HexStr(lh));
1392 in.
pushKV(
"musig2_partial_sigs", musig_partial_sigs);
1400 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1401 this_prop.
pushKV(
"subtype", entry.subtype);
1404 proprietary.
push_back(std::move(this_prop));
1406 in.
pushKV(
"proprietary", std::move(proprietary));
1410 if (input.
unknown.size() > 0) {
1412 for (
auto entry : input.
unknown) {
1415 in.
pushKV(
"unknown", std::move(unknowns));
1420 result.
pushKV(
"inputs", std::move(inputs));
1425 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
1432 out.pushKV(
"redeem_script", std::move(r));
1437 out.pushKV(
"witness_script", std::move(r));
1450 out.pushKV(
"bip32_derivs", std::move(keypaths));
1463 elem.
pushKV(
"depth", (
int)depth);
1464 elem.
pushKV(
"leaf_ver", (
int)leaf_ver);
1468 out.pushKV(
"taproot_tree", std::move(tree));
1475 const auto& [leaf_hashes, origin] = leaf_origin;
1481 for (
const auto& leaf_hash : leaf_hashes) {
1484 path_obj.
pushKV(
"leaf_hashes", std::move(leaf_hashes_arr));
1485 keypaths.
push_back(std::move(path_obj));
1487 out.pushKV(
"taproot_bip32_derivs", std::move(keypaths));
1497 for (
const auto& pub : parts) {
1500 musig_part.
pushKV(
"participant_pubkeys", part_pubkeys);
1503 out.pushKV(
"musig2_participant_pubkeys", musig_pubkeys);
1511 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1512 this_prop.
pushKV(
"subtype", entry.subtype);
1515 proprietary.
push_back(std::move(this_prop));
1517 out.pushKV(
"proprietary", std::move(proprietary));
1521 if (output.
unknown.size() > 0) {
1523 for (
auto entry : output.
unknown) {
1526 out.pushKV(
"unknown", std::move(unknowns));
1533 output_value += psbtx.
tx->vout[i].nValue;
1536 have_all_utxos =
false;
1539 result.
pushKV(
"outputs", std::move(outputs));
1540 if (have_all_utxos) {
1552 "\nCombine multiple partially signed Bitcoin transactions into one transaction.\n"
1553 "Implements the Combiner role.\n",
1565 HelpExampleCli(
"combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")
1570 std::vector<PartiallySignedTransaction> psbtxs;
1575 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1581 psbtxs.push_back(psbtx);
1590 ssTx << merged_psbt;
1599 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n"
1600 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n"
1601 "created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n"
1602 "Implements the Finalizer and Extractor roles.\n",
1606 " extract and return the complete transaction in normal network serialization instead of the PSBT."},
1611 {
RPCResult::Type::STR,
"psbt",
true,
"The base64-encoded partially signed transaction if not extracted"},
1628 bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
1635 std::string result_str;
1639 result_str =
HexStr(ssTx);
1640 result.
pushKV(
"hex", result_str);
1644 result.
pushKV(
"psbt", result_str);
1646 result.
pushKV(
"complete", complete);
1656 "\nCreates a transaction in the Partially Signed Transaction format.\n"
1657 "Implements the Creator role.\n"
1658 "Note that the transaction's inputs are not signed, and\n"
1659 "it is not stored in the wallet or transmitted to the network.\n",
1665 HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
1670 std::optional<bool> rbf;
1671 if (!request.params[3].isNull()) {
1672 rbf = request.params[3].
get_bool();
1679 for (
unsigned int i = 0; i < rawTx.
vin.size(); ++i) {
1680 psbtx.
inputs.emplace_back();
1682 for (
unsigned int i = 0; i < rawTx.
vout.size(); ++i) {
1698 "\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n"
1699 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
1703 " will continue. If false, RPC will fail if any signatures are present."},
1705 "If iswitness is not present, heuristic tests will be used in decoding.\n"
1706 "If true, only witness deserialization will be tried.\n"
1707 "If false, only non-witness deserialization will be tried.\n"
1708 "This boolean should reflect whether the transaction has inputs\n"
1709 "(e.g. fully valid, or on-chain transactions), if known by the caller."
1716 "\nCreate a transaction\n"
1717 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1718 "\nConvert the transaction to a PSBT\n"
1725 bool permitsigdata = request.params[1].isNull() ? false : request.params[1].get_bool();
1726 bool witness_specified = !request.params[2].isNull();
1727 bool iswitness = witness_specified ? request.params[2].get_bool() :
false;
1728 const bool try_witness = witness_specified ? iswitness :
true;
1729 const bool try_no_witness = witness_specified ? !iswitness :
true;
1730 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
1746 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
1747 psbtx.
inputs.emplace_back();
1749 for (
unsigned int i = 0; i < tx.
vout.size(); ++i) {
1765 "\nUpdates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.\n",
1777 RPCResult::Type::STR,
"",
"The base64-encoded partially signed transaction with inputs updated"
1786 if (!request.params[1].isNull()) {
1787 auto descs = request.params[1].get_array();
1788 for (
size_t i = 0; i < descs.size(); ++i) {
1795 request.params[0].get_str(),
1811 "\nJoins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n"
1812 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1828 std::vector<PartiallySignedTransaction> psbtxs;
1831 if (txs.
size() <= 1) {
1835 uint32_t best_version = 1;
1836 uint32_t best_locktime = 0xffffffff;
1837 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1843 psbtxs.push_back(psbtx);
1845 if (psbtx.
tx->version > best_version) {
1846 best_version = psbtx.
tx->version;
1849 if (psbtx.
tx->nLockTime < best_locktime) {
1850 best_locktime = psbtx.
tx->nLockTime;
1857 merged_psbt.
tx->version = best_version;
1858 merged_psbt.
tx->nLockTime = best_locktime;
1861 for (
auto& psbt : psbtxs) {
1862 for (
unsigned int i = 0; i < psbt.tx->vin.size(); ++i) {
1863 if (!merged_psbt.
AddInput(psbt.tx->vin[i], psbt.inputs[i])) {
1867 for (
unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
1868 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1870 for (
auto& xpub_pair : psbt.m_xpubs) {
1871 if (merged_psbt.
m_xpubs.count(xpub_pair.first) == 0) {
1872 merged_psbt.
m_xpubs[xpub_pair.first] = xpub_pair.second;
1874 merged_psbt.
m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
1877 merged_psbt.
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
1881 std::vector<int> input_indices(merged_psbt.
inputs.size());
1882 std::iota(input_indices.begin(), input_indices.end(), 0);
1883 std::vector<int> output_indices(merged_psbt.
outputs.size());
1884 std::iota(output_indices.begin(), output_indices.end(), 0);
1888 std::shuffle(output_indices.begin(), output_indices.end(),
FastRandomContext());
1892 shuffled_psbt.
tx->version = merged_psbt.
tx->version;
1893 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1894 for (
int i : input_indices) {
1897 for (
int i : output_indices) {
1903 ssTx << shuffled_psbt;
1912 "\nAnalyzes and provides information about the current status of a PSBT and its inputs\n",
1925 {
RPCResult::Type::OBJ,
"missing",
true,
"Things that are missing that are required to complete this input",
1929 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing"},
1933 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose signature is missing"},
1938 {
RPCResult::Type::STR,
"next",
true,
"Role of the next person that this input needs to go to"},
1941 {
RPCResult::Type::NUM,
"estimated_vsize",
true,
"Estimated vsize of the final signed transaction"},
1942 {
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"},
1943 {
RPCResult::Type::STR_AMOUNT,
"fee",
true,
"The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled"},
1964 for (
const auto& input : psbta.
inputs) {
1968 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1969 input_univ.
pushKV(
"is_final", input.is_final);
1972 if (!input.missing_pubkeys.empty()) {
1974 for (
const CKeyID& pubkey : input.missing_pubkeys) {
1977 missing.
pushKV(
"pubkeys", std::move(missing_pubkeys_univ));
1979 if (!input.missing_redeem_script.IsNull()) {
1980 missing.
pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
1982 if (!input.missing_witness_script.IsNull()) {
1983 missing.
pushKV(
"witnessscript",
HexStr(input.missing_witness_script));
1985 if (!input.missing_sigs.empty()) {
1987 for (
const CKeyID& pubkey : input.missing_sigs) {
1990 missing.
pushKV(
"signatures", std::move(missing_sigs_univ));
1992 if (!missing.
getKeys().empty()) {
1993 input_univ.
pushKV(
"missing", std::move(missing));
1995 inputs_result.
push_back(std::move(input_univ));
1997 if (!inputs_result.
empty()) result.
pushKV(
"inputs", std::move(inputs_result));
2005 if (psbta.
fee != std::nullopt) {
2009 if (!psbta.
error.empty()) {
2021 "\nUpdate all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool. \n"
2022 "Then, sign the inputs we are able to with information from the output descriptors. ",
2032 {
"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"
2037 " \"ALL|ANYONECANPAY\"\n"
2038 " \"NONE|ANYONECANPAY\"\n"
2039 " \"SINGLE|ANYONECANPAY\""},
2052 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[\\\"descriptor1\\\", \\\"descriptor2\\\"]\"") +
2053 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[{\\\"desc\\\":\\\"mydescriptor\\\", \\\"range\\\":21}]\"")
2060 auto descs = request.params[1].get_array();
2061 for (
size_t i = 0; i < descs.size(); ++i) {
2066 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
2067 bool finalize = request.params[4].isNull() ? true : request.params[4].get_bool();
2070 request.params[0].get_str(),
2077 bool complete =
true;
2078 for (
const auto& input : psbtx.
inputs) {
2088 result.
pushKV(
"complete", complete);
2121 for (
const auto& c : commands) {
2122 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.
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.
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.
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.
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...
SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(const CBlockIndex *GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(Chainstate ActiveChainstate)() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
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 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)
bool ReadBlockUndo(CBlockUndo &blockundo, const CBlockIndex &index) const
bool ReadBlock(CBlock &block, const FlatFilePos &pos) const
Functions for disk access for blocks.
std::string EncodeHexTx(const CTransaction &tx)
std::string SighashToStr(unsigned char sighash_type)
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
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.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex=true, bool include_address=false, const SigningProvider *provider=nullptr)
UniValue ValueFromAmount(const CAmount amount)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
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)
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, uint256 &hashBlock, const BlockManager &blockman)
Return transaction with a given hash.
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...
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
void RemoveUnnecessaryTransactions(PartiallySignedTransaction &psbtx, const int &sighash_type)
Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e.
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.
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.
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()
const RPCResult decodepsbt_outputs
static std::vector< RPCArg > CreateTxDoc()
static RPCHelpMan analyzepsbt()
static RPCHelpMan decoderawtransaction()
RPCHelpMan descriptorprocesspsbt()
static RPCHelpMan combinepsbt()
static RPCHelpMan decodepsbt()
PartiallySignedTransaction ProcessPSBT(const std::string &psbt_string, const std::any &context, const HidingSigningProvider &provider, int sighash_type, bool finalize)
static RPCHelpMan decodescript()
static RPCHelpMan createpsbt()
static RPCHelpMan joinpsbts()
static std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc)
static RPCHelpMan combinerawtransaction()
static RPCHelpMan signrawtransactionwithkey()
static RPCHelpMan createrawtransaction()
static RPCHelpMan finalizepsbt()
void RegisterRawTransactionRPCCommands(CRPCTable &t)
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, 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)
int ParseSighashString(const UniValue &sighash)
Returns a sighash value corresponding to the passed in argument.
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.
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< CKeyID, CPubKey > pubkeys
std::map< CKeyID, CKey > keys
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.
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.
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)