76 entry.
pushKV(
"confirmations",
82 entry.
pushKV(
"confirmations", 0);
91 "\nReturn the raw transaction data.\n"
92 "\nBy default, this call only returns a transaction if it is in the "
93 "mempool. If -txindex is enabled\n"
94 "and no blockhash argument is passed, it will return the transaction "
95 "if it is in the mempool or any block.\n"
96 "If a blockhash argument is passed, it will return the transaction if\n"
97 "the specified block is available and the transaction is in that "
99 "\nIf verbose is 'true', returns an Object with information about "
101 "If verbose is 'false' or omitted, returns a string that is "
102 "serialized, hex-encoded data for 'txid'.\n",
105 "The transaction id"},
107 "If false, return a string, otherwise return a json object"},
110 "The block in which to look for the transaction"},
113 RPCResult{
"if verbose is not set or set to false",
115 "The serialized, hex-encoded data for 'txid'"},
117 "if verbose is set to true",
123 "Whether specified block is in the active chain or not "
124 "(only present with explicit \"blockhash\" argument)"},
126 "The serialized, hex-encoded data for 'txid'"},
128 "The transaction id (same as provided)"},
131 "The serialized transaction size"},
143 "The transaction id"},
153 "The script sequence number"},
174 "The required sigs"},
176 "The type, eg 'pubkeyhash'"},
189 "The confirmations"},
199 "\"mytxid\" false \"myblockhash\"") +
201 "\"mytxid\" true \"myblockhash\"")},
207 bool in_active_chain =
true;
216 "The genesis block coinbase is not considered an "
217 "ordinary transaction and cannot be retrieved");
222 bool fVerbose =
false;
223 if (!request.params[1].isNull()) {
224 fVerbose = request.params[1].isNum()
225 ? (request.params[1].get_int() != 0)
226 : request.params[1].get_bool();
229 if (!request.params[2].isNull()) {
233 ParseHashV(request.params[2],
"parameter 3"));
237 "Block hash not found");
242 bool f_txindex_ready =
false;
244 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
255 return !blockindex->nStatus.hasData())) {
257 "Block not available");
259 errmsg =
"No such transaction found in the provided block";
262 "No such mempool transaction. Use -txindex or provide "
263 "a block hash to enable blockchain transaction queries";
264 }
else if (!f_txindex_ready) {
265 errmsg =
"No such mempool transaction. Blockchain "
266 "transactions are still in the process of being "
269 errmsg =
"No such mempool or blockchain transaction";
273 errmsg +
". Use gettransaction for wallet transactions.");
282 result.
pushKV(
"in_active_chain", in_active_chain);
284 TxToJSON(*tx, hash_block, result, chainman.ActiveChainstate());
292 "createrawtransaction",
293 "Create a transaction spending the given inputs and creating new "
295 "Outputs can be addresses or data.\n"
296 "Returns hex-encoded raw transaction.\n"
297 "Note that the transaction's inputs are not signed, and\n"
298 "it is not stored in the wallet or transmitted to the network.\n",
315 "The output number"},
318 "'locktime' argument"},
319 "The sequence number"},
328 "The outputs (key-value pairs), where none of "
329 "the keys are duplicated.\n"
330 "That is, each address can only appear once and there can only "
331 "be one 'data' object.\n"
332 "For compatibility reasons, a dictionary, which holds the "
333 "key-value pairs directly, is also\n"
334 " accepted as second parameter.",
344 "A key-value pair. The key (string) is the "
345 "bitcoin address, the value (float or string) is "
358 "A key-value pair. The key must be \"data\", the "
359 "value is hex-encoded data"},
365 "Raw locktime. Non-0 value also locktime-activates inputs"},
368 "hex string of the transaction"},
371 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
372 "\" \"[{\\\"address\\\":10000.00}]\"") +
374 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
375 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
377 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
378 "\", \"[{\\\"address\\\":10000.00}]\"") +
380 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
381 "\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
392 request.params[1], request.params[2]);
401 "decoderawtransaction",
402 "Return a JSON object representing the serialized, hex-encoded "
406 "The transaction hex string"},
427 "The transaction id"},
437 "The script sequence number"},
458 "The required sigs"},
460 "The type, eg 'pubkeyhash'"},
480 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
496 "Decode a hex-encoded script.\n",
499 "the hex-encoded script"},
517 "address of P2SH script wrapping this redeem script (not "
518 "returned if the script is already a P2SH)"},
528 if (request.params[0].get_str().size() > 0) {
529 std::vector<uint8_t> scriptData(
530 ParseHexV(request.params[0],
"argument"));
531 script =
CScript(scriptData.begin(), scriptData.end());
554 "combinerawtransaction",
555 "Combine multiple partially signed transactions into one "
557 "The combined transaction may be another partially signed transaction "
559 "fully signed transaction.",
565 "The hex strings of partially signed "
570 "A hex-encoded raw transaction"},
575 "The hex-encoded raw transaction with signature(s)"},
577 R
"('["myhex1", "myhex2", "myhex3"]')")},
581 std::vector<CMutableTransaction> txVariants(txs.
size());
583 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
584 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
587 strprintf(
"TX decode failed for tx %d", idx));
591 if (txVariants.empty()) {
593 "Missing transactions");
609 chainman.ActiveChainstate().CoinsTip();
614 for (
const CTxIn &txin : mergedTx.
vin) {
627 for (
size_t i = 0; i < mergedTx.
vin.size(); i++) {
632 "Input not found or already spent");
640 if (txv.vin.size() > i) {
647 &mergedTx, i, txout.
nValue),
660 "signrawtransactionwithkey",
661 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
662 "The second argument is an array of base58-encoded private\n"
663 "keys that will be the only keys used to sign the transaction.\n"
664 "The third optional argument (may be null) is an array of previous "
665 "transaction outputs that\n"
666 "this transaction depends on but may not yet be in the block chain.\n",
669 "The transaction hex string"},
674 "The base58-encoded private keys for signing",
677 "private key in base58-encoding"},
684 "The previous dependent transaction outputs",
695 "The output number"},
700 "(required for P2SH) redeem script"},
708 "The signature hash type. Must be one of:\n"
711 " \"SINGLE|FORKID\"\n"
712 " \"ALL|FORKID|ANYONECANPAY\"\n"
713 " \"NONE|FORKID|ANYONECANPAY\"\n"
714 " \"SINGLE|FORKID|ANYONECANPAY\""},
722 "The hex-encoded raw transaction with signature(s)"},
724 "If the transaction has a complete set of signatures"},
728 "Script verification errors (if there are any)",
735 "The hash of the referenced, previous transaction"},
737 "The index of the output to spent and used as "
740 "The hex-encoded signature script"},
742 "Script sequence number"},
744 "Verification or signing error related to the "
751 "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") +
753 "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")},
757 {UniValue::VSTR, UniValue::VARR, UniValue::VARR,
762 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
769 for (
size_t idx = 0; idx < keys.
size(); ++idx) {
774 "Invalid private key");
780 std::map<COutPoint, Coin> coins;
800 "sendrawtransaction",
801 "Submits raw transaction (serialized, hex-encoded) to local node and "
803 "\nAlso see createrawtransaction and "
804 "signrawtransactionwithkey calls.\n",
807 "The hex string of the raw transaction"},
811 "Reject transactions whose fee rate is higher than the specified "
812 "value, expressed in " +
814 "/kB\nSet to 0 to accept any fee rate.\n"},
818 "\nCreate a transaction\n" +
820 "createrawtransaction",
821 "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" "
822 "\"{\\\"myaddress\\\":10000}\"") +
823 "Sign the transaction, and get back the hex\n" +
825 "\nSend the transaction (signed hex)\n" +
827 "\nAs a JSON-RPC call\n" +
840 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
847 const CFeeRate max_raw_tx_fee_rate =
848 request.params[1].isNull()
853 Amount max_raw_tx_fee = max_raw_tx_fee_rate.
GetFee(virtual_size);
855 std::string err_string;
859 node, tx, err_string, max_raw_tx_fee,
true,
868 return tx->GetHash().GetHex();
876 "\nReturns result of mempool acceptance tests indicating if raw "
877 "transaction(s) (serialized, hex-encoded) would be accepted by "
879 "\nIf multiple transactions are passed in, parents must come before "
880 "children and package policies apply: the transactions cannot conflict "
881 "with any mempool transactions or each other.\n"
882 "\nIf one transaction fails, other transactions may not be fully "
883 "validated (the 'allowed' key will be blank).\n"
884 "\nThe maximum number of transactions allowed is " +
887 "\nThis checks if transactions violate the consensus or policy "
889 "\nSee sendrawtransaction call.\n",
895 "An array of hex strings of raw transactions.",
904 "Reject transactions whose fee rate is higher than the specified "
905 "value, expressed in " +
911 "The result of the mempool acceptance test for each raw "
912 "transaction in the input array.\n"
913 "Returns results for each transaction in the same order they were "
915 "Transactions that cannot be fully validated due to failures in "
916 "other transactions will not contain an 'allowed' result.\n",
923 "The transaction hash in hex"},
925 "Package validation error, if any (only possible if "
926 "rawtxs had more than 1 transaction)."},
928 "Whether this tx would be accepted to the mempool and "
929 "pass client-specified maxfeerate. "
930 "If not present, the tx was not fully validated due to a "
931 "failure in another tx in the list."},
935 "Transaction fees (only present if 'allowed' is true)",
941 "Rejection string (only present when 'allowed' is "
946 "\nCreate a transaction\n" +
948 "createrawtransaction",
949 "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" "
950 "\"{\\\"myaddress\\\":10000}\"") +
951 "Sign the transaction, and get back the hex\n" +
953 "\nTest acceptance of the transaction (signed hex)\n" +
955 "\nAs a JSON-RPC call\n" +
966 if (raw_transactions.
size() < 1 ||
969 "Array must contain between 1 and " +
974 const CFeeRate max_raw_tx_fee_rate =
975 request.params[1].isNull()
979 std::vector<CTransactionRef> txns;
980 txns.reserve(raw_transactions.
size());
981 for (
const auto &rawtx : raw_transactions.
getValues()) {
985 "TX decode failed: " + rawtx.get_str());
993 Chainstate &chainstate = chainman.ActiveChainstate();
996 if (txns.size() > 1) {
1012 bool exit_early{
false};
1013 for (
const auto &tx : txns) {
1015 result_inner.
pushKV(
"txid", tx->GetId().GetHex());
1022 auto it = package_result.
m_tx_results.find(tx->GetId());
1023 if (exit_early || it == package_result.
m_tx_results.end()) {
1028 const auto &tx_result = it->second;
1033 if (tx_result.m_result_type ==
1035 const Amount fee = tx_result.m_base_fees.value();
1037 const int64_t virtual_size = tx_result.m_vsize.value();
1038 const Amount max_raw_tx_fee =
1039 max_raw_tx_fee_rate.
GetFee(virtual_size);
1041 fee > max_raw_tx_fee) {
1042 result_inner.
pushKV(
"allowed",
false);
1043 result_inner.
pushKV(
"reject-reason",
1044 "max-fee-exceeded");
1050 result_inner.
pushKV(
"allowed",
true);
1051 result_inner.
pushKV(
"size", virtual_size);
1053 fees.
pushKV(
"base", fee);
1054 result_inner.
pushKV(
"fees", fees);
1057 result_inner.
pushKV(
"allowed",
false);
1061 result_inner.
pushKV(
"reject-reason",
"missing-inputs");
1063 result_inner.
pushKV(
"reject-reason",
1077 "Return a JSON object representing the serialized, base64-encoded "
1078 "partially signed Bitcoin transaction.\n",
1081 "The PSBT base64 string"},
1090 "The decoded network-serialized unsigned transaction.",
1093 "The layout is the same as the output of "
1094 "decoderawtransaction."},
1098 "The unknown global fields",
1101 "(key-value pair) An unknown key-value pair"},
1114 "Transaction output for UTXOs",
1126 "The type, eg 'pubkeyhash'"},
1128 " Bitcoin address if there is one"},
1132 "partial_signatures",
1137 "The public key and signature that corresponds "
1141 "The sighash type to be used"},
1150 "The type, eg 'pubkeyhash'"},
1160 "The public key with the derivation path as "
1164 "The fingerprint of the master key"},
1178 "The unknown global fields",
1181 "(key-value pair) An unknown key-value pair"},
1201 "The type, eg 'pubkeyhash'"},
1213 "The public key this path corresponds to"},
1215 "The fingerprint of the master key"},
1221 "The unknown global fields",
1224 "(key-value pair) An unknown key-value pair"},
1229 "The transaction fee paid if all UTXOs slots in the PSBT have "
1250 result.
pushKV(
"tx", tx_univ);
1253 if (psbtx.
unknown.size() > 0) {
1255 for (
auto entry : psbtx.
unknown) {
1258 result.
pushKV(
"unknown", unknowns);
1263 bool have_all_utxos =
true;
1265 for (
size_t i = 0; i < psbtx.
inputs.size(); ++i) {
1277 total_in += txout.
nValue;
1280 have_all_utxos =
false;
1285 out.
pushKV(
"scriptPubKey", o);
1288 have_all_utxos =
false;
1298 in.
pushKV(
"partial_signatures", partial_sigs);
1302 uint8_t sighashbyte =
1304 if (sighashbyte > 0) {
1312 in.
pushKV(
"redeem_script", r);
1323 "master_fingerprint",
1325 ReadBE32(entry.second.fingerprint)));
1330 in.
pushKV(
"bip32_derivs", keypaths);
1339 in.
pushKV(
"final_scriptSig", scriptsig);
1343 if (input.
unknown.size() > 0) {
1345 for (
auto entry : input.
unknown) {
1349 in.
pushKV(
"unknown", unknowns);
1354 result.
pushKV(
"inputs", inputs);
1359 for (
size_t i = 0; i < psbtx.
outputs.size(); ++i) {
1366 out.
pushKV(
"redeem_script", r);
1376 "master_fingerprint",
1378 ReadBE32(entry.second.fingerprint)));
1383 out.
pushKV(
"bip32_derivs", keypaths);
1387 if (output.
unknown.size() > 0) {
1389 for (
auto entry : output.
unknown) {
1393 out.
pushKV(
"unknown", unknowns);
1401 output_value += psbtx.
tx->vout[i].nValue;
1404 have_all_utxos =
false;
1407 result.
pushKV(
"outputs", outputs);
1408 if (have_all_utxos) {
1409 result.
pushKV(
"fee", total_in - output_value);
1420 "Combine multiple partially signed Bitcoin transactions into one "
1422 "Implements the Combiner role.\n",
1428 "The base64 strings of partially signed transactions",
1431 "A base64 string of a PSBT"},
1436 "The base64-encoded partially signed transaction"},
1438 "combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")},
1444 std::vector<PartiallySignedTransaction> psbtxs;
1448 "Parameter 'txs' cannot be empty");
1450 for (
size_t i = 0; i < txs.
size(); ++i) {
1457 psbtxs.push_back(psbtx);
1467 ssTx << merged_psbt;
1476 "Finalize the inputs of a PSBT. If the transaction is fully signed, it "
1478 "network serialized transaction which can be broadcast with "
1479 "sendrawtransaction. Otherwise a PSBT will be\n"
1480 "created which has the final_scriptSigfields filled for inputs that "
1482 "Implements the Finalizer and Extractor roles.\n",
1485 "A base64 string of a PSBT"},
1487 "If true and the transaction is complete,\n"
1488 " extract and return the complete "
1489 "transaction in normal network serialization instead of the "
1497 "The base64-encoded partially signed transaction if not "
1500 "The hex-encoded network transaction if extracted"},
1502 "If the transaction has a complete set of signatures"},
1507 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL},
1519 request.params[1].isNull() ||
1520 (!request.params[1].isNull() && request.params[1].get_bool());
1527 std::string result_str;
1531 result_str =
HexStr(ssTx);
1532 result.
pushKV(
"hex", result_str);
1536 result.
pushKV(
"psbt", result_str);
1538 result.
pushKV(
"complete", complete);
1548 "Creates a transaction in the Partially Signed Transaction format.\n"
1549 "Implements the Creator role.\n",
1566 "The output number"},
1569 "'locktime' argument"},
1570 "The sequence number"},
1579 "The outputs (key-value pairs), where none of "
1580 "the keys are duplicated.\n"
1581 "That is, each address can only appear once and there can only "
1582 "be one 'data' object.\n"
1583 "For compatibility reasons, a dictionary, which holds the "
1584 "key-value pairs directly, is also\n"
1585 " accepted as second parameter.",
1595 "A key-value pair. The key (string) is the "
1596 "bitcoin address, the value (float or string) is "
1609 "A key-value pair. The key must be \"data\", the "
1610 "value is hex-encoded data"},
1616 "Raw locktime. Non-0 value also locktime-activates inputs"},
1619 "The resulting raw transaction (base64-encoded string)"},
1621 "createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1622 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
1635 request.params[1], request.params[2]);
1640 for (
size_t i = 0; i < rawTx.
vin.size(); ++i) {
1643 for (
size_t i = 0; i < rawTx.
vout.size(); ++i) {
1659 "Converts a network serialized transaction to a PSBT. "
1660 "This should be used only with createrawtransaction and "
1661 "fundrawtransaction\n"
1662 "createpsbt and walletcreatefundedpsbt should be used for new "
1666 "The hex string of a raw transaction"},
1668 "If true, any signatures in the input will be discarded and "
1670 " will continue. If false, RPC will "
1671 "fail if any signatures are present."},
1674 "The resulting raw transaction (base64-encoded string)"},
1676 "\nCreate a transaction\n" +
1678 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1679 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1680 "\nConvert the transaction to a PSBT\n" +
1684 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL},
1689 bool permitsigdata = request.params[1].isNull()
1691 : request.params[1].get_bool();
1692 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
1694 "TX decode failed");
1701 "Inputs must not have scriptSigs");
1709 for (
size_t i = 0; i < tx.
vin.size(); ++i) {
1712 for (
size_t i = 0; i < tx.
vout.size(); ++i) {
1728 "Updates all inputs and outputs in a PSBT with data from output "
1729 "descriptors, the UTXO set or the mempool.\n",
1732 "A base64 string of a PSBT"},
1736 "An array of either strings or objects",
1739 "An output descriptor"},
1743 "An object with an output descriptor and extra information",
1746 "An output descriptor"},
1748 "Up to what index HD chains should be explored (either "
1749 "end or [begin,end])"},
1754 "The base64-encoded partially signed transaction with inputs "
1759 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR},
1772 if (!request.params[1].isNull()) {
1773 auto descs = request.params[1].get_array();
1774 for (
size_t i = 0; i < descs.size(); ++i) {
1792 chainman.ActiveChainstate().CoinsTip();
1797 for (
const CTxIn &txin : psbtx.
tx->vin) {
1807 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
1823 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1837 "Joins multiple distinct PSBTs with different inputs and outputs "
1838 "into one PSBT with inputs and outputs from all of the PSBTs\n"
1839 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1843 "The base64 strings of partially signed transactions",
1845 "A base64 string of a PSBT"}}}},
1847 "The base64-encoded partially signed transaction"},
1854 std::vector<PartiallySignedTransaction> psbtxs;
1857 if (txs.
size() <= 1) {
1860 "At least two PSBTs are required to join PSBTs.");
1863 uint32_t best_version = 1;
1864 uint32_t best_locktime = 0xffffffff;
1865 for (
size_t i = 0; i < txs.
size(); ++i) {
1872 psbtxs.push_back(psbtx);
1874 if (
static_cast<uint32_t
>(psbtx.
tx->nVersion) > best_version) {
1875 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1878 if (psbtx.
tx->nLockTime < best_locktime) {
1879 best_locktime = psbtx.
tx->nLockTime;
1886 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1887 merged_psbt.
tx->nLockTime = best_locktime;
1890 for (
auto &psbt : psbtxs) {
1891 for (
size_t i = 0; i < psbt.tx->vin.size(); ++i) {
1892 if (!merged_psbt.
AddInput(psbt.tx->vin[i],
1896 strprintf(
"Input %s:%d exists in multiple PSBTs",
1901 psbt.tx->vin[i].prevout.GetN()));
1904 for (
size_t i = 0; i < psbt.tx->vout.size(); ++i) {
1905 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1907 merged_psbt.
unknown.insert(psbt.unknown.begin(),
1908 psbt.unknown.end());
1913 std::vector<int> input_indices(merged_psbt.
inputs.size());
1914 std::iota(input_indices.begin(), input_indices.end(), 0);
1915 std::vector<int> output_indices(merged_psbt.
outputs.size());
1916 std::iota(output_indices.begin(), output_indices.end(), 0);
1919 Shuffle(input_indices.begin(), input_indices.end(),
1921 Shuffle(output_indices.begin(), output_indices.end(),
1926 shuffled_psbt.
tx->nVersion = merged_psbt.
tx->nVersion;
1927 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1928 for (
int i : input_indices) {
1929 shuffled_psbt.
AddInput(merged_psbt.
tx->vin[i],
1932 for (
int i : output_indices) {
1940 ssTx << shuffled_psbt;
1949 "Analyzes and provides information about the current status of a "
1950 "PSBT and its inputs\n",
1952 "A base64 string of a PSBT"}},
1967 "Whether a UTXO is provided"},
1969 "Whether the input is finalized"},
1973 "Things that are missing that are required to "
1974 "complete this input",
1982 "Public key ID, hash160 of the public "
1983 "key, of a public key whose BIP 32 "
1984 "derivation path is missing"},
1992 "Public key ID, hash160 of the public "
1993 "key, of a public key whose signature is "
1998 "Hash160 of the redeemScript that is missing"},
2001 "Role of the next person that this input needs to "
2006 "Estimated vsize of the final signed transaction"},
2009 "Estimated feerate of the final signed transaction in " +
2011 "/kB. Shown only if all UTXO slots in the PSBT have been "
2014 "The transaction fee paid. Shown only if all UTXO slots in "
2015 "the PSBT have been filled"},
2017 "Role of the next person that this psbt needs to go to"},
2019 "Error message (if there is one)"},
2038 for (
const auto &input : psbta.
inputs) {
2042 input_univ.
pushKV(
"has_utxo", input.has_utxo);
2043 input_univ.
pushKV(
"is_final", input.is_final);
2046 if (!input.missing_pubkeys.empty()) {
2048 for (
const CKeyID &pubkey : input.missing_pubkeys) {
2051 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
2053 if (!input.missing_redeem_script.IsNull()) {
2054 missing.
pushKV(
"redeemscript",
2055 HexStr(input.missing_redeem_script));
2057 if (!input.missing_sigs.empty()) {
2059 for (
const CKeyID &pubkey : input.missing_sigs) {
2062 missing.
pushKV(
"signatures", missing_sigs_univ);
2064 if (!missing.
getKeys().empty()) {
2065 input_univ.
pushKV(
"missing", missing);
2069 if (!inputs_result.
empty()) {
2070 result.
pushKV(
"inputs", inputs_result);
2076 result.
pushKV(
"estimated_feerate",
2079 if (psbta.
fee != std::nullopt) {
2083 if (!psbta.
error.empty()) {
2115 for (
const auto &c : commands) {
bool MoneyRange(const Amount nValue)
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
#define CHECK_NONFATAL(condition)
Identity function.
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
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.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
const Consensus::Params & GetConsensus() const
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.
Double ended buffer combining vector and stream-like interfaces.
Fee rate in satoshis per kilobyte: Amount / kB.
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Amount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
An encapsulated secp256k1 private key.
bool IsValid() const
Check whether this private key is valid.
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
std::vector< CTxOut > vout
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
An output of a transaction.
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...
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
MempoolAcceptResult ProcessTransaction(const CTransactionRef &tx, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Try to add a transaction to the memory pool.
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddKey(const CKey &key)
A signature creator for transactions.
Signature hash type wrapper class.
uint32_t getRawSigHashType() const
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const std::vector< UniValue > & getValues() const
const std::vector< std::string > & getKeys() const
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool pushKV(const std::string &key, const UniValue &val)
std::string GetRejectReason() const
std::string GetHex() const
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@ TX_MISSING_INPUTS
transaction was missing some of its inputs
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
std::string SighashToStr(uint8_t sighash_type)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
static uint32_t ReadBE32(const uint8_t *ptr)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
CKey DecodeSecret(const std::string &str)
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const TxId &txid, const Consensus::Params &consensusParams, BlockHash &hashBlock)
Return transaction with a given txid.
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
TransactionError BroadcastTransaction(const NodeContext &node, const CTransactionRef tx, std::string &err_string, const Amount max_tx_fee, bool relay, bool wait_callback)
Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params ¶ms)
Functions for disk access for blocks.
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE
Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls.
static constexpr uint32_t MAX_PACKAGE_COUNT
Default maximum number of transactions in a package.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
Compute the virtual transaction size (size, or more if sigChecks are too dense).
static CTransactionRef MakeTransactionRef()
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(const PSBTRole role)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
TransactionError CombinePSBTs(PartiallySignedTransaction &out, const std::vector< PartiallySignedTransaction > &psbtxs)
Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial sign...
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, SigHashType sighash, SignatureData *out_sigdata, bool use_dummy)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
void Shuffle(I first, I last, R &&rng)
More efficient than using std::shuffle on a FastRandomContext.
static RPCHelpMan getrawtransaction()
static RPCHelpMan sendrawtransaction()
static RPCHelpMan converttopsbt()
static RPCHelpMan decoderawtransaction()
static RPCHelpMan combinepsbt()
static RPCHelpMan decodepsbt()
static RPCHelpMan decodescript()
static RPCHelpMan createpsbt()
RPCHelpMan utxoupdatepsbt()
static RPCHelpMan combinerawtransaction()
static void TxToJSON(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, Chainstate &active_chainstate)
static RPCHelpMan testmempoolaccept()
static RPCHelpMan signrawtransactionwithkey()
static RPCHelpMan createrawtransaction()
static RPCHelpMan finalizepsbt()
void RegisterRawTransactionRPCCommands(CRPCTable &t)
void SignTransaction(CMutableTransaction &mtx, const SigningProvider *keystore, const std::map< COutPoint, Coin > &coins, const UniValue &hashType, UniValue &result)
Sign a transaction with the given keystore and previous transactions.
CMutableTransaction ConstructTransaction(const CChainParams ¶ms, const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime)
Create a transaction from univalue parameters.
void ParsePrevouts(const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ 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< uint8_t > ParseHexV(const UniValue &v, std::string strName)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
Amount AmountFromValue(const UniValue &value)
std::vector< CScript > EvalDescriptorStringOrObject(const UniValue &scanobject, FlatSigningProvider &provider)
Evaluate a descriptor given as a string, or as a {"desc":...,"range":...} object, with default range ...
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
std::string GetAllOutputTypes()
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
#define extract(n)
Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits.
int RPCSerializationFlags()
Retrieves any serialization flags requested in command line argument.
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)
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
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const uint8_t > input)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
static const Currency & get()
@ MEMPOOL_ENTRY
Valid, transaction was already in the mempool.
@ VALID
Fully validated, valid.
A structure for PSBTs which contains per output information.
std::map< CPubKey, KeyOriginInfo > hd_keypaths
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
Validation result for package mempool acceptance.
std::map< const TxId, const MempoolAcceptResult > m_tx_results
Map from txid to finished MempoolAcceptResults.
const PackageValidationState m_state
A version of CTransaction with the PSBT format.
std::map< std::vector< uint8_t >, std::vector< uint8_t > > 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
@ RANGE
Special type that is a NUM or [NUM,NUM].
@ 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)
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
@ 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)
A TxId is the identifier of a transaction.
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< Amount > 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 AssertLockNotHeld(cs)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
bool error(const char *fmt, const Args &...args)
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
PackageMempoolAcceptResult ProcessNewPackage(Chainstate &active_chainstate, CTxMemPool &pool, const Package &package, bool test_accept)
Validate (and maybe submit) a package to the mempool.
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
static const int PROTOCOL_VERSION
network protocol versioning