7#include <chainparams.h>
73 entry.
pushKV(
"confirmations",
79 entry.
pushKV(
"confirmations", 0);
88 "Return the raw transaction data.\n"
89 "\nBy default, this call only returns a transaction if it is in the "
90 "mempool. If -txindex is enabled\n"
91 "and no blockhash argument is passed, it will return the transaction "
92 "if it is in the mempool or any block.\n"
93 "If a blockhash argument is passed, it will return the transaction if\n"
94 "the specified block is available and the transaction is in that "
96 "\nIf verbose is 'true', returns an Object with information about "
98 "If verbose is 'false' or omitted, returns a string that is "
99 "serialized, hex-encoded data for 'txid'.",
102 "The transaction id"},
106 "If false, return a string, otherwise return a json object",
109 "The block in which to look for the transaction"},
112 RPCResult{
"if verbose is not set or set to false",
114 "The serialized, hex-encoded data for 'txid'"},
116 "if verbose is set to true",
120 Cat<std::vector<RPCResult>>(
123 "Whether specified block is in the active chain or "
125 "(only present with explicit \"blockhash\" argument)"},
129 "The confirmations"},
134 "The serialized, hex-encoded data for 'txid'"},
145 "\"mytxid\" false \"myblockhash\"") +
147 "\"mytxid\" true \"myblockhash\"")},
153 bool in_active_chain =
true;
162 "The genesis block coinbase is not considered an "
163 "ordinary transaction and cannot be retrieved");
168 bool fVerbose =
false;
169 if (!request.params[1].isNull()) {
170 fVerbose = request.params[1].isNum()
171 ? (request.params[1].getInt<
int>() != 0)
172 : request.params[1].get_bool();
175 if (!request.params[2].isNull()) {
179 ParseHashV(request.params[2],
"parameter 3"));
183 "Block hash not found");
188 bool f_txindex_ready =
false;
190 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
201 return !blockindex->nStatus.hasData())) {
203 "Block not available");
205 errmsg =
"No such transaction found in the provided block";
208 "No such mempool transaction. Use -txindex or provide "
209 "a block hash to enable blockchain transaction queries";
210 }
else if (!f_txindex_ready) {
211 errmsg =
"No such mempool transaction. Blockchain "
212 "transactions are still in the process of being "
215 errmsg =
"No such mempool or blockchain transaction";
219 errmsg +
". Use gettransaction for wallet transactions.");
228 result.
pushKV(
"in_active_chain", in_active_chain);
238 "createrawtransaction",
239 "Create a transaction spending the given inputs and creating new "
241 "Outputs can be addresses or data.\n"
242 "Returns hex-encoded raw transaction.\n"
243 "Note that the transaction's inputs are not signed, and\n"
244 "it is not stored in the wallet or transmitted to the network.\n",
261 "The output number"},
264 "'locktime' argument"},
265 "The sequence number"},
273 "The outputs (key-value pairs), where none of "
274 "the keys are duplicated.\n"
275 "That is, each address can only appear once and there can only "
276 "be one 'data' object.\n"
277 "For compatibility reasons, a dictionary, which holds the "
278 "key-value pairs directly, is also\n"
279 " accepted as second parameter.",
288 "A key-value pair. The key (string) is the "
289 "bitcoin address, the value (float or string) is "
301 "A key-value pair. The key must be \"data\", the "
302 "value is hex-encoded data"},
308 "Raw locktime. Non-0 value also locktime-activates inputs"},
311 "hex string of the transaction"},
314 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
315 "\" \"[{\\\"address\\\":10000.00}]\"") +
317 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
318 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
320 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
321 "\", \"[{\\\"address\\\":10000.00}]\"") +
323 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
324 "\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
329 request.params[1], request.params[2]);
338 "decoderawtransaction",
339 "Return a JSON object representing the serialized, hex-encoded "
343 "The transaction hex string"},
358 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
374 "Decode a hex-encoded script.\n",
377 "the hex-encoded script"},
395 "address of P2SH script wrapping this redeem script (not "
396 "returned if the script is already a P2SH)"},
404 if (request.params[0].get_str().size() > 0) {
405 std::vector<uint8_t> scriptData(
406 ParseHexV(request.params[0],
"argument"));
407 script = CScript(scriptData.begin(), scriptData.end());
430 "combinerawtransaction",
431 "Combine multiple partially signed transactions into one "
433 "The combined transaction may be another partially signed transaction "
435 "fully signed transaction.",
441 "The hex strings of partially signed "
446 "A hex-encoded raw transaction"},
451 "The hex-encoded raw transaction with signature(s)"},
453 R
"('["myhex1", "myhex2", "myhex3"]')")},
457 std::vector<CMutableTransaction> txVariants(txs.
size());
459 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
460 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
463 strprintf(
"TX decode failed for tx %d", idx));
467 if (txVariants.empty()) {
469 "Missing transactions");
490 for (
const CTxIn &txin : mergedTx.
vin) {
501 const CTransaction txConst(mergedTx);
503 for (
size_t i = 0; i < mergedTx.
vin.size(); i++) {
504 CTxIn &txin = mergedTx.
vin[i];
508 "Input not found or already spent");
516 if (txv.vin.size() > i) {
523 &mergedTx, i, txout.
nValue),
536 "signrawtransactionwithkey",
537 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
538 "The second argument is an array of base58-encoded private\n"
539 "keys that will be the only keys used to sign the transaction.\n"
540 "The third optional argument (may be null) is an array of previous "
541 "transaction outputs that\n"
542 "this transaction depends on but may not yet be in the block chain.\n",
545 "The transaction hex string"},
550 "The base58-encoded private keys for signing",
553 "private key in base58-encoding"},
560 "The previous dependent transaction outputs",
571 "The output number"},
576 "(required for P2SH) redeem script"},
584 "The signature hash type. Must be one of:\n"
587 " \"SINGLE|FORKID\"\n"
588 " \"ALL|FORKID|ANYONECANPAY\"\n"
589 " \"NONE|FORKID|ANYONECANPAY\"\n"
590 " \"SINGLE|FORKID|ANYONECANPAY\""},
598 "The hex-encoded raw transaction with signature(s)"},
600 "If the transaction has a complete set of signatures"},
604 "Script verification errors (if there are any)",
611 "The hash of the referenced, previous transaction"},
613 "The index of the output to spent and used as "
616 "The hex-encoded signature script"},
618 "Script sequence number"},
620 "Verification or signing error related to the "
627 "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") +
629 "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")},
633 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
640 for (
size_t idx = 0; idx < keys.
size(); ++idx) {
645 "Invalid private key");
651 std::map<COutPoint, Coin> coins;
652 for (
const CTxIn &txin : mtx.
vin) {
672 "Return a JSON object representing the serialized, base64-encoded "
673 "partially signed Bitcoin transaction.\n",
676 "The PSBT base64 string"},
685 "The decoded network-serialized unsigned transaction.",
688 "The layout is the same as the output of "
689 "decoderawtransaction."},
693 "The unknown global fields",
696 "(key-value pair) An unknown key-value pair"},
709 "Transaction output for UTXOs",
721 "The type, eg 'pubkeyhash'"},
723 " Bitcoin address if there is one"},
727 "partial_signatures",
732 "The public key and signature that corresponds "
736 "The sighash type to be used"},
745 "The type, eg 'pubkeyhash'"},
755 "The public key with the derivation path as "
759 "The fingerprint of the master key"},
773 "The unknown global fields",
776 "(key-value pair) An unknown key-value pair"},
796 "The type, eg 'pubkeyhash'"},
808 "The public key this path corresponds to"},
810 "The fingerprint of the master key"},
816 "The unknown global fields",
819 "(key-value pair) An unknown key-value pair"},
824 "The transaction fee paid if all UTXOs slots in the PSBT have "
835 strprintf(
"TX decode failed %s", error));
843 result.
pushKV(
"tx", tx_univ);
846 if (psbtx.
unknown.size() > 0) {
848 for (
auto entry : psbtx.
unknown) {
851 result.
pushKV(
"unknown", unknowns);
856 bool have_all_utxos =
true;
858 for (
size_t i = 0; i < psbtx.
inputs.size(); ++i) {
873 have_all_utxos =
false;
878 out.
pushKV(
"scriptPubKey", o);
881 have_all_utxos =
false;
891 in.
pushKV(
"partial_signatures", partial_sigs);
895 uint8_t sighashbyte =
897 if (sighashbyte > 0) {
905 in.
pushKV(
"redeem_script", r);
916 "master_fingerprint",
918 ReadBE32(entry.second.fingerprint)));
923 in.
pushKV(
"bip32_derivs", keypaths);
932 in.
pushKV(
"final_scriptSig", scriptsig);
936 if (input.
unknown.size() > 0) {
938 for (
auto entry : input.
unknown) {
942 in.
pushKV(
"unknown", unknowns);
947 result.
pushKV(
"inputs", inputs);
952 for (
size_t i = 0; i < psbtx.
outputs.size(); ++i) {
959 out.
pushKV(
"redeem_script", r);
969 "master_fingerprint",
971 ReadBE32(entry.second.fingerprint)));
976 out.
pushKV(
"bip32_derivs", keypaths);
980 if (output.
unknown.size() > 0) {
982 for (
auto entry : output.
unknown) {
986 out.
pushKV(
"unknown", unknowns);
994 output_value += psbtx.
tx->vout[i].nValue;
997 have_all_utxos =
false;
1000 result.
pushKV(
"outputs", outputs);
1001 if (have_all_utxos) {
1002 result.
pushKV(
"fee", total_in - output_value);
1013 "Combine multiple partially signed Bitcoin transactions into one "
1015 "Implements the Combiner role.\n",
1021 "The base64 strings of partially signed transactions",
1024 "A base64 string of a PSBT"},
1029 "The base64-encoded partially signed transaction"},
1031 "combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")},
1035 std::vector<PartiallySignedTransaction> psbtxs;
1039 "Parameter 'txs' cannot be empty");
1041 for (
size_t i = 0; i < txs.
size(); ++i) {
1046 strprintf(
"TX decode failed %s", error));
1048 psbtxs.push_back(psbtx);
1058 ssTx << merged_psbt;
1067 "Finalize the inputs of a PSBT. If the transaction is fully signed, it "
1069 "network serialized transaction which can be broadcast with "
1070 "sendrawtransaction. Otherwise a PSBT will be\n"
1071 "created which has the final_scriptSigfields filled for inputs that "
1073 "Implements the Finalizer and Extractor roles.\n",
1076 "A base64 string of a PSBT"},
1078 "If true and the transaction is complete,\n"
1079 " extract and return the complete "
1080 "transaction in normal network serialization instead of the "
1088 "The base64-encoded partially signed transaction if not "
1091 "The hex-encoded network transaction if extracted"},
1093 "If the transaction has a complete set of signatures"},
1103 strprintf(
"TX decode failed %s", error));
1107 request.params[1].isNull() ||
1108 (!request.params[1].isNull() && request.params[1].get_bool());
1115 std::string result_str;
1119 result_str =
HexStr(ssTx);
1120 result.
pushKV(
"hex", result_str);
1124 result.
pushKV(
"psbt", result_str);
1126 result.
pushKV(
"complete", complete);
1136 "Creates a transaction in the Partially Signed Transaction format.\n"
1137 "Implements the Creator role.\n",
1154 "The output number"},
1157 "'locktime' argument"},
1158 "The sequence number"},
1166 "The outputs (key-value pairs), where none of "
1167 "the keys are duplicated.\n"
1168 "That is, each address can only appear once and there can only "
1169 "be one 'data' object.\n"
1170 "For compatibility reasons, a dictionary, which holds the "
1171 "key-value pairs directly, is also\n"
1172 " accepted as second parameter.",
1181 "A key-value pair. The key (string) is the "
1182 "bitcoin address, the value (float or string) is "
1194 "A key-value pair. The key must be \"data\", the "
1195 "value is hex-encoded data"},
1201 "Raw locktime. Non-0 value also locktime-activates inputs"},
1204 "The resulting raw transaction (base64-encoded string)"},
1206 "createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1207 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
1212 request.params[1], request.params[2]);
1217 for (
size_t i = 0; i < rawTx.
vin.size(); ++i) {
1220 for (
size_t i = 0; i < rawTx.
vout.size(); ++i) {
1236 "Converts a network serialized transaction to a PSBT. "
1237 "This should be used only with createrawtransaction and "
1238 "fundrawtransaction\n"
1239 "createpsbt and walletcreatefundedpsbt should be used for new "
1243 "The hex string of a raw transaction"},
1245 "If true, any signatures in the input will be discarded and "
1247 " will continue. If false, RPC will "
1248 "fail if any signatures are present."},
1251 "The resulting raw transaction (base64-encoded string)"},
1253 "\nCreate a transaction\n" +
1255 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1256 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1257 "\nConvert the transaction to a PSBT\n" +
1263 bool permitsigdata = request.params[1].isNull()
1265 : request.params[1].get_bool();
1266 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
1268 "TX decode failed");
1272 for (CTxIn &input : tx.
vin) {
1273 if (!input.scriptSig.empty() && !permitsigdata) {
1275 "Inputs must not have scriptSigs");
1277 input.scriptSig.clear();
1283 for (
size_t i = 0; i < tx.
vin.size(); ++i) {
1286 for (
size_t i = 0; i < tx.
vout.size(); ++i) {
1302 "Updates all inputs and outputs in a PSBT with data from output "
1303 "descriptors, the UTXO set or the mempool.\n",
1306 "A base64 string of a PSBT"},
1310 "An array of either strings or objects",
1313 "An output descriptor"},
1317 "An object with an output descriptor and extra information",
1320 "An output descriptor"},
1322 "Up to what index HD chains should be explored (either "
1323 "end or [begin,end])"},
1328 "The base64-encoded partially signed transaction with inputs "
1338 strprintf(
"TX decode failed %s", error));
1343 if (!request.params[1].isNull()) {
1344 auto descs = request.params[1].get_array();
1345 for (
size_t i = 0; i < descs.size(); ++i) {
1368 for (
const CTxIn &txin : psbtx.
tx->vin) {
1378 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
1394 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1408 "Joins multiple distinct PSBTs with different inputs and outputs "
1409 "into one PSBT with inputs and outputs from all of the PSBTs\n"
1410 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1414 "The base64 strings of partially signed transactions",
1416 "A base64 string of a PSBT"}}}},
1418 "The base64-encoded partially signed transaction"},
1423 std::vector<PartiallySignedTransaction> psbtxs;
1426 if (txs.
size() <= 1) {
1429 "At least two PSBTs are required to join PSBTs.");
1432 uint32_t best_version = 1;
1433 uint32_t best_locktime = 0xffffffff;
1434 for (
size_t i = 0; i < txs.
size(); ++i) {
1439 strprintf(
"TX decode failed %s", error));
1441 psbtxs.push_back(psbtx);
1443 if (
static_cast<uint32_t
>(psbtx.
tx->nVersion) > best_version) {
1444 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1447 if (psbtx.
tx->nLockTime < best_locktime) {
1448 best_locktime = psbtx.
tx->nLockTime;
1455 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1456 merged_psbt.
tx->nLockTime = best_locktime;
1459 for (
auto &psbt : psbtxs) {
1460 for (
size_t i = 0; i < psbt.tx->vin.size(); ++i) {
1461 if (!merged_psbt.
AddInput(psbt.tx->vin[i],
1465 strprintf(
"Input %s:%d exists in multiple PSBTs",
1470 psbt.tx->vin[i].prevout.GetN()));
1473 for (
size_t i = 0; i < psbt.tx->vout.size(); ++i) {
1474 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1476 merged_psbt.
unknown.insert(psbt.unknown.begin(),
1477 psbt.unknown.end());
1482 std::vector<int> input_indices(merged_psbt.
inputs.size());
1483 std::iota(input_indices.begin(), input_indices.end(), 0);
1484 std::vector<int> output_indices(merged_psbt.
outputs.size());
1485 std::iota(output_indices.begin(), output_indices.end(), 0);
1488 Shuffle(input_indices.begin(), input_indices.end(),
1490 Shuffle(output_indices.begin(), output_indices.end(),
1495 shuffled_psbt.
tx->nVersion = merged_psbt.
tx->nVersion;
1496 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1497 for (
int i : input_indices) {
1498 shuffled_psbt.
AddInput(merged_psbt.
tx->vin[i],
1501 for (
int i : output_indices) {
1509 ssTx << shuffled_psbt;
1518 "Analyzes and provides information about the current status of a "
1519 "PSBT and its inputs\n",
1521 "A base64 string of a PSBT"}},
1536 "Whether a UTXO is provided"},
1538 "Whether the input is finalized"},
1542 "Things that are missing that are required to "
1543 "complete this input",
1551 "Public key ID, hash160 of the public "
1552 "key, of a public key whose BIP 32 "
1553 "derivation path is missing"},
1561 "Public key ID, hash160 of the public "
1562 "key, of a public key whose signature is "
1567 "Hash160 of the redeemScript that is missing"},
1570 "Role of the next person that this input needs to "
1575 "Estimated vsize of the final signed transaction"},
1578 "Estimated feerate of the final signed transaction in " +
1580 "/kB. Shown only if all UTXO slots in the PSBT have been "
1583 "The transaction fee paid. Shown only if all UTXO slots in "
1584 "the PSBT have been filled"},
1586 "Role of the next person that this psbt needs to go to"},
1588 "Error message (if there is one)"},
1598 strprintf(
"TX decode failed %s", error));
1605 for (
const auto &input : psbta.
inputs) {
1609 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1610 input_univ.
pushKV(
"is_final", input.is_final);
1613 if (!input.missing_pubkeys.empty()) {
1615 for (
const CKeyID &pubkey : input.missing_pubkeys) {
1618 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
1620 if (!input.missing_redeem_script.IsNull()) {
1621 missing.
pushKV(
"redeemscript",
1622 HexStr(input.missing_redeem_script));
1624 if (!input.missing_sigs.empty()) {
1626 for (
const CKeyID &pubkey : input.missing_sigs) {
1629 missing.
pushKV(
"signatures", missing_sigs_univ);
1631 if (!missing.
getKeys().empty()) {
1632 input_univ.
pushKV(
"missing", missing);
1636 if (!inputs_result.
empty()) {
1637 result.
pushKV(
"inputs", inputs_result);
1643 result.
pushKV(
"estimated_feerate",
1646 if (psbta.
fee != std::nullopt) {
1650 if (!psbta.
error.empty()) {
1661 "gettransactionstatus",
1662 "Return the current pool a transaction belongs to\n",
1665 "The transaction id"},
1673 "In which pool the transaction is currently located, "
1674 "either none, mempool, orphanage or conflicting"},
1676 "If the transaction is mined, this is the blockhash of the "
1677 "mining block, otherwise \"none\". This field is only "
1678 "present if -txindex is enabled."},
1690 if (mempool.
exists(txid)) {
1691 ret.
pushKV(
"pool",
"mempool");
1694 return orphanage.HaveTx(txid);
1696 ret.
pushKV(
"pool",
"orphanage");
1699 return conflicting.HaveTx(txid);
1701 ret.
pushKV(
"pool",
"conflicting");
1703 ret.
pushKV(
"pool",
"none");
1707 if (!
g_txindex->BlockUntilSyncedToCurrentChain()) {
1710 "Blockchain transactions are still in the process of "
1716 if (
g_txindex->FindTx(txid, blockhash, tx)) {
1719 ret.
pushKV(
"block",
"none");
1750 for (
const auto &c : commands) {
bool MoneyRange(const Amount nValue)
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
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 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.
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.
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.
bool exists(const TxId &txid) const
auto withOrphanage(Callable &&func) const EXCLUSIVE_LOCKS_REQUIRED(!cs_orphanage)
auto withConflicting(Callable &&func) const EXCLUSIVE_LOCKS_REQUIRED(!cs_conflicting)
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...
SnapshotCompletionResult MaybeCompleteSnapshotValidation() EXCLUSIVE_LOCKS_REQUIRED(const CBlockIndex *GetSnapshotBaseBlock() const EXCLUSIVE_LOCKS_REQUIRED(Chainstate ActiveChainstate)() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
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
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const std::vector< std::string > & getKeys() const
const UniValue & get_array() const
void pushKV(std::string key, UniValue val)
std::string GetHex() const
CBlockIndex * LookupBlockIndex(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
std::string EncodeHexTx(const CTransaction &tx)
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.
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS, std::function< bool(const CTxOut &)> is_change_func={})
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)
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
CTransactionRef GetTransaction(const CBlockIndex *const block_index, const CTxMemPool *const mempool, const TxId &txid, BlockHash &hashBlock, const BlockManager &blockman)
Return transaction with a given txid.
void FindCoins(const NodeContext &node, std::map< COutPoint, Coin > &coins)
Look up unspent output information.
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 converttopsbt()
static RPCHelpMan decoderawtransaction()
static RPCHelpMan combinepsbt()
static RPCHelpMan decodepsbt()
RPCHelpMan gettransactionstatus()
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 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.
std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc, bool wallet)
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
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::string HelpExampleCli(const std::string &methodname, const std::string &args)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
std::vector< uint8_t > ParseHexV(const UniValue &v, std::string strName)
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
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 ...
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.
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
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
static const Currency & get()
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
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].
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g.
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
std::string DefaultHint
Hint for default value.
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
@ 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 WITH_LOCK(cs, code)
Run code while locking a mutex.
std::unique_ptr< TxIndex > g_txindex
The global transaction index, used in GetTransaction. May be null.
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)
static const int PROTOCOL_VERSION
network protocol versioning