80 entry.
pushKV(
"confirmations", 0);
91 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
96 static std::vector<RPCResult>
DecodeTxDoc(
const std::string& txid_field_doc)
102 {
RPCResult::Type::NUM,
"vsize",
"The virtual transaction size (differs from size for witness transactions)"},
152 "Each key may only appear once, i.e. there can only be one 'data' output, and no address may be duplicated.\n" 153 "At least one output of either type must be specified.\n" 154 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 155 " accepted as second parameter.",
171 "Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
192 std::map<COutPoint, Coin> coins;
196 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
198 const CTxIn& tx_in = psbtx.
tx->vin.at(i);
222 if (!coins.empty()) {
224 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
229 const CTxIn& tx_in = psbtx.
tx->vin.at(i);
240 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
249 SignPSBTInput(provider, psbtx, i, &txdata, sighash_type,
nullptr, finalize);
253 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
267 "By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled\n" 268 "and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.\n" 269 "If a blockhash argument is passed, it will return the transaction if\n" 270 "the specified block is available and the transaction is in that block.\n\n" 271 "Hint: Use gettransaction for wallet transactions.\n\n" 273 "If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.\n" 274 "If verbosity is 1, returns a JSON Object with information about the transaction.\n" 275 "If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.",
283 RPCResult{
"if verbosity is not set or set to 0",
288 Cat<std::vector<RPCResult>>(
290 {
RPCResult::Type::BOOL,
"in_active_chain",
true,
"Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
297 DecodeTxDoc(
"The transaction id (same as provided)")),
309 {
RPCResult::Type::OBJ,
"prevout",
true,
"The previous output, omitted if block undo data is not available",
324 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 0 \"myblockhash\"")
325 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 1 \"myblockhash\"")
326 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" 2 \"myblockhash\"")
343 if (!request.params[1].isNull()) {
344 if (request.params[1].isBool()) {
345 verbosity = request.params[1].get_bool();
347 verbosity = request.params[1].getInt<
int>();
351 if (!request.params[2].isNull()) {
361 bool f_txindex_ready =
false;
363 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
372 if (!block_has_data) {
375 errmsg =
"No such transaction found in the provided block";
377 errmsg =
"No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries";
378 }
else if (!f_txindex_ready) {
379 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
381 errmsg =
"No such mempool or blockchain transaction";
386 if (verbosity <= 0) {
396 if (request.params[2].isNull()) {
400 if (verbosity == 1) {
416 if (it != block.
vtx.end()) {
418 undoTX = &blockUndo.
vtxundo.at(it - block.
vtx.begin() - 1);
429 "\nCreate a transaction spending the given inputs and creating new outputs.\n" 430 "Outputs can be addresses or data.\n" 431 "Returns hex-encoded raw transaction.\n" 432 "Note that the transaction's inputs are not signed, and\n" 433 "it is not stored in the wallet or transmitted to the network.\n",
439 HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
440 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
441 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
442 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
446 std::optional<bool> rbf;
447 if (!request.params[3].isNull()) {
460 "Return a JSON object representing the serialized, hex-encoded transaction.",
464 "If iswitness is not present, heuristic tests will be used in decoding.\n" 465 "If true, only witness deserialization will be tried.\n" 466 "If false, only non-witness deserialization will be tried.\n" 467 "This boolean should reflect whether the transaction has inputs\n" 468 "(e.g. fully valid, or on-chain transactions), if known by the caller." 483 bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool();
484 bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool();
486 if (!
DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) {
502 "\nDecode a hex-encoded script.\n",
512 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
514 "address of P2SH script wrapping this redeem script (not returned for types that should not be wrapped)"},
516 "Result of a witness output script wrapping this redeem script (not returned for types that should not be wrapped)",
520 {
RPCResult::Type::STR,
"type",
"The type of the output script (e.g. witness_v0_keyhash or witness_v0_scripthash)"},
521 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
523 {
RPCResult::Type::STR,
"p2sh-segwit",
"address of the P2SH script wrapping this witness redeem script"},
535 if (request.params[0].get_str().size() > 0){
536 std::vector<unsigned char> scriptData(
ParseHexV(request.params[0],
"argument"));
543 std::vector<std::vector<unsigned char>> solutions_data;
546 const bool can_wrap{[&] {
547 switch (which_type) {
581 const bool can_wrap_P2WSH{[&] {
582 switch (which_type) {
587 for (
const auto& solution : solutions_data) {
609 if (can_wrap_P2WSH) {
624 r.
pushKV(
"segwit", std::move(sr));
636 "\nCombine multiple partially signed transactions into one transaction.\n" 637 "The combined transaction may be another partially signed transaction or a \n" 638 "fully signed transaction.",
650 HelpExampleCli(
"combinerawtransaction", R
"('["myhex1", "myhex2", "myhex3"]')") 656 std::vector<CMutableTransaction> txVariants(txs.
size());
658 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
659 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
664 if (txVariants.empty()) {
684 for (
const CTxIn& txin : mergedTx.
vin) {
695 for (
unsigned int i = 0; i < mergedTx.
vin.size(); i++) {
705 if (txv.vin.size() > i) {
721 return RPCHelpMan{
"signrawtransactionwithkey",
722 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 723 "The second argument is an array of base58-encoded private\n" 724 "keys that will be the only keys used to sign the transaction.\n" 725 "The third optional argument (may be null) is an array of previous transaction outputs that\n" 726 "this transaction depends on but may not yet be in the block chain.\n",
753 " \"ALL|ANYONECANPAY\"\n" 754 " \"NONE|ANYONECANPAY\"\n" 755 " \"SINGLE|ANYONECANPAY\"\n" 781 HelpExampleCli(
"signrawtransactionwithkey",
"\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
782 +
HelpExampleRpc(
"signrawtransactionwithkey",
"\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
787 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
793 for (
unsigned int idx = 0; idx < keys.
size(); ++idx) {
802 keystore.
pubkeys.emplace(key_id, pubkey);
803 keystore.
keys.emplace(key_id, key);
807 std::map<COutPoint, Coin> coins;
829 {
RPCResult::Type::OBJ,
"non_witness_utxo",
true,
"Decoded network transaction for non-witness UTXOs",
842 {
RPCResult::Type::STR,
"address",
true,
"The Bitcoin address (only if a well-defined address exists)"},
899 {
RPCResult::Type::OBJ,
"signature",
true,
"The signature for the pubkey and leaf hash combination",
978 {
RPCResult::Type::ARR,
"taproot_tree",
true,
"The tuples that make up the Taproot tree, in depth first search order",
1022 "Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.",
1042 {
RPCResult::Type::NUM,
"psbt_version",
"The PSBT version number. Not to be confused with the unsigned transaction version"},
1079 result.
pushKV(
"tx", std::move(tx_univ));
1084 for (
auto& xpub : xpub_pair.second) {
1085 std::vector<unsigned char> ser_xpub;
1087 xpub.EncodeWithVersion(ser_xpub.data());
1093 global_xpubs.
push_back(std::move(keypath));
1096 result.
pushKV(
"global_xpubs", std::move(global_xpubs));
1105 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1106 this_prop.
pushKV(
"subtype", entry.subtype);
1109 proprietary.
push_back(std::move(this_prop));
1111 result.
pushKV(
"proprietary", std::move(proprietary));
1115 for (
auto entry : psbtx.
unknown) {
1118 result.
pushKV(
"unknown", std::move(unknowns));
1122 bool have_all_utxos =
true;
1124 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
1128 bool have_a_utxo =
false;
1138 out.pushKV(
"scriptPubKey", std::move(o));
1140 in.
pushKV(
"witness_utxo", std::move(
out));
1149 in.
pushKV(
"non_witness_utxo", std::move(non_wit));
1155 total_in += txout.
nValue;
1158 have_all_utxos =
false;
1161 have_all_utxos =
false;
1170 in.
pushKV(
"partial_signatures", std::move(partial_sigs));
1182 in.
pushKV(
"redeem_script", std::move(r));
1187 in.
pushKV(
"witness_script", std::move(r));
1201 in.
pushKV(
"bip32_derivs", std::move(keypaths));
1209 in.
pushKV(
"final_scriptSig", std::move(scriptsig));
1216 in.
pushKV(
"final_scriptwitness", std::move(txinwitness));
1225 in.
pushKV(
"ripemd160_preimages", std::move(ripemd160_preimages));
1234 in.
pushKV(
"sha256_preimages", std::move(sha256_preimages));
1243 in.
pushKV(
"hash160_preimages", std::move(hash160_preimages));
1252 in.
pushKV(
"hash256_preimages", std::move(hash256_preimages));
1264 const auto& [xonly, leaf_hash] = pubkey_leaf;
1269 script_sigs.
push_back(std::move(sigobj));
1271 in.
pushKV(
"taproot_script_path_sigs", std::move(script_sigs));
1277 for (
const auto& [leaf, control_blocks] : input.
m_tap_scripts) {
1278 const auto& [
script, leaf_ver] = leaf;
1281 script_info.
pushKV(
"leaf_ver", leaf_ver);
1283 for (
const auto& control_block : control_blocks) {
1286 script_info.
pushKV(
"control_blocks", std::move(control_blocks_univ));
1287 tap_scripts.
push_back(std::move(script_info));
1289 in.
pushKV(
"taproot_scripts", std::move(tap_scripts));
1296 const auto& [leaf_hashes, origin] = leaf_origin;
1302 for (
const auto& leaf_hash : leaf_hashes) {
1305 path_obj.
pushKV(
"leaf_hashes", std::move(leaf_hashes_arr));
1306 keypaths.
push_back(std::move(path_obj));
1308 in.
pushKV(
"taproot_bip32_derivs", std::move(keypaths));
1326 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1327 this_prop.
pushKV(
"subtype", entry.subtype);
1330 proprietary.
push_back(std::move(this_prop));
1332 in.
pushKV(
"proprietary", std::move(proprietary));
1336 if (input.
unknown.size() > 0) {
1338 for (
auto entry : input.
unknown) {
1341 in.
pushKV(
"unknown", std::move(unknowns));
1346 result.
pushKV(
"inputs", std::move(inputs));
1351 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
1358 out.pushKV(
"redeem_script", std::move(r));
1363 out.pushKV(
"witness_script", std::move(r));
1376 out.pushKV(
"bip32_derivs", std::move(keypaths));
1389 elem.
pushKV(
"depth", (
int)depth);
1390 elem.
pushKV(
"leaf_ver", (
int)leaf_ver);
1394 out.pushKV(
"taproot_tree", std::move(tree));
1401 const auto& [leaf_hashes, origin] = leaf_origin;
1407 for (
const auto& leaf_hash : leaf_hashes) {
1410 path_obj.
pushKV(
"leaf_hashes", std::move(leaf_hashes_arr));
1411 keypaths.
push_back(std::move(path_obj));
1413 out.pushKV(
"taproot_bip32_derivs", std::move(keypaths));
1421 this_prop.
pushKV(
"identifier",
HexStr(entry.identifier));
1422 this_prop.
pushKV(
"subtype", entry.subtype);
1425 proprietary.
push_back(std::move(this_prop));
1427 out.pushKV(
"proprietary", std::move(proprietary));
1431 if (output.
unknown.size() > 0) {
1433 for (
auto entry : output.
unknown) {
1436 out.pushKV(
"unknown", std::move(unknowns));
1443 output_value += psbtx.
tx->vout[i].nValue;
1446 have_all_utxos =
false;
1449 result.
pushKV(
"outputs", std::move(outputs));
1450 if (have_all_utxos) {
1462 "\nCombine multiple partially signed Bitcoin transactions into one transaction.\n" 1463 "Implements the Combiner role.\n",
1475 HelpExampleCli(
"combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')") 1480 std::vector<PartiallySignedTransaction> psbtxs;
1485 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1491 psbtxs.push_back(psbtx);
1500 ssTx << merged_psbt;
1509 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n" 1510 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n" 1511 "created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n" 1512 "Implements the Finalizer and Extractor roles.\n",
1516 " extract and return the complete transaction in normal network serialization instead of the PSBT."},
1521 {
RPCResult::Type::STR,
"psbt",
true,
"The base64-encoded partially signed transaction if not extracted"},
1538 bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
1545 std::string result_str;
1549 result_str =
HexStr(ssTx);
1550 result.
pushKV(
"hex", result_str);
1554 result.
pushKV(
"psbt", result_str);
1556 result.
pushKV(
"complete", complete);
1566 "\nCreates a transaction in the Partially Signed Transaction format.\n" 1567 "Implements the Creator role.\n",
1573 HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
1578 std::optional<bool> rbf;
1579 if (!request.params[3].isNull()) {
1580 rbf = request.params[3].
get_bool();
1587 for (
unsigned int i = 0; i < rawTx.
vin.size(); ++i) {
1588 psbtx.
inputs.emplace_back();
1590 for (
unsigned int i = 0; i < rawTx.
vout.size(); ++i) {
1606 "\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n" 1607 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
1611 " will continue. If false, RPC will fail if any signatures are present."},
1613 "If iswitness is not present, heuristic tests will be used in decoding.\n" 1614 "If true, only witness deserialization will be tried.\n" 1615 "If false, only non-witness deserialization will be tried.\n" 1616 "This boolean should reflect whether the transaction has inputs\n" 1617 "(e.g. fully valid, or on-chain transactions), if known by the caller." 1624 "\nCreate a transaction\n" 1625 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1626 "\nConvert the transaction to a PSBT\n" 1633 bool permitsigdata = request.params[1].isNull() ? false : request.params[1].get_bool();
1634 bool witness_specified = !request.params[2].isNull();
1635 bool iswitness = witness_specified ? request.params[2].get_bool() :
false;
1636 const bool try_witness = witness_specified ? iswitness :
true;
1637 const bool try_no_witness = witness_specified ? !iswitness :
true;
1638 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
1654 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
1655 psbtx.
inputs.emplace_back();
1657 for (
unsigned int i = 0; i < tx.
vout.size(); ++i) {
1673 "\nUpdates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.\n",
1685 RPCResult::Type::STR,
"",
"The base64-encoded partially signed transaction with inputs updated" 1694 if (!request.params[1].isNull()) {
1695 auto descs = request.params[1].get_array();
1696 for (
size_t i = 0; i < descs.size(); ++i) {
1703 request.params[0].get_str(),
1719 "\nJoins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n" 1720 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1736 std::vector<PartiallySignedTransaction> psbtxs;
1739 if (txs.
size() <= 1) {
1743 uint32_t best_version = 1;
1744 uint32_t best_locktime = 0xffffffff;
1745 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1751 psbtxs.push_back(psbtx);
1753 if (psbtx.
tx->version > best_version) {
1754 best_version = psbtx.
tx->version;
1757 if (psbtx.
tx->nLockTime < best_locktime) {
1758 best_locktime = psbtx.
tx->nLockTime;
1765 merged_psbt.
tx->version = best_version;
1766 merged_psbt.
tx->nLockTime = best_locktime;
1769 for (
auto& psbt : psbtxs) {
1770 for (
unsigned int i = 0; i < psbt.tx->vin.size(); ++i) {
1771 if (!merged_psbt.
AddInput(psbt.tx->vin[i], psbt.inputs[i])) {
1775 for (
unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
1776 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1778 for (
auto& xpub_pair : psbt.m_xpubs) {
1779 if (merged_psbt.
m_xpubs.count(xpub_pair.first) == 0) {
1780 merged_psbt.
m_xpubs[xpub_pair.first] = xpub_pair.second;
1782 merged_psbt.
m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end());
1785 merged_psbt.
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
1789 std::vector<int> input_indices(merged_psbt.
inputs.size());
1790 std::iota(input_indices.begin(), input_indices.end(), 0);
1791 std::vector<int> output_indices(merged_psbt.
outputs.size());
1792 std::iota(output_indices.begin(), output_indices.end(), 0);
1796 std::shuffle(output_indices.begin(), output_indices.end(),
FastRandomContext());
1800 shuffled_psbt.tx->version = merged_psbt.
tx->version;
1801 shuffled_psbt.tx->nLockTime = merged_psbt.
tx->nLockTime;
1802 for (
int i : input_indices) {
1803 shuffled_psbt.AddInput(merged_psbt.
tx->vin[i], merged_psbt.
inputs[i]);
1805 for (
int i : output_indices) {
1806 shuffled_psbt.AddOutput(merged_psbt.
tx->vout[i], merged_psbt.
outputs[i]);
1808 shuffled_psbt.unknown.insert(merged_psbt.
unknown.begin(), merged_psbt.
unknown.end());
1811 ssTx << shuffled_psbt;
1820 "\nAnalyzes and provides information about the current status of a PSBT and its inputs\n",
1833 {
RPCResult::Type::OBJ,
"missing",
true,
"Things that are missing that are required to complete this input",
1837 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing"},
1841 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose signature is missing"},
1846 {
RPCResult::Type::STR,
"next",
true,
"Role of the next person that this input needs to go to"},
1849 {
RPCResult::Type::NUM,
"estimated_vsize",
true,
"Estimated vsize of the final signed transaction"},
1850 {
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"},
1851 {
RPCResult::Type::STR_AMOUNT,
"fee",
true,
"The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled"},
1872 for (
const auto& input : psbta.
inputs) {
1876 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1877 input_univ.
pushKV(
"is_final", input.is_final);
1880 if (!input.missing_pubkeys.empty()) {
1882 for (
const CKeyID& pubkey : input.missing_pubkeys) {
1885 missing.
pushKV(
"pubkeys", std::move(missing_pubkeys_univ));
1887 if (!input.missing_redeem_script.IsNull()) {
1888 missing.
pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
1890 if (!input.missing_witness_script.IsNull()) {
1891 missing.
pushKV(
"witnessscript",
HexStr(input.missing_witness_script));
1893 if (!input.missing_sigs.empty()) {
1895 for (
const CKeyID& pubkey : input.missing_sigs) {
1898 missing.
pushKV(
"signatures", std::move(missing_sigs_univ));
1900 if (!missing.
getKeys().empty()) {
1901 input_univ.
pushKV(
"missing", std::move(missing));
1903 inputs_result.
push_back(std::move(input_univ));
1905 if (!inputs_result.
empty()) result.
pushKV(
"inputs", std::move(inputs_result));
1913 if (psbta.
fee != std::nullopt) {
1917 if (!psbta.
error.empty()) {
1929 "\nUpdate all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool. \n" 1930 "Then, sign the inputs we are able to with information from the output descriptors. ",
1940 {
"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" 1945 " \"ALL|ANYONECANPAY\"\n" 1946 " \"NONE|ANYONECANPAY\"\n" 1947 " \"SINGLE|ANYONECANPAY\""},
1960 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[\\\"descriptor1\\\", \\\"descriptor2\\\"]\"") +
1961 HelpExampleCli(
"descriptorprocesspsbt",
"\"psbt\" \"[{\\\"desc\\\":\\\"mydescriptor\\\", \\\"range\\\":21}]\"")
1968 auto descs = request.params[1].get_array();
1969 for (
size_t i = 0; i < descs.size(); ++i) {
1974 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
1975 bool finalize = request.params[4].isNull() ? true : request.params[4].get_bool();
1978 request.params[0].get_str(),
1985 bool complete =
true;
1986 for (
const auto& input : psbtx.
inputs) {
1996 result.
pushKV(
"complete", complete);
2029 for (
const auto& c : commands) {
2030 t.appendCommand(c.name, &c);
std::shared_ptr< const CTransaction > CTransactionRef
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 AddInput(const CTxIn &txin, PSBTInput &psbtin)
bool IsSpent() const
Either this coin never existed (see e.g.
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
void push_back(UniValue val)
std::set< PSBTProprietary > m_proprietary
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.
The same as previous option with information about prevouts if available.
int64_t GetBlockTime() const
bool IsNull() const
Test whether this is the 0 key (the result of default construction).
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath, bool apostrophe)
Write HD keypaths as strings.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
void SetBackend(CCoinsView &viewIn)
node::BlockManager & m_blockman
Reference to a BlockManager instance which itself is shared across all Chainstate instances...
CTxMemPool & EnsureMemPool(const NodeContext &node)
TxVerbosity
Verbose level for block's transaction.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
CPubKey GetPubKey() const
Compute the public key from a private key.
static RPCHelpMan getrawtransaction()
static std::vector< RPCResult > ScriptPubKeyDoc()
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::map< CKeyID, CKey > keys
CScriptWitness scriptWitness
Only serialized through CTransaction.
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
static RPCHelpMan combinerawtransaction()
int ParseSighashString(const UniValue &sighash)
Returns a sighash value corresponding to the passed in argument.
bool MoneyRange(const CAmount &nValue)
#define CHECK_NONFATAL(condition)
Identity function.
int Height() const
Return the maximal height in the chain.
CTxOut out
unspent transaction output
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.
static void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry, Chainstate &active_chainstate, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
std::vector< std::vector< unsigned char > > stack
std::string EncodeBase64(Span< const unsigned char > input)
const RPCResult decodepsbt_inputs
const UniValue & get_array() const
const CBlock & GenesisBlock() const
A version of CTransaction with the PSBT format.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos) const
Functions for disk access for blocks.
A signature creator for transactions.
const std::vector< std::string > & getKeys() const
std::map< XOnlyPubKey, std::pair< std::set< uint256 >, KeyOriginInfo > > m_tap_bip32_paths
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...
CChain m_chain
The current chain of blockheaders we consult and build on.
RPCHelpMan descriptorprocesspsbt()
static RPCHelpMan decoderawtransaction()
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
std::map< KeyOriginInfo, std::set< CExtPubKey > > m_xpubs
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
bool IsSegWitOutput(const SigningProvider &provider, const CScript &script)
Check whether a scriptPubKey is known to be segwit.
std::optional< CAmount > fee
Amount of fee being paid by the transaction.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
XOnlyPubKey m_tap_internal_key
Invalid, missing or duplicate parameter.
std::string PSBTRoleName(PSBTRole role)
int64_t CAmount
Amount in satoshis (Can be negative)
std::string GetAllOutputTypes()
Gets all existing output types formatted for RPC help sections.
std::optional< size_t > estimated_vsize
Estimated weight of the transaction.
static RPCHelpMan createpsbt()
A structure for PSBTs which contains per output information.
General error during transaction or block submission.
std::vector< PSBTOutput > outputs
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Special type that is a STR with only hex chars.
NodeContext struct containing references to chain state and connection state.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
std::string error
Error message.
static RPCHelpMan finalizepsbt()
UniValue JSONRPCError(int code, const std::string &message)
Special string with only hex chars.
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
static RPCHelpMan converttopsbt()
static RPCHelpMan combinepsbt()
Chainstate stores and provides an API to update our local knowledge of the current best chain...
Include TXID, inputs, outputs, and other common block's transaction information.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex=true, bool include_address=false, const SigningProvider *provider=nullptr)
Abstract view on the open txout dataset.
std::map< CScriptID, CScript > scripts
An input of a transaction.
uint32_t GetVersion() const
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
Double ended buffer combining vector and stream-like interfaces.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
std::optional< CFeeRate > estimated_feerate
Estimated feerate (fee / weight) of the transaction.
const SigningProvider & DUMMY_SIGNING_PROVIDER
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
An encapsulated public key.
std::map< CKeyID, CPubKey > pubkeys
opcodetype
Script opcodes.
Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e...
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::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
bool UndoReadFromDisk(CBlockUndo &blockundo, const CBlockIndex &index) const
const std::string CURRENCY_UNIT
PartiallySignedTransaction ProcessPSBT(const std::string &psbt_string, const std::any &context, const HidingSigningProvider &provider, int sighash_type, bool finalize)
static uint32_t ReadBE32(const unsigned char *ptr)
std::string SighashToStr(unsigned char sighash_type)
General application defined errors.
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, std::optional< bool > rbf)
Create a transaction from univalue parameters.
std::string DefaultHint
Hint for default value.
An output of a transaction.
static std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc)
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
void MergeSignatureData(SignatureData sigdata)
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::vector< CTxOut > vout
constexpr bool IsNull() const
static RPCHelpMan utxoupdatepsbt()
std::vector< PSBTInput > inputs
Special numeric to denote unix epoch time.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
void RegisterRawTransactionRPCCommands(CRPCTable &t)
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
static RPCHelpMan signrawtransactionwithkey()
std::vector< PSBTInputAnalysis > inputs
More information about the individual inputs of the transaction.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
std::vector< std::tuple< uint8_t, uint8_t, std::vector< unsigned char > > > m_tap_tree
Special type that is a NUM or [NUM,NUM].
std::string EncodeBase58Check(Span< const unsigned char > input)
Encode a byte span into a base58-encoded string, including checksum.
const CChainParams & GetParams() const
#define extract(n)
Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits.
Optional argument for which the default value is omitted from help text for one of two reasons: ...
std::string EncodeHexTx(const CTransaction &tx)
std::vector< CTransactionRef > vtx
static std::vector< RPCArg > CreateTxDoc()
static RPCHelpMan decodescript()
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Special string to represent a floating point amount.
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
The block chain is a tree shaped structure starting with the genesis block at the root...
void pushKV(std::string key, UniValue val)
Undo information for a CBlock.
Serialized script, used inside transaction inputs and outputs.
uint256 ParseHashV(const UniValue &v, std::string_view name)
Utilities: convert hex-encoded Values (throws error if not hex).
Undo information for a CTransaction.
ChainstateManager & EnsureChainman(const NodeContext &node)
Holds the results of AnalyzePSBT (miscellaneous information about a PSBT)
#define NONFATAL_UNREACHABLE()
NONFATAL_UNREACHABLE() is a macro that is used to mark unreachable code.
A reference to a CKey: the Hash160 of its serialized public key.
void UpdateInput(CTxIn &input, const SignatureData &data)
Special type representing a floating point amount (can be either NUM or STR)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
std::string GetHex() const
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
UniValue ValueFromAmount(const CAmount amount)
const RPCResult decodepsbt_outputs
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
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 ...
A reference to a CScript: the Hash160 of its serialization.
std::string EncodeDestination(const CTxDestination &dest)
A mutable version of CTransaction.
static RPCHelpMan decodepsbt()
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed by checking for non-null finalized fields.
An encapsulated private key.
A Span is an object that can refer to a contiguous sequence of objects.
The basic transaction that is broadcasted on the network and contained in blocks. ...
const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
int nHeight
height of the entry in the chain. The genesis block has height 0
std::set< PSBTProprietary > m_proprietary
void RemoveUnnecessaryTransactions(PartiallySignedTransaction &psbtx, const int &sighash_type)
Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e.
Special dictionary with keys that are not literals.
CKey DecodeSecret(const std::string &str)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
std::optional< CMutableTransaction > tx
full block available in blk*.dat
static RPCHelpMan analyzepsbt()
is a home for public enum and struct type definitions that are used by internally by node code...
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
std::vector< CTxUndo > vtxundo
Only for Witness versions not already defined above.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
static RPCHelpMan createrawtransaction()
PSBTRole next
Which of the BIP 174 roles needs to handle the transaction next.
CCoinsView that brings transactions from a mempool into view.
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
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...
NodeContext & EnsureAnyNodeContext(const std::any &context)
bool IsOpSuccess(const opcodetype &opcode)
Test for OP_SUCCESSx opcodes as defined by BIP342.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
Error parsing or validating structure in raw format.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
static constexpr TransactionSerParams TX_WITH_WITNESS
bool IsValid() const
Check whether this private key is valid.
Special type to denote elision (...)
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
static RPCHelpMan joinpsbts()
unspendable OP_RETURN script that carries data
PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
bool IsCompressed() const
Check whether this is a compressed public key.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string_view name)