65 entry.
pushKV(
"confirmations", 0);
74 "\nReturn the raw transaction data.\n" 76 "\nBy default this function only works for mempool transactions. When called with a blockhash\n" 77 "argument, getrawtransaction will return the transaction if the specified block is available and\n" 78 "the transaction is found in that block. When called without a blockhash argument, getrawtransaction\n" 79 "will return the transaction if it is in the mempool, or if -txindex is enabled and the transaction\n" 80 "is in a block in the blockchain.\n" 82 "\nHint: Use gettransaction for wallet transactions.\n" 84 "\nIf verbose is 'true', returns an Object with information about 'txid'.\n" 85 "If verbose is 'false' or omitted, returns a string that is serialized, hex-encoded data for 'txid'.\n",
88 {
"verbose",
RPCArg::Type::BOOL,
"false",
"If false, return a string, otherwise return a json object"},
92 RPCResult{
"if verbose is not set or set to false",
98 {
RPCResult::Type::BOOL,
"in_active_chain",
"Whether specified block is in the active chain or not (only present with explicit \"blockhash\" argument)"},
103 {
RPCResult::Type::NUM,
"vsize",
"The virtual transaction size (differs from size for witness transactions)"},
155 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" false \"myblockhash\"")
156 +
HelpExampleCli(
"getrawtransaction",
"\"mytxid\" true \"myblockhash\"")
162 bool in_active_chain =
true;
166 if (hash ==
Params().GenesisBlock().hashMerkleRoot) {
172 bool fVerbose =
false;
173 if (!request.params[1].isNull()) {
174 fVerbose = request.params[1].isNum() ? (request.params[1].get_int() != 0) : request.params[1].get_bool();
177 if (!request.params[2].isNull()) {
188 bool f_txindex_ready =
false;
190 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
201 errmsg =
"No such transaction found in the provided block";
203 errmsg =
"No such mempool transaction. Use -txindex or provide a block hash to enable blockchain transaction queries";
204 }
else if (!f_txindex_ready) {
205 errmsg =
"No such mempool transaction. Blockchain transactions are still in the process of being indexed";
207 errmsg =
"No such mempool or blockchain transaction";
217 if (blockindex) result.
pushKV(
"in_active_chain", in_active_chain);
227 "\nReturns a hex-encoded proof that \"txid\" was included in a block.\n" 228 "\nNOTE: By default this function only works sometimes. This is when there is an\n" 229 "unspent output in the utxo for this transaction. To make it always work,\n" 230 "you need to maintain a transaction index, using the -txindex command line option or\n" 231 "specify the block in which the transaction is included manually (by blockhash).\n",
246 std::set<uint256> setTxids;
251 for (
unsigned int idx = 0; idx < txids.
size(); idx++) {
252 auto ret = setTxids.insert(
ParseHashV(txids[idx],
"txid"));
260 if (!request.params[1].isNull()) {
262 hashBlock =
ParseHashV(request.params[1],
"blockhash");
271 for (
const auto& tx : setTxids) {
283 g_txindex->BlockUntilSyncedToCurrentChain();
288 if (pblockindex ==
nullptr) {
290 if (!tx || hashBlock.
IsNull()) {
304 unsigned int ntxFound = 0;
305 for (
const auto& tx : block.
vtx) {
306 if (setTxids.count(tx->GetHash())) {
310 if (ntxFound != setTxids.size()) {
317 std::string strHex =
HexStr(ssMB);
326 "\nVerifies that a proof points to a transaction in a block, returning the transaction it commits to\n" 327 "and throwing an RPC error if the block is not in our best chain\n",
334 {
RPCResult::Type::STR_HEX,
"txid",
"The txid(s) which the proof commits to, or empty array if the proof can not be validated."},
346 std::vector<uint256> vMatch;
347 std::vector<unsigned int> vIndex;
348 if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) != merkleBlock.header.hashMerkleRoot)
359 if (pindex->
nTx == merkleBlock.txn.GetNumTransactions()) {
360 for (
const uint256& hash : vMatch) {
373 "\nCreate a transaction spending the given inputs and creating new outputs.\n" 374 "Outputs can be addresses or data.\n" 375 "Returns hex-encoded raw transaction.\n" 376 "Note that the transaction's inputs are not signed, and\n" 377 "it is not stored in the wallet or transmitted to the network.\n",
385 {
"sequence",
RPCArg::Type::NUM,
"depends on the value of the 'replaceable' and 'locktime' arguments",
"The sequence number"},
391 "That is, each address can only appear once and there can only be one 'data' object.\n" 392 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 393 " accepted as second parameter.",
407 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
408 {
"replaceable",
RPCArg::Type::BOOL,
"false",
"Marks this transaction as BIP125-replaceable.\n" 409 " Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
415 HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"address\\\":0.01}]\"")
416 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
417 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"address\\\":0.01}]\"")
418 +
HelpExampleRpc(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
431 if (!request.params[3].isNull()) {
432 rbf = request.params[3].isTrue();
444 "\nReturn a JSON object representing the serialized, hex-encoded transaction.\n",
447 {
"iswitness",
RPCArg::Type::BOOL,
"depends on heuristic tests",
"Whether the transaction hex is a serialized witness transaction.\n" 448 "If iswitness is not present, heuristic tests will be used in decoding.\n" 449 "If true, only witness deserialization will be tried.\n" 450 "If false, only non-witness deserialization will be tried.\n" 451 "This boolean should reflect whether the transaction has inputs\n" 452 "(e.g. fully valid, or on-chain transactions), if known by the caller." 461 {
RPCResult::Type::NUM,
"vsize",
"The virtual transaction size (differs from size for witness transactions)"},
510 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
514 bool try_witness = request.params[1].isNull() ? true : request.params[1].get_bool();
515 bool try_no_witness = request.params[1].isNull() ? true : !request.params[1].get_bool();
517 if (!
DecodeHexTx(mtx, request.params[0].get_str(), try_no_witness, try_witness)) {
531 std::vector<std::string> ret;
532 using U = std::underlying_type<TxoutType>::type;
536 return Join(ret,
", ");
542 "\nDecode a hex-encoded script.\n",
556 {
RPCResult::Type::STR,
"p2sh",
"address of P2SH script wrapping this redeem script (not returned if the script is already a P2SH)"},
557 {
RPCResult::Type::OBJ,
"segwit",
"Result of a witness script public key wrapping this redeem script (not returned if the script is a P2SH or witness)",
561 {
RPCResult::Type::STR,
"type",
"The type of the script public key (e.g. witness_v0_keyhash or witness_v0_scripthash)"},
567 {
RPCResult::Type::STR,
"p2sh-segwit",
"address of the P2SH script wrapping this witness redeem script"},
581 if (request.params[0].get_str().size() > 0){
582 std::vector<unsigned char> scriptData(
ParseHexV(request.params[0],
"argument"));
583 script =
CScript(scriptData.begin(), scriptData.end());
599 std::vector<std::vector<unsigned char>> solutions_data;
604 for (
const auto& solution : solutions_data) {
635 "\nCombine multiple partially signed transactions into one transaction.\n" 636 "The combined transaction may be another partially signed transaction or a \n" 637 "fully signed transaction.",
649 HelpExampleCli(
"combinerawtransaction", R
"('["myhex1", "myhex2", "myhex3"]')") 655 std::vector<CMutableTransaction> txVariants(txs.
size());
657 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
658 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
663 if (txVariants.empty()) {
682 for (
const CTxIn& txin : mergedTx.
vin) {
693 for (
unsigned int i = 0; i < mergedTx.
vin.size(); i++) {
703 if (txv.vin.size() > i) {
719 return RPCHelpMan{
"signrawtransactionwithkey",
720 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 721 "The second argument is an array of base58-encoded private\n" 722 "keys that will be the only keys used to sign the transaction.\n" 723 "The third optional argument (may be null) is an array of previous transaction outputs that\n" 724 "this transaction depends on but may not yet be in the block chain.\n",
746 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type. Must be one of:\n" 750 " \"ALL|ANYONECANPAY\"\n" 751 " \"NONE|ANYONECANPAY\"\n" 752 " \"SINGLE|ANYONECANPAY\"\n" 774 HelpExampleCli(
"signrawtransactionwithkey",
"\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"")
775 +
HelpExampleRpc(
"signrawtransactionwithkey",
"\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")
779 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VARR, UniValue::VSTR},
true);
782 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
788 for (
unsigned int idx = 0; idx < keys.
size(); ++idx) {
798 std::map<COutPoint, Coin> coins;
818 "\nSubmit a raw transaction (serialized, hex-encoded) to local node and network.\n" 819 "\nNote that the transaction will be sent unconditionally to all peers, so using this\n" 820 "for manual rebroadcast may degrade privacy by leaking the transaction's origin, as\n" 821 "nodes will normally not rebroadcast non-wallet transactions already in their mempool.\n" 822 "\nAlso see createrawtransaction and signrawtransactionwithkey calls.\n",
826 "Reject transactions whose fee rate is higher than the specified value, expressed in " +
CURRENCY_UNIT +
827 "/kB.\nSet to 0 to accept any fee rate.\n"},
833 "\nCreate a transaction\n" 834 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
835 "Sign the transaction, and get back the hex\n" 837 "\nSend the transaction (signed hex)\n" 839 "\nAs a JSON-RPC call\n" 850 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
855 const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
860 CAmount max_raw_tx_fee = max_raw_tx_fee_rate.
GetFee(virtual_size);
862 std::string err_string;
870 return tx->GetHash().GetHex();
878 "\nReturns result of mempool acceptance tests indicating if raw transaction (serialized, hex-encoded) would be accepted by mempool.\n" 879 "\nThis checks if the transaction violates the consensus or policy rules.\n" 880 "\nSee sendrawtransaction call.\n",
883 " Length must be one for now.",
891 RPCResult::Type::ARR,
"",
"The result of the mempool acceptance test for each raw transaction in the input array.\n" 892 "Length is exactly one for now.",
899 {
RPCResult::Type::NUM,
"vsize",
"Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)"},
904 {
RPCResult::Type::STR,
"reject-reason",
"Rejection string (only present when 'allowed' is false)"},
909 "\nCreate a transaction\n" 910 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
911 "Sign the transaction, and get back the hex\n" 913 "\nTest acceptance of the transaction (signed hex)\n" 915 "\nAs a JSON-RPC call\n" 925 if (request.params[0].get_array().size() != 1) {
930 if (!
DecodeHexTx(mtx, request.params[0].get_array()[0].get_str())) {
935 const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
941 CAmount max_raw_tx_fee = max_raw_tx_fee_rate.
GetFee(virtual_size);
945 result_0.
pushKV(
"txid", tx->GetHash().GetHex());
946 result_0.
pushKV(
"wtxid", tx->GetWitnessHash().GetHex());
949 bool test_accept_res;
954 nullptr ,
false ,
true, &fee);
958 if (test_accept_res && max_raw_tx_fee && fee > max_raw_tx_fee) {
959 result_0.
pushKV(
"allowed",
false);
960 result_0.
pushKV(
"reject-reason",
"max-fee-exceeded");
964 result_0.
pushKV(
"allowed", test_accept_res);
968 if (test_accept_res) {
969 result_0.
pushKV(
"vsize", virtual_size);
972 result_0.
pushKV(
"fees", fees);
976 result_0.
pushKV(
"reject-reason",
"missing-inputs");
994 "\nReturn a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.\n",
1013 {
RPCResult::Type::OBJ,
"non_witness_utxo",
true,
"Decoded network transaction for non-witness UTXOs",
1047 {
RPCResult::Type::OBJ,
"pubkey",
true,
"The public key with the derivation path as the value.",
1121 result.
pushKV(
"tx", tx_univ);
1125 for (
auto entry : psbtx.
unknown) {
1128 result.
pushKV(
"unknown", unknowns);
1132 bool have_all_utxos =
true;
1134 for (
unsigned int i = 0; i < psbtx.
inputs.size(); ++i) {
1138 bool have_a_utxo =
false;
1148 out.
pushKV(
"scriptPubKey", o);
1150 in.
pushKV(
"witness_utxo", out);
1159 in.
pushKV(
"non_witness_utxo", non_wit);
1165 total_in += txout.
nValue;
1168 have_all_utxos =
false;
1171 have_all_utxos =
false;
1180 in.
pushKV(
"partial_signatures", partial_sigs);
1192 in.
pushKV(
"redeem_script", r);
1197 in.
pushKV(
"witness_script", r);
1211 in.
pushKV(
"bip32_derivs", keypaths);
1219 in.
pushKV(
"final_scriptSig", scriptsig);
1226 in.
pushKV(
"final_scriptwitness", txinwitness);
1230 if (input.
unknown.size() > 0) {
1232 for (
auto entry : input.
unknown) {
1235 in.
pushKV(
"unknown", unknowns);
1240 result.
pushKV(
"inputs", inputs);
1245 for (
unsigned int i = 0; i < psbtx.
outputs.size(); ++i) {
1252 out.
pushKV(
"redeem_script", r);
1257 out.
pushKV(
"witness_script", r);
1270 out.
pushKV(
"bip32_derivs", keypaths);
1274 if (output.
unknown.size() > 0) {
1276 for (
auto entry : output.
unknown) {
1279 out.
pushKV(
"unknown", unknowns);
1286 output_value += psbtx.
tx->vout[i].nValue;
1289 have_all_utxos =
false;
1292 result.
pushKV(
"outputs", outputs);
1293 if (have_all_utxos) {
1305 "\nCombine multiple partially signed Bitcoin transactions into one transaction.\n" 1306 "Implements the Combiner role.\n",
1318 HelpExampleCli(
"combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')") 1325 std::vector<PartiallySignedTransaction> psbtxs;
1330 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1336 psbtxs.push_back(psbtx);
1346 ssTx << merged_psbt;
1355 "Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a\n" 1356 "network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be\n" 1357 "created which has the final_scriptSig and final_scriptWitness fields filled for inputs that are complete.\n" 1358 "Implements the Finalizer and Extractor roles.\n",
1362 " extract and return the complete transaction in normal network serialization instead of the PSBT."},
1367 {
RPCResult::Type::STR,
"psbt",
"The base64-encoded partially signed transaction if not extracted"},
1377 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL},
true);
1386 bool extract = request.params[1].isNull() || (!request.params[1].isNull() && request.params[1].get_bool());
1393 std::string result_str;
1395 if (complete && extract) {
1397 result_str =
HexStr(ssTx);
1398 result.
pushKV(
"hex", result_str);
1402 result.
pushKV(
"psbt", result_str);
1404 result.
pushKV(
"complete", complete);
1414 "\nCreates a transaction in the Partially Signed Transaction format.\n" 1415 "Implements the Creator role.\n",
1423 {
"sequence",
RPCArg::Type::NUM,
"depends on the value of the 'replaceable' and 'locktime' arguments",
"The sequence number"},
1429 "That is, each address can only appear once and there can only be one 'data' object.\n" 1430 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 1431 " accepted as second parameter.",
1445 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
1446 {
"replaceable",
RPCArg::Type::BOOL,
"false",
"Marks this transaction as BIP125 replaceable.\n" 1447 " Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible."},
1453 HelpExampleCli(
"createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
1467 if (!request.params[3].isNull()) {
1468 rbf = request.params[3].isTrue();
1475 for (
unsigned int i = 0; i < rawTx.
vin.size(); ++i) {
1478 for (
unsigned int i = 0; i < rawTx.
vout.size(); ++i) {
1494 "\nConverts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction\n" 1495 "createpsbt and walletcreatefundedpsbt should be used for new applications.\n",
1498 {
"permitsigdata",
RPCArg::Type::BOOL,
"false",
"If true, any signatures in the input will be discarded and conversion\n" 1499 " will continue. If false, RPC will fail if any signatures are present."},
1500 {
"iswitness",
RPCArg::Type::BOOL,
"depends on heuristic tests",
"Whether the transaction hex is a serialized witness transaction.\n" 1501 "If iswitness is not present, heuristic tests will be used in decoding.\n" 1502 "If true, only witness deserialization will be tried.\n" 1503 "If false, only non-witness deserialization will be tried.\n" 1504 "This boolean should reflect whether the transaction has inputs\n" 1505 "(e.g. fully valid, or on-chain transactions), if known by the caller." 1512 "\nCreate a transaction\n" 1513 +
HelpExampleCli(
"createrawtransaction",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1514 "\nConvert the transaction to a PSBT\n" 1519 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VBOOL},
true);
1523 bool permitsigdata = request.params[1].isNull() ? false : request.params[1].get_bool();
1524 bool witness_specified = !request.params[2].isNull();
1525 bool iswitness = witness_specified ? request.params[2].get_bool() :
false;
1526 const bool try_witness = witness_specified ? iswitness :
true;
1527 const bool try_no_witness = witness_specified ? !iswitness :
true;
1528 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
1544 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
1547 for (
unsigned int i = 0; i < tx.
vout.size(); ++i) {
1563 "\nUpdates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set or the mempool.\n",
1570 {
"range",
RPCArg::Type::RANGE,
"1000",
"Up to what index HD chains should be explored (either end or [begin,end])"},
1575 RPCResult::Type::STR,
"",
"The base64-encoded partially signed transaction with inputs updated" 1582 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR},
true);
1593 if (!request.params[1].isNull()) {
1594 auto descs = request.params[1].get_array();
1595 for (
size_t i = 0; i < descs.size(); ++i) {
1612 for (
const CTxIn& txin : psbtx.
tx->vin) {
1620 for (
unsigned int i = 0; i < psbtx.
tx->vin.size(); ++i) {
1640 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1654 "\nJoins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs\n" 1655 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1673 std::vector<PartiallySignedTransaction> psbtxs;
1676 if (txs.
size() <= 1) {
1680 uint32_t best_version = 1;
1681 uint32_t best_locktime = 0xffffffff;
1682 for (
unsigned int i = 0; i < txs.
size(); ++i) {
1688 psbtxs.push_back(psbtx);
1690 if (static_cast<uint32_t>(psbtx.
tx->nVersion) > best_version) {
1691 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1694 if (psbtx.
tx->nLockTime < best_locktime) {
1695 best_locktime = psbtx.
tx->nLockTime;
1702 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1703 merged_psbt.
tx->nLockTime = best_locktime;
1706 for (
auto& psbt : psbtxs) {
1707 for (
unsigned int i = 0; i < psbt.tx->vin.size(); ++i) {
1708 if (!merged_psbt.
AddInput(psbt.tx->vin[i], psbt.inputs[i])) {
1712 for (
unsigned int i = 0; i < psbt.tx->vout.size(); ++i) {
1713 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1715 merged_psbt.
unknown.insert(psbt.unknown.begin(), psbt.unknown.end());
1719 std::vector<int> input_indices(merged_psbt.
inputs.size());
1720 std::iota(input_indices.begin(), input_indices.end(), 0);
1721 std::vector<int> output_indices(merged_psbt.
outputs.size());
1722 std::iota(output_indices.begin(), output_indices.end(), 0);
1730 shuffled_psbt.tx->nVersion = merged_psbt.
tx->nVersion;
1731 shuffled_psbt.tx->nLockTime = merged_psbt.
tx->nLockTime;
1732 for (
int i : input_indices) {
1733 shuffled_psbt.AddInput(merged_psbt.
tx->vin[i], merged_psbt.
inputs[i]);
1735 for (
int i : output_indices) {
1736 shuffled_psbt.AddOutput(merged_psbt.
tx->vout[i], merged_psbt.
outputs[i]);
1738 shuffled_psbt.unknown.insert(merged_psbt.
unknown.begin(), merged_psbt.
unknown.end());
1741 ssTx << shuffled_psbt;
1750 "\nAnalyzes and provides information about the current status of a PSBT and its inputs\n",
1763 {
RPCResult::Type::OBJ,
"missing",
true,
"Things that are missing that are required to complete this input",
1767 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose BIP 32 derivation path is missing"},
1771 {
RPCResult::Type::STR_HEX,
"keyid",
"Public key ID, hash160 of the public key, of a public key whose signature is missing"},
1776 {
RPCResult::Type::STR,
"next",
true,
"Role of the next person that this input needs to go to"},
1779 {
RPCResult::Type::NUM,
"estimated_vsize",
true,
"Estimated vsize of the final signed transaction"},
1780 {
RPCResult::Type::STR_AMOUNT,
"estimated_feerate",
true,
"Estimated feerate of the final signed transaction in " +
CURRENCY_UNIT +
"/kB. Shown only if all UTXO slots in the PSBT have been filled"},
1781 {
RPCResult::Type::STR_AMOUNT,
"fee",
true,
"The transaction fee paid. Shown only if all UTXO slots in the PSBT have been filled"},
1804 for (
const auto& input : psbta.
inputs) {
1808 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1809 input_univ.
pushKV(
"is_final", input.is_final);
1812 if (!input.missing_pubkeys.empty()) {
1814 for (
const CKeyID& pubkey : input.missing_pubkeys) {
1817 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
1819 if (!input.missing_redeem_script.IsNull()) {
1820 missing.
pushKV(
"redeemscript",
HexStr(input.missing_redeem_script));
1822 if (!input.missing_witness_script.IsNull()) {
1823 missing.
pushKV(
"witnessscript",
HexStr(input.missing_witness_script));
1825 if (!input.missing_sigs.empty()) {
1827 for (
const CKeyID& pubkey : input.missing_sigs) {
1830 missing.
pushKV(
"signatures", missing_sigs_univ);
1832 if (!missing.
getKeys().empty()) {
1833 input_univ.
pushKV(
"missing", missing);
1837 if (!inputs_result.
empty()) result.
pushKV(
"inputs", inputs_result);
1849 if (!psbta.
error.empty()) {
1864 {
"rawtransactions",
"getrawtransaction", &
getrawtransaction, {
"txid",
"verbose",
"blockhash"} },
1865 {
"rawtransactions",
"createrawtransaction", &
createrawtransaction, {
"inputs",
"outputs",
"locktime",
"replaceable"} },
1866 {
"rawtransactions",
"decoderawtransaction", &
decoderawtransaction, {
"hexstring",
"iswitness"} },
1867 {
"rawtransactions",
"decodescript", &
decodescript, {
"hexstring"} },
1868 {
"rawtransactions",
"sendrawtransaction", &
sendrawtransaction, {
"hexstring",
"maxfeerate"} },
1870 {
"rawtransactions",
"signrawtransactionwithkey", &
signrawtransactionwithkey, {
"hexstring",
"privkeys",
"prevtxs",
"sighashtype"} },
1871 {
"rawtransactions",
"testmempoolaccept", &
testmempoolaccept, {
"rawtxs",
"maxfeerate"} },
1872 {
"rawtransactions",
"decodepsbt", &
decodepsbt, {
"psbt"} },
1873 {
"rawtransactions",
"combinepsbt", &
combinepsbt, {
"txs"} },
1874 {
"rawtransactions",
"finalizepsbt", &
finalizepsbt, {
"psbt",
"extract"} },
1875 {
"rawtransactions",
"createpsbt", &
createpsbt, {
"inputs",
"outputs",
"locktime",
"replaceable"} },
1876 {
"rawtransactions",
"converttopsbt", &
converttopsbt, {
"hexstring",
"permitsigdata",
"iswitness"} },
1877 {
"rawtransactions",
"utxoupdatepsbt", &
utxoupdatepsbt, {
"psbt",
"descriptors"} },
1878 {
"rawtransactions",
"joinpsbts", &
joinpsbts, {
"txs"} },
1879 {
"rawtransactions",
"analyzepsbt", &
analyzepsbt, {
"psbt"} },
1881 {
"blockchain",
"gettxoutproof", &
gettxoutproof, {
"txids",
"blockhash"} },
1885 for (
const auto& c : commands) {
std::shared_ptr< const CTransaction > CTransactionRef
const Coin & AccessByTxid(const CCoinsViewCache &view, const uint256 &txid)
Utility function to find any unspent output with a given txid.
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
static const int SERIALIZE_TRANSACTION_NO_WITNESS
A flag that is ORed into the protocol version to designate that a transaction should be (un)serialize...
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.
int64_t GetBlockTime() const
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty 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.
void SetBackend(CCoinsView &viewIn)
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
CChain & ChainActive()
Please prefer the identical ChainstateManager::ActiveChain.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
std::unique_ptr< CTxMemPool > mempool
static RPCHelpMan getrawtransaction()
Optional< CMutableTransaction > tx
void appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
bool ReadBlockFromDisk(CBlock &block, const FlatFilePos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
Optional< CFeeRate > estimated_feerate
Estimated feerate (fee / weight) of the transaction.
CScriptWitness scriptWitness
Only serialized through CTransaction.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
std::vector< PSBTInputAnalysis > inputs
More information about the individual inputs of the transaction.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
transaction was missing some of its inputs
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
static RPCHelpMan combinerawtransaction()
bool MoneyRange(const CAmount &nValue)
CTxOut out
unspent transaction output
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, int sighash, SignatureData *out_sigdata, bool use_dummy)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
UniValue ValueFromAmount(const CAmount &amount)
std::vector< std::vector< unsigned char > > stack
PSBTRole next
Which of the BIP 174 roles needs to handle the transaction next.
Holds the results of AnalyzePSBT (miscellaneous information about a PSBT)
const std::string & get_str() const
static auto & nullopt
Substitute for C++17 std::nullopt DEPRECATED use std::nullopt in new code.
const UniValue & get_array() const
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
CTxMemPool & EnsureMemPool(const util::Ref &context)
A signature creator for transactions.
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
const std::vector< std::string > & getKeys() const
static RPCHelpMan sendrawtransaction()
static RPCHelpMan decoderawtransaction()
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, bool rbf)
Create a transaction from univalue parameters.
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
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.
Invalid, missing or duplicate parameter.
const UniValue & find_value(const UniValue &obj, const std::string &name)
std::string PSBTRoleName(PSBTRole role)
int64_t CAmount
Amount in satoshis (Can be negative)
static RPCHelpMan createpsbt()
A structure for PSBTs which contains per output information.
static RPCHelpMan verifytxoutproof()
General error during transaction or block submission.
bool AcceptToMemoryPool(CTxMemPool &pool, TxValidationState &state, const CTransactionRef &tx, std::list< CTransactionRef > *plTxnReplaced, bool bypass_limits, bool test_accept, CAmount *fee_out)
(try to) add transaction to memory pool plTxnReplaced will be appended to with all transactions repla...
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
std::vector< PSBTOutput > outputs
Optional< CAmount > fee
Amount of fee being paid by the transaction.
std::map< CPubKey, KeyOriginInfo > hd_keypaths
Special type that is a STR with only hex chars.
std::string EncodeBase64(Span< const unsigned char > input)
static RPCHelpMan finalizepsbt()
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
UniValue JSONRPCError(int code, const std::string &message)
bool push_back(const UniValue &val)
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(MakeSpan(std::forward< V >(v))))
Like MakeSpan, but for (const) unsigned char member types only.
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.
static RPCHelpMan converttopsbt()
static RPCHelpMan combinepsbt()
static CAmount AmountFromValue(const UniValue &value)
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
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.
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.
Fillable signing provider that keeps keys in an address->secret map.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
static std::string GetAllOutputTypes()
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
static RPCHelpMan testmempoolaccept()
const std::string CURRENCY_UNIT
static uint32_t ReadBE32(const unsigned char *ptr)
Optional< size_t > estimated_vsize
Estimated weight of the transaction.
std::string SighashToStr(unsigned char sighash_type)
General application defined errors.
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)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::vector< CTxOut > vout
static RPCHelpMan utxoupdatepsbt()
std::vector< PSBTInput > inputs
Special numeric to denote unix epoch time.
void RegisterRawTransactionRPCCommands(CRPCTable &t)
Register raw transaction RPC commands.
static RPCHelpMan signrawtransactionwithkey()
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Optional arg that is a named argument and has a default value of null.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
NodeContext & EnsureNodeContext(const util::Ref &context)
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
Special type that is a NUM or [NUM,NUM].
CBlockIndex * LookupBlockIndex(const uint256 &hash)
#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.
TransactionError BroadcastTransaction(NodeContext &node, const CTransactionRef tx, std::string &err_string, const CAmount &max_tx_fee, bool relay, bool wait_callback)
Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
CChainState & ChainstateActive()
Please prefer the identical ChainstateManager::ActiveChainstate.
std::vector< CTransactionRef > vtx
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.
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 ...
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
static RPCHelpMan gettxoutproof()
Serialized script, used inside transaction inputs and outputs.
int RPCSerializationFlags()
static const int PROTOCOL_VERSION
network protocol versioning
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
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)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
std::string GetHex() const
Only for Witness versions not already defined above.
static void TxToJSON(const CTransaction &tx, const uint256 hashBlock, UniValue &entry)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Fee rate in satoshis per kilobyte: CAmount / 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)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::string EncodeDestination(const CTxDestination &dest)
A mutable version of CTransaction.
static RPCHelpMan decodepsbt()
std::string error
Error message.
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
An encapsulated 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
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
const Consensus::Params & GetConsensus() const
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::string GetRejectReason() const
full block available in blk*.dat
static RPCHelpMan analyzepsbt()
static RPCHelpMan createrawtransaction()
CCoinsView that brings transactions from a mempool into view.
bool error(const char *fmt, const Args &... args)
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const uint256 &hash, const Consensus::Params &consensusParams, uint256 &hashBlock)
Return transaction from the block at block_index.
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
unsigned int nTx
Number of transactions in this block.
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.
Special type to denote elision (...)
bool IsValid() const
Check whether this private key is valid.
static RPCHelpMan joinpsbts()
CAmount GetFee(size_t nBytes) const
Return the fee in satoshis for the given size in bytes.
bool IsCompressed() const
Check whether this is a compressed public key.
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...