81 entry.
pushKV(
"confirmations", 0);
101 "Each key may only appear once, i.e. there can only be one 'data' output, and no address may be duplicated.\n"
102 "At least one output of either type must be specified.\n"
103 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
104 " accepted as second parameter.",
120 "Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
142 std::map<COutPoint, Coin> coins;
168 if (!coins.empty()) {
187 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
197 const auto sign_result =
SignPSBTInput(
provider, psbtx, i, &txdata, {.sighash_type = sighash_type, .finalize = finalize},
nullptr);
204 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
215 const std::vector<RPCResult> verbosity_1_block{
216 {
RPCResult::Type::BOOL,
"in_active_chain",
true,
"Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
218 {
RPCResult::Type::NUM,
"vsize_adjusted",
true,
"Sigop-adjusted virtual size in bytes, present for mempool transactions."},
224 const auto v2_extras = Cat<std::vector<RPCResult>>(
225 std::vector<RPCResult>{{
227 "transaction fee in " +
CURRENCY_UNIT +
", omitted if block undo data is not available"
231 .prevout_optional =
true,
232 .vin_inner_elision =
"Same vin fields as verbosity = 1"}));
236 "By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled\n"
237 "and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.\n"
238 "If a blockhash argument is passed, it will return the transaction if\n"
239 "the specified block is available and the transaction is in that block.\n\n"
240 "Hint: Use gettransaction for wallet transactions.\n\n"
242 "If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.\n"
243 "If verbosity is 1, returns a JSON Object with information about the transaction.\n"
244 "If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.",
252 RPCResult{
"if verbosity is not set or set to 0",
257 Cat<std::vector<RPCResult>>(
259 TxDoc({.txid_field_doc=
"The transaction id (same as provided)"})),
262 Cat(
ElideGroup(verbosity_1_block,
"Same output as verbosity = 1"), v2_extras)},
268 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 0 \"myblockhash\"")
269 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 1 \"myblockhash\"")
270 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 2 \"myblockhash\"")
287 if (!request.params[2].isNull()) {
297 bool f_txindex_ready =
false;
299 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
308 if (!block_has_data) {
311 errmsg =
"No such transaction found in the provided block";
313 errmsg =
"No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries";
314 }
else if (!f_txindex_ready) {
315 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
317 errmsg =
"No such mempool or blockchain transaction";
322 if (verbosity <= 0) {
332 if (request.params[2].isNull()) {
338 if (blockindex ==
nullptr && hash_block.
IsNull() &&
node.mempool) {
339 auto info =
node.mempool->info(tx->GetHash());
341 result.
pushKV(
"vsize_adjusted", info.vsize);
345 if (verbosity == 1) {
358 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.");
361 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.");
366 if (it != block.
vtx.end()) {
368 undoTX = &blockUndo.
vtxundo.at(it - block.
vtx.begin() - 1);
379 "createrawtransaction",
380 "Create a transaction spending the given inputs and creating new outputs.\n"
381 "Outputs can be addresses or data.\n"
382 "Returns hex-encoded raw transaction.\n"
383 "Note that the transaction's inputs are not signed, and\n"
384 "it is not stored in the wallet or transmitted to the network.\n",
390 HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
391 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
392 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
393 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
397 std::optional<bool> rbf;
398 if (!request.params[3].isNull()) {
411 "Return a JSON object representing the serialized, hex-encoded transaction.",
415 "If iswitness is not present, heuristic tests will be used in decoding.\n"
416 "If true, only witness deserialization will be tried.\n"
417 "If false, only non-witness deserialization will be tried.\n"
418 "This boolean should reflect whether the transaction has inputs\n"
419 "(e.g. fully valid, or on-chain transactions), if known by the caller."
434 bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool();
435 bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool();
437 if (!
DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) {
453 "Decode a hex-encoded script.\n",
463 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
465 "address of P2SH script wrapping this redeem script (not returned for types that should not be wrapped)"},
467 "Result of a witness output script wrapping this redeem script (not returned for types that should not be wrapped)",
471 {
RPCResult::Type::STR,
"type",
"The type of the output script (e.g. witness_v0_keyhash or witness_v0_scripthash)"},
472 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
474 {
RPCResult::Type::STR,
"p2sh-segwit",
"address of the P2SH script wrapping this witness redeem script"},
486 if (request.params[0].get_str().size() > 0){
487 std::vector<unsigned char> scriptData(
ParseHexV(request.params[0],
"argument"));
494 std::vector<std::vector<unsigned char>> solutions_data;
497 const bool can_wrap{[&] {
498 switch (which_type) {
532 const bool can_wrap_P2WSH{[&] {
533 switch (which_type) {
538 for (
const auto& solution : solutions_data) {
560 if (can_wrap_P2WSH) {
575 r.
pushKV(
"segwit", std::move(sr));
587 "combinerawtransaction",
588 "Combine multiple partially signed transactions into one transaction.\n"
589 "The combined transaction may be another partially signed transaction or a \n"
590 "fully signed transaction.",
602 HelpExampleCli(
"combinerawtransaction", R
"('["myhex1", "myhex2", "myhex3"]')")
610 if (txs.
size() < 2) {
614 std::vector<CMutableTransaction> txVariants(txs.
size());
616 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
617 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
623 std::vector<CMutableTransaction> tx_variants_copy(txVariants);
625 for (
unsigned int k{0};
k < tx_variants_copy.size(); ++
k) {
627 for (
CTxIn& input : tx_variants_copy[
k].vin) {
628 input.scriptSig.clear();
632 first_txid = tx_variants_copy[
k].GetHash();
633 }
else if (first_txid != tx_variants_copy[
k].GetHash()) {
652 view.SetBackend(viewMempool);
654 for (
const CTxIn& txin : mergedTx.
vin) {
665 for (
unsigned int i = 0; i < mergedTx.
vin.size(); i++) {
675 if (txv.vin.size() > i) {
692 "signrawtransactionwithkey",
693 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
694 "The second argument is an array of base58-encoded private\n"
695 "keys that will be the only keys used to sign the transaction.\n"
696 "The third optional argument (may be null) is an array of previous transaction outputs that\n"
697 "this transaction depends on but may not yet be in the block chain.\n",
724 " \"ALL|ANYONECANPAY\"\n"
725 " \"NONE|ANYONECANPAY\"\n"
726 " \"SINGLE|ANYONECANPAY\"\n"
752 HelpExampleCli(
"signrawtransactionwithkey",
"\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
753 +
HelpExampleRpc(
"signrawtransactionwithkey",
"\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
758 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
764 for (
unsigned int idx = 0; idx <
keys.size(); ++idx) {
773 keystore.
pubkeys.emplace(key_id, pubkey);
774 keystore.
keys.emplace(key_id, key);
778 std::map<COutPoint, Coin> coins;
797 static const RPCResult decodepsbt_inputs{
802 {
RPCResult::Type::OBJ,
"non_witness_utxo",
true,
"Decoded network transaction for non-witness UTXOs",
814 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
868 {
RPCResult::Type::STR_HEX,
"previous_txid",
true,
"TXID of the transaction containing the output being spent by this input"},
872 {
RPCResult::Type::NUM,
"height_locktime",
true,
"Height-based locktime required for this input"},
876 {
RPCResult::Type::OBJ,
"signature",
true,
"The signature for the pubkey and leaf hash combination",
914 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which the participants create."},
925 {
RPCResult::Type::STR_HEX,
"participant_pubkey",
"The compressed public key of the participant that created this pubnonce."},
926 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which this pubnonce is for."},
927 {
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."},
935 {
RPCResult::Type::STR_HEX,
"participant_pubkey",
"The compressed public key of the participant that created this partial signature."},
936 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which this partial signature is for."},
937 {
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."},
958 return decodepsbt_inputs;
963 static const RPCResult decodepsbt_outputs{
994 {
RPCResult::Type::ARR,
"taproot_tree",
true,
"The tuples that make up the Taproot tree, in depth first search order",
1020 {
RPCResult::Type::STR_HEX,
"aggregate_pubkey",
"The compressed aggregate public key for which the participants create."},
1044 return decodepsbt_outputs;
1051 "Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.",
1070 {
RPCResult::Type::NUM,
"tx_version",
true,
"The version number of the unsigned transaction. Not to be confused with PSBT version"},
1071 {
RPCResult::Type::NUM,
"fallback_locktime",
true,
"The locktime to fallback to if no inputs specify a required locktime."},
1077 {
RPCResult::Type::NUM,
"psbt_version",
true,
"The PSBT version number. Not to be confused with the unsigned transaction version"},
1115 result.
pushKV(
"tx", std::move(tx_univ));
1121 for (
auto& xpub : xpub_pair.second) {
1122 std::vector<unsigned char> ser_xpub;
1124 xpub.EncodeWithVersion(ser_xpub.data());
1128 keypath.
pushKV(
"master_fingerprint",
HexStr(xpub_pair.first.fingerprint));
1130 global_xpubs.
push_back(std::move(keypath));
1133 result.
pushKV(
"global_xpubs", std::move(global_xpubs));
1141 result.
pushKV(
"input_count", (uint64_t)psbtx.
inputs.size());
1142 result.
pushKV(
"output_count", (uint64_t)psbtx.
outputs.size());
1157 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1158 this_prop.
pushKV(
"subtype", entry.subtype);
1161 proprietary.
push_back(std::move(this_prop));
1163 result.
pushKV(
"proprietary", std::move(proprietary));
1167 for (
auto entry : psbtx.
unknown) {
1170 result.
pushKV(
"unknown", std::move(unknowns));
1174 bool have_all_utxos =
true;
1176 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
1180 bool have_a_utxo =
false;
1190 out.pushKV(
"scriptPubKey", std::move(o));
1192 in.
pushKV(
"witness_utxo", std::move(
out));
1201 in.
pushKV(
"non_witness_utxo", std::move(non_wit));
1207 total_in += txout.
nValue;
1210 have_all_utxos =
false;
1213 have_all_utxos =
false;
1222 in.
pushKV(
"partial_signatures", std::move(partial_sigs));
1234 in.
pushKV(
"redeem_script", std::move(r));
1239 in.
pushKV(
"witness_script", std::move(r));
1253 in.
pushKV(
"bip32_derivs", std::move(keypaths));
1261 in.
pushKV(
"final_scriptSig", std::move(scriptsig));
1268 in.
pushKV(
"final_scriptwitness", std::move(txinwitness));
1277 in.
pushKV(
"ripemd160_preimages", std::move(ripemd160_preimages));
1286 in.
pushKV(
"sha256_preimages", std::move(sha256_preimages));
1295 in.
pushKV(
"hash160_preimages", std::move(hash160_preimages));
1304 in.
pushKV(
"hash256_preimages", std::move(hash256_preimages));
1310 in.
pushKV(
"previous_vout",
static_cast<uint64_t
>(input.
prev_out));
1331 const auto& [xonly, leaf_hash] = pubkey_leaf;
1336 script_sigs.
push_back(std::move(sigobj));
1338 in.
pushKV(
"taproot_script_path_sigs", std::move(script_sigs));
1344 for (
const auto& [leaf, control_blocks] : input.
m_tap_scripts) {
1345 const auto& [
script, leaf_ver] = leaf;
1348 script_info.
pushKV(
"leaf_ver", leaf_ver);
1350 for (
const auto& control_block : control_blocks) {
1353 script_info.
pushKV(
"control_blocks", std::move(control_blocks_univ));
1354 tap_scripts.
push_back(std::move(script_info));
1356 in.
pushKV(
"taproot_scripts", std::move(tap_scripts));
1363 const auto& [leaf_hashes, origin] = leaf_origin;
1369 for (
const auto& leaf_hash : leaf_hashes) {
1372 path_obj.
pushKV(
"leaf_hashes", std::move(leaf_hashes_arr));
1373 keypaths.
push_back(std::move(path_obj));
1375 in.
pushKV(
"taproot_bip32_derivs", std::move(keypaths));
1395 for (
const auto& pub : parts) {
1398 musig_part.
pushKV(
"participant_pubkeys", part_pubkeys);
1401 in.
pushKV(
"musig2_participant_pubkeys", musig_pubkeys);
1406 const auto& [agg, lh] = agg_lh;
1407 for (
const auto& [part, pubnonce] : part_pubnonce) {
1411 if (!lh.IsNull()) info.
pushKV(
"leaf_hash",
HexStr(lh));
1416 in.
pushKV(
"musig2_pubnonces", musig_pubnonces);
1421 const auto& [agg, lh] = agg_lh;
1422 for (
const auto& [part, psig] : part_psig) {
1426 if (!lh.IsNull()) info.
pushKV(
"leaf_hash",
HexStr(lh));
1431 in.
pushKV(
"musig2_partial_sigs", musig_partial_sigs);
1439 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1440 this_prop.
pushKV(
"subtype", entry.subtype);
1443 proprietary.
push_back(std::move(this_prop));
1445 in.
pushKV(
"proprietary", std::move(proprietary));
1449 if (input.
unknown.size() > 0) {
1451 for (
auto entry : input.
unknown) {
1454 in.
pushKV(
"unknown", std::move(unknowns));
1459 result.
pushKV(
"inputs", std::move(inputs));
1464 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
1471 out.pushKV(
"redeem_script", std::move(r));
1476 out.pushKV(
"witness_script", std::move(r));
1489 out.pushKV(
"bip32_derivs", std::move(keypaths));
1497 out.pushKV(
"script", spk);
1510 elem.
pushKV(
"depth", depth);
1511 elem.
pushKV(
"leaf_ver", leaf_ver);
1515 out.pushKV(
"taproot_tree", std::move(tree));
1522 const auto& [leaf_hashes, origin] = leaf_origin;
1528 for (
const auto& leaf_hash : leaf_hashes) {
1531 path_obj.
pushKV(
"leaf_hashes", std::move(leaf_hashes_arr));
1532 keypaths.
push_back(std::move(path_obj));
1534 out.pushKV(
"taproot_bip32_derivs", std::move(keypaths));
1544 for (
const auto& pub : parts) {
1547 musig_part.
pushKV(
"participant_pubkeys", part_pubkeys);
1550 out.pushKV(
"musig2_participant_pubkeys", musig_pubkeys);
1558 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1559 this_prop.
pushKV(
"subtype", entry.subtype);
1562 proprietary.
push_back(std::move(this_prop));
1564 out.pushKV(
"proprietary", std::move(proprietary));
1568 if (output.
unknown.size() > 0) {
1570 for (
auto entry : output.
unknown) {
1573 out.pushKV(
"unknown", std::move(unknowns));
1580 output_value += output.
amount;
1583 have_all_utxos =
false;
1586 result.
pushKV(
"outputs", std::move(outputs));
1587 if (have_all_utxos) {
1600 "Combine multiple partially signed Bitcoin transactions into one transaction.\n"
1601 "Implements the Combiner role.\n",
1613 HelpExampleCli(
"combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")
1618 std::vector<PartiallySignedTransaction> psbtxs;
1623 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1628 psbtxs.push_back(*psbt_res);
1631 std::optional<PartiallySignedTransaction> merged_psbt =
CombinePSBTs(psbtxs);
1637 ssTx << *merged_psbt;
1646 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n"
1647 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n"
1648 "created which has the final_scriptSig and final_scriptwitness fields filled for inputs that are complete.\n"
1649 "Implements the Finalizer and Extractor roles.\n",
1653 " extract and return the complete transaction in normal network serialization instead of the PSBT."},
1658 {
RPCResult::Type::STR,
"psbt",
true,
"The base64-encoded partially signed transaction if not extracted"},
1675 bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
1682 std::string result_str;
1686 result_str =
HexStr(ssTx);
1687 result.
pushKV(
"hex", result_str);
1691 result.
pushKV(
"psbt", result_str);
1693 result.
pushKV(
"complete", complete);
1704 "Creates a transaction in the Partially Signed Transaction format.\n"
1705 "Implements the Creator role.\n"
1706 "Note that the transaction's inputs are not signed, and\n"
1707 "it is not stored in the wallet or transmitted to the network.\n",
1708 Cat<std::vector<RPCArg>>(
1718 HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
1722 std::optional<bool> rbf;
1723 if (!request.params[3].isNull()) {
1724 rbf = request.params[3].
get_bool();
1729 uint32_t psbt_version = 2;
1730 if (!request.params[5].isNull()) {
1731 psbt_version = request.params[5].getInt<uint32_t>();
1733 if (psbt_version != 2 && psbt_version != 0) {
1751 "Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n"
1752 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
1756 " will continue. If false, RPC will fail if any signatures are present."},
1758 "If iswitness is not present, heuristic tests will be used in decoding.\n"
1759 "If true, only witness deserialization will be tried.\n"
1760 "If false, only non-witness deserialization will be tried.\n"
1761 "This boolean should reflect whether the transaction has inputs\n"
1762 "(e.g. fully valid, or on-chain transactions), if known by the caller."
1770 "\nCreate a transaction\n"
1771 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1772 "\nConvert the transaction to a PSBT\n"
1779 bool permitsigdata = request.params[1].isNull() ? false : request.params[1].get_bool();
1780 bool witness_specified = !request.params[2].isNull();
1781 bool iswitness = witness_specified ? request.params[2].get_bool() :
false;
1782 const bool try_witness = witness_specified ? iswitness :
true;
1783 const bool try_no_witness = witness_specified ? !iswitness :
true;
1784 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
1798 uint32_t psbt_version = 2;
1799 if (!request.params[3].isNull()) {
1800 psbt_version = request.params[3].getInt<uint32_t>();
1802 if (psbt_version != 2 && psbt_version != 0) {
1820 "Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.\n",
1832 RPCResult::Type::STR,
"",
"The base64-encoded partially signed transaction with inputs updated"
1841 if (!request.params[1].isNull()) {
1842 auto descs = request.params[1].get_array();
1843 for (
size_t i = 0; i < descs.size(); ++i) {
1850 request.params[0].get_str(),
1867 "Joins multiple distinct version 0 PSBTs with different inputs and outputs into one version 0 PSBT with inputs and outputs from all of the PSBTs\n"
1868 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1884 std::vector<PartiallySignedTransaction> psbtxs;
1887 if (txs.
size() <= 1) {
1891 uint32_t best_version = 1;
1892 uint32_t best_locktime = 0xffffffff;
1893 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1898 psbtxs.push_back(*psbt_res);
1909 if (psbt_locktime < best_locktime) {
1910 best_locktime = psbt_locktime;
1921 for (
auto& psbt : psbtxs) {
1922 for (
const PSBTInput& input : psbt.inputs) {
1923 if (!merged_psbt.
AddInput(input)) {
1927 for (
const PSBTOutput& output : psbt.outputs) {
1931 merged_psbt.
m_proprietary.insert(psbt.m_proprietary.begin(), psbt.m_proprietary.end());
1932 merged_psbt.
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
1940 ssTx << merged_psbt;
1950 "Analyzes and provides information about the current status of a PSBT and its inputs\n",
1963 {
RPCResult::Type::OBJ,
"missing",
true,
"Things that are missing that are required to complete this input",
1967 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing"},
1971 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose signature is missing"},
1976 {
RPCResult::Type::STR,
"next",
true,
"Role of the next person that this input needs to go to"},
1979 {
RPCResult::Type::NUM,
"estimated_vsize",
true,
"Estimated vsize of the final signed transaction"},
1980 {
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"},
1981 {
RPCResult::Type::STR_AMOUNT,
"fee",
true,
"The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled"},
2002 for (
const auto& input : psbta.
inputs) {
2006 input_univ.
pushKV(
"has_utxo", input.has_utxo);
2007 input_univ.
pushKV(
"is_final", input.is_final);
2010 if (!input.missing_pubkeys.empty()) {
2012 for (
const CKeyID& pubkey : input.missing_pubkeys) {
2015 missing.
pushKV(
"pubkeys", std::move(missing_pubkeys_univ));
2017 if (!input.missing_redeem_script.IsNull()) {
2018 missing.
pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
2020 if (!input.missing_witness_script.IsNull()) {
2021 missing.
pushKV(
"witnessscript",
HexStr(input.missing_witness_script));
2023 if (!input.missing_sigs.empty()) {
2025 for (
const CKeyID& pubkey : input.missing_sigs) {
2028 missing.
pushKV(
"signatures", std::move(missing_sigs_univ));
2030 if (!missing.
getKeys().empty()) {
2031 input_univ.
pushKV(
"missing", std::move(missing));
2033 inputs_result.
push_back(std::move(input_univ));
2035 if (!inputs_result.
empty()) result.
pushKV(
"inputs", std::move(inputs_result));
2043 if (psbta.
fee != std::nullopt) {
2047 if (!psbta.
error.empty()) {
2059 "descriptorprocesspsbt",
2060 "Update all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool. \n"
2061 "Then, sign the inputs we are able to with information from the output descriptors. ",
2071 {
"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"
2076 " \"ALL|ANYONECANPAY\"\n"
2077 " \"NONE|ANYONECANPAY\"\n"
2078 " \"SINGLE|ANYONECANPAY\""},
2091 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[\\\"descriptor1\\\", \\\"descriptor2\\\"]\"") +
2092 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[{\\\"desc\\\":\\\"mydescriptor\\\", \\\"range\\\":21}]\"")
2099 auto descs = request.params[1].get_array();
2100 for (
size_t i = 0; i < descs.size(); ++i) {
2105 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
2106 bool finalize = request.params[4].isNull() ? true : request.params[4].get_bool();
2109 request.params[0].get_str(),
2116 bool complete =
true;
2117 const std::optional<PrecomputedTransactionData> txdata_opt{
PrecomputePSBTData(psbtx)};
2119 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
2129 result.
pushKV(
"complete", complete);
2162 for (
const auto& c : commands) {
2163 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
bool Contains(const CBlockIndex &index) const
Efficiently check whether a block is present in this chain.
int Height() const
Return the maximal height in the chain.
const CBlock & GenesisBlock() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
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 constexpr uint32_t CURRENT_VERSION
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 ...
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.
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.
static CoinsViewEmpty & Get()
Double ended buffer combining vector and stream-like interfaces.
A signature creator for transactions.
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< std::bitset< 8 > > m_tx_modifiable
uint32_t GetVersion() const
std::map< KeyOriginInfo, std::set< CExtPubKey > > m_xpubs
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
std::vector< PSBTInput > inputs
void MergeGlobalXPubs(const PartiallySignedTransaction &psbt)
Merge the global xpubs of psbt into this, keeping the existing origin for an xpub seen again with a d...
std::optional< CMutableTransaction > GetUnsignedTx() const
std::vector< PSBTOutput > outputs
std::set< PSBTProprietary > m_proprietary
bool AddOutput(const PSBTOutput &psbtout)
std::optional< uint32_t > fallback_locktime
bool AddInput(const PSBTInput &psbtin)
auto Arg(std::string_view key) const
Helper to get a required or default-valued request argument.
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 std::optional< uint256 > &expected_hash) const
Functions for disk access for blocks.
std::string ToString() const
std::string GetHex() const
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.
bilingual_str ErrorString(const Result< T > &result)
is a home for public enum and struct type definitions that are used internally by node code,...
constexpr TransactionSerParams TX_WITH_WITNESS
std::shared_ptr< const CTransaction > CTransactionRef
util::Expected< void, PSBTError > SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, const common::PSBTFillOptions &options, SignatureData *out_sigdata)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
bool PSBTInputSignedAndVerified(const PartiallySignedTransaction &psbt, unsigned int input_index, const PrecomputedTransactionData *txdata)
Checks whether a PSBTInput is already signed by doing script verification using final fields.
std::string PSBTRoleName(PSBTRole role)
util::Result< PartiallySignedTransaction > DecodeBase64PSBT(const std::string &base64_tx)
Decode a base64ed PSBT into a PartiallySignedTransaction.
std::optional< PartiallySignedTransaction > CombinePSBTs(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.
std::optional< PrecomputedTransactionData > PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
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.
constexpr unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
static RPCMethod decodescript()
static RPCMethod createrawtransaction()
static void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry, Chainstate &active_chainstate, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
static RPCMethod joinpsbts()
static RPCMethod getrawtransaction()
PartiallySignedTransaction ProcessPSBT(const std::string &psbt_string, const std::any &context, const HidingSigningProvider &provider, std::optional< int > sighash_type, bool finalize)
static RPCMethod createpsbt()
static RPCMethod combinerawtransaction()
static std::vector< RPCArg > CreateTxDoc()
const RPCResult & DecodePSBTOutputs()
RPCMethod descriptorprocesspsbt()
static RPCMethod decodepsbt()
static RPCMethod combinepsbt()
static RPCMethod utxoupdatepsbt()
static RPCMethod converttopsbt()
static constexpr decltype(CTransaction::version) DEFAULT_RAWTX_VERSION
static RPCMethod finalizepsbt()
const RPCResult & DecodePSBTInputs()
void RegisterRawTransactionRPCCommands(CRPCTable &t)
static RPCMethod signrawtransactionwithkey()
static RPCMethod decoderawtransaction()
static RPCMethod analyzepsbt()
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.
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.
std::vector< RPCResult > TxDoc(const TxDocOptions &opts)
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
@ WithSummary
first field carries elision_summary as "...", rest skipped
@ Silent
all top-level fields skipped silently (no "..." line)
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)
std::vector< RPCResult > ElideGroup(std::vector< RPCResult > fields, std::string summary)
Stamp elision onto an entire vector of RPCResult fields at once.
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< std::vector< unsigned char > > stack
std::map< CKeyID, CPubKey > pubkeys
std::map< CKeyID, CKey > keys
@ 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:
@ 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::vector< uint16_t > keys
FuzzedDataProvider provider
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)
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.