63 entry.
pushKV(
"confirmations",
68 entry.
pushKV(
"confirmations", 0);
78 "By default this function only works for mempool transactions. When " 79 "called with a blockhash\n" 80 "argument, getrawtransaction will return the transaction if the " 81 "specified block is available and\n" 82 "the transaction is found in that block. When called without a " 83 "blockhash argument, getrawtransaction\n" 84 "will return the transaction if it is in the mempool, or if -txindex " 85 "is enabled and the transaction\n" 86 "is in a block in the blockchain.\n" 88 "\nReturn the raw transaction data.\n" 89 "\nIf verbose is 'true', returns an Object with information about " 91 "If verbose is 'false' or omitted, returns a string that is " 92 "serialized, hex-encoded data for 'txid'.\n",
95 "The transaction id"},
97 "If false, return a string, otherwise return a json object"},
100 "The block in which to look for the transaction"},
103 RPCResult{
"if verbose is not set or set to false",
105 "The serialized, hex-encoded data for 'txid'"},
107 "if verbose is set to true",
113 "Whether specified block is in the active chain or not " 114 "(only present with explicit \"blockhash\" argument)"},
116 "The serialized, hex-encoded data for 'txid'"},
118 "The transaction id (same as provided)"},
121 "The serialized transaction size"},
133 "The transaction id"},
143 "The script sequence number"},
164 "The required sigs"},
166 "The type, eg 'pubkeyhash'"},
179 "The confirmations"},
189 "\"mytxid\" false \"myblockhash\"") +
191 "\"mytxid\" true \"myblockhash\"")},
195 bool in_active_chain =
true;
203 "The genesis block coinbase is not considered an " 204 "ordinary transaction and cannot be retrieved");
208 bool fVerbose =
false;
222 "Block hash not found");
227 bool f_txindex_ready =
false;
229 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
241 errmsg =
"No such transaction found in the provided block";
243 errmsg =
"No such mempool transaction. Use -txindex or provide a " 244 "block hash to enable blockchain transaction queries";
245 }
else if (!f_txindex_ready) {
246 errmsg =
"No such mempool transaction. Blockchain transactions are " 247 "still in the process of being indexed";
249 errmsg =
"No such mempool or blockchain transaction";
253 ". Use gettransaction for wallet transactions.");
262 result.
pushKV(
"in_active_chain", in_active_chain);
272 "Returns a hex-encoded proof that \"txid\" was included in a block.\n" 273 "\nNOTE: By default this function only works sometimes. " 274 "This is when there is an\n" 275 "unspent output in the utxo for this transaction. To make it always " 277 "you need to maintain a transaction index, using the -txindex command " 279 "specify the block in which the transaction is included manually (by " 286 "The txids to filter",
289 "A transaction hash"},
294 "If specified, looks for txid in the block with this hash"},
298 "A string that is a serialized, hex-encoded data for the proof."},
303 std::set<TxId> setTxIds;
306 for (
unsigned int idx = 0; idx < txids.
size(); idx++) {
309 if (setTxIds.count(txid)) {
312 std::string(
"Invalid parameter, duplicated txid: ") +
316 setTxIds.insert(txid);
334 for (
const auto &txid : setTxIds) {
347 g_txindex->BlockUntilSyncedToCurrentChain();
354 if (pblockindex ==
nullptr) {
359 "Transaction not yet in block");
373 unsigned int ntxFound = 0;
374 for (
const auto &tx : block.
vtx) {
375 if (setTxIds.count(tx->GetId())) {
380 if (ntxFound != setTxIds.size()) {
383 "Not all transactions found in specified or retrieved block");
397 "Verifies that a proof points to a transaction in a block, returning " 398 "the transaction it commits to\n" 399 "and throwing an RPC error if the block is not in our best chain\n",
402 "The hex-encoded proof generated by gettxoutproof"},
409 "The txid(s) which the proof commits to, or empty array " 410 "if the proof can not be validated."},
423 std::vector<uint256> vMatch;
424 std::vector<size_t> vIndex;
425 if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) !=
426 merkleBlock.header.hashMerkleRoot) {
435 "Block not found in chain");
439 if (pindex->
nTx == merkleBlock.txn.GetNumTransactions()) {
440 for (
const uint256 &hash : vMatch) {
451 "createrawtransaction",
452 "Create a transaction spending the given inputs and creating new " 454 "Outputs can be addresses or data.\n" 455 "Returns hex-encoded raw transaction.\n" 456 "Note that the transaction's inputs are not signed, and\n" 457 "it is not stored in the wallet or transmitted to the network.\n",
474 "The output number"},
476 "depends on the value of the 'locktime' argument",
477 "The sequence number"},
486 "The outputs (key-value pairs), where none of " 487 "the keys are duplicated.\n" 488 "That is, each address can only appear once and there can only " 489 "be one 'data' object.\n" 490 "For compatibility reasons, a dictionary, which holds the " 491 "key-value pairs directly, is also\n" 492 " accepted as second parameter.",
502 "A key-value pair. The key (string) is the " 503 "bitcoin address, the value (float or string) is " 516 "A key-value pair. The key must be \"data\", the " 517 "value is hex-encoded data"},
523 "Raw locktime. Non-0 value also locktime-activates inputs"},
526 "hex string of the transaction"},
529 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]" 530 "\" \"[{\\\"address\\\":0.01}]\"") +
532 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]" 533 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
535 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]" 536 "\", \"[{\\\"address\\\":0.01}]\"") +
538 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]" 539 "\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
559 "decoderawtransaction",
560 "Return a JSON object representing the serialized, hex-encoded " 564 "The transaction hex string"},
585 "The transaction id"},
595 "The script sequence number"},
616 "The required sigs"},
618 "The type, eg 'pubkeyhash'"},
664 "Decode a hex-encoded script.\n",
667 "the hex-encoded script"},
685 "address of P2SH script wrapping this redeem script (not " 686 "returned if the script is already a P2SH)"},
698 std::vector<uint8_t> scriptData(
700 script =
CScript(scriptData.begin(), scriptData.end());
722 "combinerawtransaction",
723 "Combine multiple partially signed transactions into one " 725 "The combined transaction may be another partially signed transaction " 727 "fully signed transaction.",
733 "The hex strings of partially signed " 742 "The hex-encoded raw transaction with signature(s)"},
744 "[\"myhex1\", \"myhex2\", \"myhex3\"]")},
749 std::vector<CMutableTransaction> txVariants(txs.
size());
751 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
752 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
754 strprintf(
"TX decode failed for tx %d", idx));
758 if (txVariants.empty()) {
778 for (
const CTxIn &txin : mergedTx.
vin) {
791 for (
size_t i = 0; i < mergedTx.
vin.size(); i++) {
796 "Input not found or already spent");
804 if (txv.vin.size() > i) {
822 "signrawtransactionwithkey",
823 "Sign inputs for raw transaction (serialized, hex-encoded).\n" 824 "The second argument is an array of base58-encoded private\n" 825 "keys that will be the only keys used to sign the transaction.\n" 826 "The third optional argument (may be null) is an array of previous " 827 "transaction outputs that\n" 828 "this transaction depends on but may not yet be in the block chain.\n",
831 "The transaction hex string"},
836 "The base58-encoded private keys for signing",
839 "private key in base58-encoding"},
846 "The previous dependent transaction outputs",
857 "The output number"},
862 "(required for P2SH) redeem script"},
870 "The signature hash type. Must be one of:\n" 873 " \"SINGLE|FORKID\"\n" 874 " \"ALL|FORKID|ANYONECANPAY\"\n" 875 " \"NONE|FORKID|ANYONECANPAY\"\n" 876 " \"SINGLE|FORKID|ANYONECANPAY\""},
884 "The hex-encoded raw transaction with signature(s)"},
886 "If the transaction has a complete set of signatures"},
889 "Script verification errors (if there are any)",
896 "The hash of the referenced, previous transaction"},
898 "The index of the output to spent and used as " 901 "The hex-encoded signature script"},
903 "Script sequence number"},
905 "Verification or signing error related to the " 912 "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") +
914 "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")},
920 {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR},
true);
929 for (
size_t idx = 0; idx < keys.
size(); ++idx) {
934 "Invalid private key");
940 std::map<COutPoint, Coin> coins;
959 "sendrawtransaction",
960 "Submits raw transaction (serialized, hex-encoded) to local node and " 962 "\nAlso see createrawtransaction and " 963 "signrawtransactionwithkey calls.\n",
966 "The hex string of the raw transaction"},
970 "Reject transactions whose fee rate is higher than the specified " 971 "value, expressed in " +
976 "\nCreate a transaction\n" +
978 "createrawtransaction",
979 "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " 980 "\"{\\\"myaddress\\\":0.01}\"") +
981 "Sign the transaction, and get back the hex\n" +
983 "\nSend the transaction (signed hex)\n" +
985 "\nAs a JSON-RPC call\n" +
1005 const CFeeRate max_raw_tx_fee_rate =
1011 Amount max_raw_tx_fee = max_raw_tx_fee_rate.
GetFee(virtual_size);
1013 std::string err_string;
1017 node, config, tx, err_string, max_raw_tx_fee,
true,
1023 return tx->GetHash().GetHex();
1029 "testmempoolaccept",
1030 "Returns result of mempool acceptance tests indicating if raw" 1031 " transaction (serialized, hex-encoded) would be accepted" 1033 "\nThis checks if the transaction violates the consensus or policy " 1035 "\nSee sendrawtransaction call.\n",
1041 "An array of hex strings of raw transactions.\n" 1042 " Length must be one for now.",
1051 "Reject transactions whose fee rate is higher than the specified " 1052 "value, expressed in " +
1057 "The result of the mempool acceptance test for each raw " 1058 "transaction in the input array.\n" 1059 "Length is exactly one for now.",
1066 "The transaction hash in hex"},
1068 "If the mempool allows this tx to be inserted"},
1070 "Rejection string (only present when 'allowed' is " 1075 "\nCreate a transaction\n" +
1077 "createrawtransaction",
1078 "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" " 1079 "\"{\\\"myaddress\\\":0.01}\"") +
1080 "Sign the transaction, and get back the hex\n" +
1082 "\nTest acceptance of the transaction (signed hex)\n" +
1084 "\nAs a JSON-RPC call\n" +
1099 "Array must contain exactly one raw transaction for now");
1107 const TxId &txid = tx->GetId();
1109 const CFeeRate max_raw_tx_fee_rate =
1116 Amount max_raw_tx_fee = max_raw_tx_fee_rate.
GetFee(virtual_size);
1123 bool test_accept_res;
1127 config, mempool, state, std::move(tx),
false ,
1128 max_raw_tx_fee,
true );
1130 result_0.
pushKV(
"allowed", test_accept_res);
1131 if (!test_accept_res) {
1134 result_0.
pushKV(
"reject-reason",
"missing-inputs");
1136 result_0.
pushKV(
"reject-reason",
1149 std::string keypath_str =
"m";
1150 for (uint32_t num : keypath) {
1152 bool hardened =
false;
1153 if (num & 0x80000000) {
1170 "Return a JSON object representing the serialized, base64-encoded " 1171 "partially signed Bitcoin transaction.\n",
1174 "The PSBT base64 string"},
1183 "The decoded network-serialized unsigned transaction.",
1186 "The layout is the same as the output of " 1187 "decoderawtransaction."},
1191 "The unknown global fields",
1194 "(key-value pair) An unknown key-value pair"},
1207 "Transaction output for UTXOs",
1219 "The type, eg 'pubkeyhash'"},
1221 " Bitcoin address if there is one"},
1225 "partial_signatures",
1230 "The public key and signature that corresponds " 1234 "The sighash type to be used"},
1243 "The type, eg 'pubkeyhash'"},
1253 "The public key with the derivation path as " 1257 "The fingerprint of the master key"},
1271 "The unknown global fields",
1274 "(key-value pair) An unknown key-value pair"},
1294 "The type, eg 'pubkeyhash'"},
1306 "The public key this path corresponds to"},
1308 "The fingerprint of the master key"},
1314 "The unknown global fields",
1317 "(key-value pair) An unknown key-value pair"},
1322 "The transaction fee paid if all UTXOs slots in the PSBT have " 1336 strprintf(
"TX decode failed %s", error));
1344 result.
pushKV(
"tx", tx_univ);
1347 if (psbtx.
unknown.size() > 0) {
1349 for (
auto entry : psbtx.
unknown) {
1352 result.
pushKV(
"unknown", unknowns);
1357 bool have_all_utxos =
true;
1359 for (
size_t i = 0; i < psbtx.
inputs.size(); ++i) {
1371 total_in += txout.
nValue;
1374 have_all_utxos =
false;
1379 out.
pushKV(
"scriptPubKey", o);
1382 have_all_utxos =
false;
1392 in.
pushKV(
"partial_signatures", partial_sigs);
1397 if (sighashbyte > 0) {
1405 in.
pushKV(
"redeem_script", r);
1416 "master_fingerprint",
1421 in.
pushKV(
"bip32_derivs", keypaths);
1430 in.
pushKV(
"final_scriptSig", scriptsig);
1434 if (input.
unknown.size() > 0) {
1436 for (
auto entry : input.
unknown) {
1439 in.
pushKV(
"unknown", unknowns);
1444 result.
pushKV(
"inputs", inputs);
1449 for (
size_t i = 0; i < psbtx.
outputs.size(); ++i) {
1456 out.
pushKV(
"redeem_script", r);
1466 "master_fingerprint",
1471 out.
pushKV(
"bip32_derivs", keypaths);
1475 if (output.
unknown.size() > 0) {
1477 for (
auto entry : output.
unknown) {
1480 out.
pushKV(
"unknown", unknowns);
1488 output_value += psbtx.
tx->vout[i].nValue;
1491 have_all_utxos =
false;
1494 result.
pushKV(
"outputs", outputs);
1495 if (have_all_utxos) {
1506 "Combine multiple partially signed Bitcoin transactions into one " 1508 "Implements the Combiner role.\n",
1514 "The base64 strings of partially signed transactions",
1517 "A base64 string of a PSBT"},
1522 "The base64-encoded partially signed transaction"},
1524 "combinepsbt",
"[\"mybase64_1\", \"mybase64_2\", \"mybase64_3\"]")},
1531 std::vector<PartiallySignedTransaction> psbtxs;
1535 "Parameter 'txs' cannot be empty");
1537 for (
size_t i = 0; i < txs.
size(); ++i) {
1542 strprintf(
"TX decode failed %s", error));
1544 psbtxs.push_back(psbtx);
1554 ssTx << merged_psbt;
1562 "Finalize the inputs of a PSBT. If the transaction is fully signed, it " 1564 "network serialized transaction which can be broadcast with " 1565 "sendrawtransaction. Otherwise a PSBT will be\n" 1566 "created which has the final_scriptSigfields filled for inputs that " 1568 "Implements the Finalizer and Extractor roles.\n",
1571 "A base64 string of a PSBT"},
1573 "If true and the transaction is complete,\n" 1574 " extract and return the complete " 1575 "transaction in normal network serialization instead of the " 1583 "The base64-encoded partially signed transaction if not " 1586 "The hex-encoded network transaction if extracted"},
1588 "If the transaction has a complete set of signatures"},
1601 strprintf(
"TX decode failed %s", error));
1612 std::string result_str;
1614 if (complete && extract) {
1617 result.
pushKV(
"hex", result_str);
1621 result.
pushKV(
"psbt", result_str);
1623 result.
pushKV(
"complete", complete);
1632 "Creates a transaction in the Partially Signed Transaction format.\n" 1633 "Implements the Creator role.\n",
1650 "The output number"},
1652 "depends on the value of the 'locktime' argument",
1653 "The sequence number"},
1662 "The outputs (key-value pairs), where none of " 1663 "the keys are duplicated.\n" 1664 "That is, each address can only appear once and there can only " 1665 "be one 'data' object.\n" 1666 "For compatibility reasons, a dictionary, which holds the " 1667 "key-value pairs directly, is also\n" 1668 " accepted as second parameter.",
1678 "A key-value pair. The key (string) is the " 1679 "bitcoin address, the value (float or string) is " 1692 "A key-value pair. The key must be \"data\", the " 1693 "value is hex-encoded data"},
1699 "Raw locktime. Non-0 value also locktime-activates inputs"},
1702 "The resulting raw transaction (base64-encoded string)"},
1704 "createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]" 1705 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
1724 for (
size_t i = 0; i < rawTx.
vin.size(); ++i) {
1727 for (
size_t i = 0; i < rawTx.
vout.size(); ++i) {
1742 "Converts a network serialized transaction to a PSBT. " 1743 "This should be used only with createrawtransaction and " 1744 "fundrawtransaction\n" 1745 "createpsbt and walletcreatefundedpsbt should be used for new " 1749 "The hex string of a raw transaction"},
1751 "If true, any signatures in the input will be discarded and " 1753 " will continue. If false, RPC will " 1754 "fail if any signatures are present."},
1757 "The resulting raw transaction (base64-encoded string)"},
1759 "\nCreate a transaction\n" +
1761 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]" 1762 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1763 "\nConvert the transaction to a PSBT\n" +
1772 bool permitsigdata =
1782 "Inputs must not have scriptSigs");
1790 for (
size_t i = 0; i < tx.
vin.size(); ++i) {
1793 for (
size_t i = 0; i < tx.
vout.size(); ++i) {
1807 "Updates all inputs and outputs in a PSBT with data from output " 1808 "descriptors, the UTXO set or the mempool.\n",
1811 "A base64 string of a PSBT"},
1815 "An array of either strings or objects",
1818 "An output descriptor"},
1822 "An object with an output descriptor and extra information",
1825 "An output descriptor"},
1827 "Up to what index HD chains should be explored (either " 1828 "end or [begin,end])"},
1833 "The base64-encoded partially signed transaction with inputs " 1845 strprintf(
"TX decode failed %s", error));
1852 for (
size_t i = 0; i < descs.size(); ++i) {
1872 for (
const CTxIn &txin : psbtx.
tx->vin) {
1882 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
1897 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1909 "Joins multiple distinct PSBTs with different inputs and outputs " 1910 "into one PSBT with inputs and outputs from all of the PSBTs\n" 1911 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1915 "The base64 strings of partially signed transactions",
1917 "A base64 string of a PSBT"}}}},
1919 "The base64-encoded partially signed transaction"},
1926 std::vector<PartiallySignedTransaction> psbtxs;
1929 if (txs.
size() <= 1) {
1931 "At least two PSBTs are required to join PSBTs.");
1934 int32_t best_version = 1;
1935 uint32_t best_locktime = 0xffffffff;
1936 for (
size_t i = 0; i < txs.
size(); ++i) {
1941 strprintf(
"TX decode failed %s", error));
1943 psbtxs.push_back(psbtx);
1945 if (psbtx.
tx->nVersion > best_version) {
1946 best_version = psbtx.
tx->nVersion;
1949 if (psbtx.
tx->nLockTime < best_locktime) {
1950 best_locktime = psbtx.
tx->nLockTime;
1957 merged_psbt.
tx->nVersion = best_version;
1958 merged_psbt.
tx->nLockTime = best_locktime;
1961 for (
auto &psbt : psbtxs) {
1962 for (
size_t i = 0; i < psbt.tx->vin.size(); ++i) {
1963 if (!merged_psbt.
AddInput(psbt.tx->vin[i], psbt.inputs[i])) {
1967 "Input %s:%d exists in multiple PSBTs",
1968 psbt.tx->vin[i].prevout.GetTxId().ToString().c_str(),
1969 psbt.tx->vin[i].prevout.GetN()));
1972 for (
size_t i = 0; i < psbt.tx->vout.size(); ++i) {
1973 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1975 merged_psbt.
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
1980 std::vector<int> input_indices(merged_psbt.
inputs.size());
1981 std::iota(input_indices.begin(), input_indices.end(), 0);
1982 std::vector<int> output_indices(merged_psbt.
outputs.size());
1983 std::iota(output_indices.begin(), output_indices.end(), 0);
1991 shuffled_psbt.tx->nVersion = merged_psbt.
tx->nVersion;
1992 shuffled_psbt.tx->nLockTime = merged_psbt.
tx->nLockTime;
1993 for (
int i : input_indices) {
1994 shuffled_psbt.AddInput(merged_psbt.
tx->vin[i], merged_psbt.
inputs[i]);
1996 for (
int i : output_indices) {
1997 shuffled_psbt.AddOutput(merged_psbt.
tx->vout[i],
2000 shuffled_psbt.unknown.insert(merged_psbt.
unknown.begin(),
2004 ssTx << shuffled_psbt;
2011 "Analyzes and provides information about the current status of a " 2012 "PSBT and its inputs\n",
2014 "A base64 string of a PSBT"}},
2029 "Whether a UTXO is provided"},
2031 "Whether the input is finalized"},
2035 "Things that are missing that are required to " 2036 "complete this input",
2044 "Public key ID, hash160 of the public " 2045 "key, of a public key whose BIP 32 " 2046 "derivation path is missing"},
2054 "Public key ID, hash160 of the public " 2055 "key, of a public key whose signature is " 2060 "Hash160 of the redeemScript that is missing"},
2063 "Role of the next person that this input needs to " 2068 "Estimated vsize of the final signed transaction"},
2071 "Estimated feerate of the final signed transaction in " +
2073 "/kB. Shown only if all UTXO slots in the PSBT have been " 2076 "The transaction fee paid. Shown only if all UTXO slots in " 2077 "the PSBT have been filled"},
2079 "Role of the next person that this psbt needs to go to"},
2081 "Error message if there is one"},
2093 strprintf(
"TX decode failed %s", error));
2100 for (
const auto &input : psbta.
inputs) {
2104 input_univ.
pushKV(
"has_utxo", input.has_utxo);
2105 input_univ.
pushKV(
"is_final", input.is_final);
2108 if (!input.missing_pubkeys.empty()) {
2110 for (
const CKeyID &pubkey : input.missing_pubkeys) {
2113 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
2115 if (!input.missing_redeem_script.IsNull()) {
2116 missing.
pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
2118 if (!input.missing_sigs.empty()) {
2120 for (
const CKeyID &pubkey : input.missing_sigs) {
2123 missing.
pushKV(
"signatures", missing_sigs_univ);
2125 if (!missing.
getKeys().empty()) {
2126 input_univ.
pushKV(
"missing", missing);
2130 if (!inputs_result.
empty()) {
2131 result.
pushKV(
"inputs", inputs_result);
2137 result.
pushKV(
"estimated_feerate",
2140 if (psbta.
fee != std::nullopt) {
2144 if (!psbta.
error.empty()) {
2156 {
"rawtransactions",
"getrawtransaction",
getrawtransaction, {
"txid",
"verbose",
"blockhash"} },
2157 {
"rawtransactions",
"createrawtransaction",
createrawtransaction, {
"inputs",
"outputs",
"locktime"} },
2159 {
"rawtransactions",
"decodescript",
decodescript, {
"hexstring"} },
2160 {
"rawtransactions",
"sendrawtransaction",
sendrawtransaction, {
"hexstring",
"maxfeerate"} },
2162 {
"rawtransactions",
"signrawtransactionwithkey",
signrawtransactionwithkey, {
"hexstring",
"privkeys",
"prevtxs",
"sighashtype"} },
2163 {
"rawtransactions",
"testmempoolaccept",
testmempoolaccept, {
"rawtxs",
"maxfeerate"} },
2164 {
"rawtransactions",
"decodepsbt",
decodepsbt, {
"psbt"} },
2165 {
"rawtransactions",
"combinepsbt",
combinepsbt, {
"txs"} },
2166 {
"rawtransactions",
"finalizepsbt",
finalizepsbt, {
"psbt",
"extract"} },
2167 {
"rawtransactions",
"createpsbt",
createpsbt, {
"inputs",
"outputs",
"locktime"} },
2168 {
"rawtransactions",
"converttopsbt",
converttopsbt, {
"hexstring",
"permitsigdata"} },
2169 {
"rawtransactions",
"utxoupdatepsbt",
utxoupdatepsbt, {
"psbt",
"descriptors"} },
2170 {
"rawtransactions",
"joinpsbts",
joinpsbts, {
"txs"} },
2171 {
"rawtransactions",
"analyzepsbt",
analyzepsbt, {
"psbt"} },
2172 {
"blockchain",
"gettxoutproof",
gettxoutproof, {
"txids",
"blockhash"} },
2177 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++) {
std::shared_ptr< const CTransaction > CTransactionRef
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 ...
static UniValue decoderawtransaction(const Config &config, const JSONRPCRequest &request)
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
static UniValue signrawtransactionwithkey(const Config &config, const JSONRPCRequest &request)
const util::Ref & context
NODISCARD bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
const std::string CURRENCY_UNIT
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.
std::array< uint8_t, 64 > sig
static constexpr Amount zero()
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params ¶ms)
Functions for disk access for blocks.
Bitcoin RPC command dispatcher.
int64_t GetBlockTime() const
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or a pruned one if not found.
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.
static Amount AmountFromValue(const UniValue &value)
void SetBackend(CCoinsView &viewIn)
UniValue utxoupdatepsbt(const Config &config, const JSONRPCRequest &request)
uint32_t getRawSigHashType() const
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
static UniValue getrawtransaction(const Config &config, const JSONRPCRequest &request)
std::vector< PSBTInputAnalysis > inputs
More information about the individual inputs of the transaction.
BlockStatus nStatus
Verification status of this block. See enum BlockStatus.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
transaction was missing some of its inputs
std::string SighashToStr(uint8_t sighash_type)
#define ARRAYLEN(array)
Utilities for converting data from/to strings.
static CTransactionRef MakeTransactionRef()
PSBTRole next
Which of the BIP 174 roles needs to handle the transaction next.
std::string EncodeBase64(const uint8_t *pch, size_t len)
static UniValue createrawtransaction(const Config &config, const JSONRPCRequest &request)
std::optional< CFeeRate > estimated_feerate
Estimated feerate (fee / weight) of the transaction.
Holds the results of AnalyzePSBT (miscellaneous information about a PSBT)
const std::string & get_str() const
static std::string WriteHDKeypath(std::vector< uint32_t > &keypath)
const UniValue & get_array() const
const CBlock & GenesisBlock() const
std::vector< CTxOut > vout
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
CTxMemPool & EnsureMemPool(const util::Ref &context)
A signature creator for transactions.
std::vector< uint8_t > ParseHexV(const UniValue &v, std::string strName)
const std::vector< std::string > & getKeys() const
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
static UniValue decodescript(const Config &config, const JSONRPCRequest &request)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
std::optional< size_t > estimated_vsize
Estimated weight of the transaction.
virtual const CChainParams & GetChainParams() const =0
Invalid, missing or duplicate parameter.
static UniValue sendrawtransaction(const Config &config, const JSONRPCRequest &request)
const UniValue & find_value(const UniValue &obj, const std::string &name)
CChainState & ChainstateActive()
CMutableTransaction ConstructTransaction(const CChainParams ¶ms, const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime)
Create a transaction from univalue parameters.
A structure for PSBTs which contains per output information.
General error during transaction or block submission.
bool MoneyRange(const Amount nValue)
std::vector< PSBTOutput > outputs
std::map< CPubKey, KeyOriginInfo > hd_keypaths
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Special type that is a STR with only hex chars.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
bool GetTransaction(const TxId &txid, CTransactionRef &txOut, const Consensus::Params ¶ms, BlockHash &hashBlock, const CBlockIndex *const block_index)
Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock...
Used to create a Merkle proof (usually from a subset of transactions), which consists of a block head...
static UniValue testmempoolaccept(const Config &config, const JSONRPCRequest &request)
UniValue JSONRPCError(int code, const std::string &message)
Amount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
bool push_back(const UniValue &val)
Special string with only hex chars.
NodeContext struct containing references to chain state and connection state.
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Abstract view on the open txout dataset.
An input of a transaction.
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE
Maximum fee rate for sendrawtransaction and testmempoolaccept RPC calls.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
static UniValue verifytxoutproof(const Config &config, const JSONRPCRequest &request)
const SigningProvider & DUMMY_SIGNING_PROVIDER
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
Fillable signing provider that keeps keys in an address->secret map.
static std::string GetAllOutputTypes()
RecursiveMutex cs_main
Global state.
const char * GetTxnOutputType(txnouttype t)
Get the name of a txnouttype as a C string, or nullptr if unknown.
General application defined errors std::exception thrown in command handling.
bool pushKV(const std::string &key, const UniValue &val)
An output of a transaction.
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
void MergeSignatureData(SignatureData sigdata)
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. ...
Parameters that influence chain consensus.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
std::vector< PSBTInput > inputs
Special numeric to denote unix epoch time.
void RegisterRawTransactionRPCCommands(CRPCTable &t)
Register raw transaction RPC commands.
Optional arg that is a named argument and has a default value of null.
static uint32_t ReadBE32(const uint8_t *ptr)
UniValue joinpsbts(const Config &config, const JSONRPCRequest &request)
static UniValue finalizepsbt(const Config &config, const JSONRPCRequest &request)
NodeContext & EnsureNodeContext(const util::Ref &context)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
Special type that is a NUM or [NUM,NUM].
#define extract(n)
Extract the lowest 64 bits of (c0,c1,c2) into n, and left shift the number 64 bits.
Optional argument with default value omitted because they are implicitly clear.
void Shuffle(I first, I last, R &&rng)
More efficient than using std::shuffle on a FastRandomContext.
std::vector< CTransactionRef > vtx
static UniValue combinerawtransaction(const Config &config, const JSONRPCRequest &request)
const_iterator end() const
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
static void TxToJSON(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry)
const_iterator begin() const
static UniValue converttopsbt(const Config &config, const JSONRPCRequest &request)
A BlockHash is a unqiue identifier for a block.
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...
Serialized script, used inside transaction inputs and outputs.
int RPCSerializationFlags()
Retrieves any serialization flags requested in command line argument.
A TxId is the identifier of a transaction.
uint32_t GetHeight() const
static const int PROTOCOL_VERSION
network protocol versioning
UniValue analyzepsbt(const Config &config, const JSONRPCRequest &request)
A mutable version of CTransaction.
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)
CBlockIndex * LookupBlockIndex(const BlockHash &hash)
std::string GetHex() const
std::string HexStr(const T itbegin, const T itend)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Fee rate in satoshis per kilobyte: Amount / kB.
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
#define AssertLockNotHeld(cs)
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::string error
Error message.
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
const Coin & AccessByTxid(const CCoinsViewCache &view, const TxId &txid)
Utility function to find any unspent output with a given txid.
static UniValue gettxoutproof(const Config &config, const JSONRPCRequest &request)
An encapsulated secp256k1 private key.
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
const Consensus::Params & GetConsensus() const
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
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
static UniValue decodepsbt(const Config &config, const JSONRPCRequest &request)
std::string GetRejectReason() const
std::string PSBTRoleName(const PSBTRole role)
static UniValue combinepsbt(const Config &config, const JSONRPCRequest &request)
TransactionError BroadcastTransaction(NodeContext &node, const Config &config, 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.
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigOpCount, unsigned int bytes_per_sigop)
Compute the virtual transaction size (size, or more if sigops are too dense).
static UniValue createpsbt(const Config &config, const JSONRPCRequest &request)
CCoinsView that brings transactions from a mempool into view.
bool error(const char *fmt, const Args &... args)
bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, TxValidationState &state, const CTransactionRef &tx, bool bypass_limits, const Amount nAbsurdFee, bool test_accept)
(try to) add transaction to memory pool
std::optional< Amount > fee
Amount of fee being paid by the transaction.
unsigned int nTx
Number of transactions in this block.
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
virtual bool AddKey(const CKey &key)
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.
std::string FormatMoney(const Amount amt)
Money parsing/formatting utilities.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
Special type to denote elision (...)
bool IsValid() const
Check whether this private key is valid.
Signature hash type wrapper class.
UniValue ValueFromAmount(const Amount &amount)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
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...