7#include <chainparams.h>
72 entry.
pushKV(
"confirmations",
78 entry.
pushKV(
"confirmations", 0);
87 "\nReturn the raw transaction data.\n"
88 "\nBy default, this call only returns a transaction if it is in the "
89 "mempool. If -txindex is enabled\n"
90 "and no blockhash argument is passed, it will return the transaction "
91 "if it is in the mempool or any block.\n"
92 "If a blockhash argument is passed, it will return the transaction if\n"
93 "the specified block is available and the transaction is in that "
95 "\nIf verbose is 'true', returns an Object with information about "
97 "If verbose is 'false' or omitted, returns a string that is "
98 "serialized, hex-encoded data for 'txid'.\n",
101 "The transaction id"},
105 "If false, return a string, otherwise return a json object",
108 "The block in which to look for the transaction"},
111 RPCResult{
"if verbose is not set or set to false",
113 "The serialized, hex-encoded data for 'txid'"},
115 "if verbose is set to true",
121 "Whether specified block is in the active chain or not "
122 "(only present with explicit \"blockhash\" argument)"},
124 "The serialized, hex-encoded data for 'txid'"},
126 "The transaction id (same as provided)"},
129 "The serialized transaction size"},
141 "The transaction id"},
151 "The script sequence number"},
172 "The required sigs"},
174 "The type, eg 'pubkeyhash'"},
187 "The confirmations"},
197 "\"mytxid\" false \"myblockhash\"") +
199 "\"mytxid\" true \"myblockhash\"")},
205 bool in_active_chain =
true;
214 "The genesis block coinbase is not considered an "
215 "ordinary transaction and cannot be retrieved");
220 bool fVerbose =
false;
221 if (!request.params[1].isNull()) {
222 fVerbose = request.params[1].isNum()
223 ? (request.params[1].getInt<
int>() != 0)
224 : request.params[1].get_bool();
227 if (!request.params[2].isNull()) {
231 ParseHashV(request.params[2],
"parameter 3"));
235 "Block hash not found");
240 bool f_txindex_ready =
false;
242 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
253 return !blockindex->nStatus.hasData())) {
255 "Block not available");
257 errmsg =
"No such transaction found in the provided block";
260 "No such mempool transaction. Use -txindex or provide "
261 "a block hash to enable blockchain transaction queries";
262 }
else if (!f_txindex_ready) {
263 errmsg =
"No such mempool transaction. Blockchain "
264 "transactions are still in the process of being "
267 errmsg =
"No such mempool or blockchain transaction";
271 errmsg +
". Use gettransaction for wallet transactions.");
280 result.
pushKV(
"in_active_chain", in_active_chain);
290 "createrawtransaction",
291 "Create a transaction spending the given inputs and creating new "
293 "Outputs can be addresses or data.\n"
294 "Returns hex-encoded raw transaction.\n"
295 "Note that the transaction's inputs are not signed, and\n"
296 "it is not stored in the wallet or transmitted to the network.\n",
313 "The output number"},
316 "'locktime' argument"},
317 "The sequence number"},
325 "The outputs (key-value pairs), where none of "
326 "the keys are duplicated.\n"
327 "That is, each address can only appear once and there can only "
328 "be one 'data' object.\n"
329 "For compatibility reasons, a dictionary, which holds the "
330 "key-value pairs directly, is also\n"
331 " accepted as second parameter.",
340 "A key-value pair. The key (string) is the "
341 "bitcoin address, the value (float or string) is "
353 "A key-value pair. The key must be \"data\", the "
354 "value is hex-encoded data"},
360 "Raw locktime. Non-0 value also locktime-activates inputs"},
363 "hex string of the transaction"},
366 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
367 "\" \"[{\\\"address\\\":10000.00}]\"") +
369 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
370 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
372 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
373 "\", \"[{\\\"address\\\":10000.00}]\"") +
375 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
376 "\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
381 request.params[1], request.params[2]);
390 "decoderawtransaction",
391 "Return a JSON object representing the serialized, hex-encoded "
395 "The transaction hex string"},
416 "The transaction id"},
426 "The script sequence number"},
447 "The required sigs"},
449 "The type, eg 'pubkeyhash'"},
467 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
483 "Decode a hex-encoded script.\n",
486 "the hex-encoded script"},
504 "address of P2SH script wrapping this redeem script (not "
505 "returned if the script is already a P2SH)"},
513 if (request.params[0].get_str().size() > 0) {
514 std::vector<uint8_t> scriptData(
515 ParseHexV(request.params[0],
"argument"));
516 script = CScript(scriptData.begin(), scriptData.end());
539 "combinerawtransaction",
540 "Combine multiple partially signed transactions into one "
542 "The combined transaction may be another partially signed transaction "
544 "fully signed transaction.",
550 "The hex strings of partially signed "
555 "A hex-encoded raw transaction"},
560 "The hex-encoded raw transaction with signature(s)"},
562 R
"('["myhex1", "myhex2", "myhex3"]')")},
566 std::vector<CMutableTransaction> txVariants(txs.
size());
568 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
569 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
572 strprintf(
"TX decode failed for tx %d", idx));
576 if (txVariants.empty()) {
578 "Missing transactions");
599 for (
const CTxIn &txin : mergedTx.
vin) {
610 const CTransaction txConst(mergedTx);
612 for (
size_t i = 0; i < mergedTx.
vin.size(); i++) {
613 CTxIn &txin = mergedTx.
vin[i];
617 "Input not found or already spent");
625 if (txv.vin.size() > i) {
632 &mergedTx, i, txout.
nValue),
645 "signrawtransactionwithkey",
646 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
647 "The second argument is an array of base58-encoded private\n"
648 "keys that will be the only keys used to sign the transaction.\n"
649 "The third optional argument (may be null) is an array of previous "
650 "transaction outputs that\n"
651 "this transaction depends on but may not yet be in the block chain.\n",
654 "The transaction hex string"},
659 "The base58-encoded private keys for signing",
662 "private key in base58-encoding"},
669 "The previous dependent transaction outputs",
680 "The output number"},
685 "(required for P2SH) redeem script"},
693 "The signature hash type. Must be one of:\n"
696 " \"SINGLE|FORKID\"\n"
697 " \"ALL|FORKID|ANYONECANPAY\"\n"
698 " \"NONE|FORKID|ANYONECANPAY\"\n"
699 " \"SINGLE|FORKID|ANYONECANPAY\""},
707 "The hex-encoded raw transaction with signature(s)"},
709 "If the transaction has a complete set of signatures"},
713 "Script verification errors (if there are any)",
720 "The hash of the referenced, previous transaction"},
722 "The index of the output to spent and used as "
725 "The hex-encoded signature script"},
727 "Script sequence number"},
729 "Verification or signing error related to the "
736 "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") +
738 "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")},
742 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
749 for (
size_t idx = 0; idx < keys.
size(); ++idx) {
754 "Invalid private key");
760 std::map<COutPoint, Coin> coins;
761 for (
const CTxIn &txin : mtx.
vin) {
781 "Return a JSON object representing the serialized, base64-encoded "
782 "partially signed Bitcoin transaction.\n",
785 "The PSBT base64 string"},
794 "The decoded network-serialized unsigned transaction.",
797 "The layout is the same as the output of "
798 "decoderawtransaction."},
802 "The unknown global fields",
805 "(key-value pair) An unknown key-value pair"},
818 "Transaction output for UTXOs",
830 "The type, eg 'pubkeyhash'"},
832 " Bitcoin address if there is one"},
836 "partial_signatures",
841 "The public key and signature that corresponds "
845 "The sighash type to be used"},
854 "The type, eg 'pubkeyhash'"},
864 "The public key with the derivation path as "
868 "The fingerprint of the master key"},
882 "The unknown global fields",
885 "(key-value pair) An unknown key-value pair"},
905 "The type, eg 'pubkeyhash'"},
917 "The public key this path corresponds to"},
919 "The fingerprint of the master key"},
925 "The unknown global fields",
928 "(key-value pair) An unknown key-value pair"},
933 "The transaction fee paid if all UTXOs slots in the PSBT have "
944 strprintf(
"TX decode failed %s", error));
952 result.
pushKV(
"tx", tx_univ);
955 if (psbtx.
unknown.size() > 0) {
957 for (
auto entry : psbtx.
unknown) {
960 result.
pushKV(
"unknown", unknowns);
965 bool have_all_utxos =
true;
967 for (
size_t i = 0; i < psbtx.
inputs.size(); ++i) {
982 have_all_utxos =
false;
987 out.
pushKV(
"scriptPubKey", o);
990 have_all_utxos =
false;
1000 in.
pushKV(
"partial_signatures", partial_sigs);
1004 uint8_t sighashbyte =
1006 if (sighashbyte > 0) {
1014 in.
pushKV(
"redeem_script", r);
1025 "master_fingerprint",
1027 ReadBE32(entry.second.fingerprint)));
1032 in.
pushKV(
"bip32_derivs", keypaths);
1041 in.
pushKV(
"final_scriptSig", scriptsig);
1045 if (input.
unknown.size() > 0) {
1047 for (
auto entry : input.
unknown) {
1051 in.
pushKV(
"unknown", unknowns);
1056 result.
pushKV(
"inputs", inputs);
1061 for (
size_t i = 0; i < psbtx.
outputs.size(); ++i) {
1068 out.
pushKV(
"redeem_script", r);
1078 "master_fingerprint",
1080 ReadBE32(entry.second.fingerprint)));
1085 out.
pushKV(
"bip32_derivs", keypaths);
1089 if (output.
unknown.size() > 0) {
1091 for (
auto entry : output.
unknown) {
1095 out.
pushKV(
"unknown", unknowns);
1103 output_value += psbtx.
tx->vout[i].nValue;
1106 have_all_utxos =
false;
1109 result.
pushKV(
"outputs", outputs);
1110 if (have_all_utxos) {
1111 result.
pushKV(
"fee", total_in - output_value);
1122 "Combine multiple partially signed Bitcoin transactions into one "
1124 "Implements the Combiner role.\n",
1130 "The base64 strings of partially signed transactions",
1133 "A base64 string of a PSBT"},
1138 "The base64-encoded partially signed transaction"},
1140 "combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")},
1144 std::vector<PartiallySignedTransaction> psbtxs;
1148 "Parameter 'txs' cannot be empty");
1150 for (
size_t i = 0; i < txs.
size(); ++i) {
1155 strprintf(
"TX decode failed %s", error));
1157 psbtxs.push_back(psbtx);
1167 ssTx << merged_psbt;
1176 "Finalize the inputs of a PSBT. If the transaction is fully signed, it "
1178 "network serialized transaction which can be broadcast with "
1179 "sendrawtransaction. Otherwise a PSBT will be\n"
1180 "created which has the final_scriptSigfields filled for inputs that "
1182 "Implements the Finalizer and Extractor roles.\n",
1185 "A base64 string of a PSBT"},
1187 "If true and the transaction is complete,\n"
1188 " extract and return the complete "
1189 "transaction in normal network serialization instead of the "
1197 "The base64-encoded partially signed transaction if not "
1200 "The hex-encoded network transaction if extracted"},
1202 "If the transaction has a complete set of signatures"},
1212 strprintf(
"TX decode failed %s", error));
1216 request.params[1].isNull() ||
1217 (!request.params[1].isNull() && request.params[1].get_bool());
1224 std::string result_str;
1228 result_str =
HexStr(ssTx);
1229 result.
pushKV(
"hex", result_str);
1233 result.
pushKV(
"psbt", result_str);
1235 result.
pushKV(
"complete", complete);
1245 "Creates a transaction in the Partially Signed Transaction format.\n"
1246 "Implements the Creator role.\n",
1263 "The output number"},
1266 "'locktime' argument"},
1267 "The sequence number"},
1275 "The outputs (key-value pairs), where none of "
1276 "the keys are duplicated.\n"
1277 "That is, each address can only appear once and there can only "
1278 "be one 'data' object.\n"
1279 "For compatibility reasons, a dictionary, which holds the "
1280 "key-value pairs directly, is also\n"
1281 " accepted as second parameter.",
1290 "A key-value pair. The key (string) is the "
1291 "bitcoin address, the value (float or string) is "
1303 "A key-value pair. The key must be \"data\", the "
1304 "value is hex-encoded data"},
1310 "Raw locktime. Non-0 value also locktime-activates inputs"},
1313 "The resulting raw transaction (base64-encoded string)"},
1315 "createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1316 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
1321 request.params[1], request.params[2]);
1326 for (
size_t i = 0; i < rawTx.
vin.size(); ++i) {
1329 for (
size_t i = 0; i < rawTx.
vout.size(); ++i) {
1345 "Converts a network serialized transaction to a PSBT. "
1346 "This should be used only with createrawtransaction and "
1347 "fundrawtransaction\n"
1348 "createpsbt and walletcreatefundedpsbt should be used for new "
1352 "The hex string of a raw transaction"},
1354 "If true, any signatures in the input will be discarded and "
1356 " will continue. If false, RPC will "
1357 "fail if any signatures are present."},
1360 "The resulting raw transaction (base64-encoded string)"},
1362 "\nCreate a transaction\n" +
1364 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1365 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1366 "\nConvert the transaction to a PSBT\n" +
1372 bool permitsigdata = request.params[1].isNull()
1374 : request.params[1].get_bool();
1375 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
1377 "TX decode failed");
1381 for (CTxIn &input : tx.
vin) {
1382 if (!input.scriptSig.empty() && !permitsigdata) {
1384 "Inputs must not have scriptSigs");
1386 input.scriptSig.clear();
1392 for (
size_t i = 0; i < tx.
vin.size(); ++i) {
1395 for (
size_t i = 0; i < tx.
vout.size(); ++i) {
1411 "Updates all inputs and outputs in a PSBT with data from output "
1412 "descriptors, the UTXO set or the mempool.\n",
1415 "A base64 string of a PSBT"},
1419 "An array of either strings or objects",
1422 "An output descriptor"},
1426 "An object with an output descriptor and extra information",
1429 "An output descriptor"},
1431 "Up to what index HD chains should be explored (either "
1432 "end or [begin,end])"},
1437 "The base64-encoded partially signed transaction with inputs "
1447 strprintf(
"TX decode failed %s", error));
1452 if (!request.params[1].isNull()) {
1453 auto descs = request.params[1].get_array();
1454 for (
size_t i = 0; i < descs.size(); ++i) {
1477 for (
const CTxIn &txin : psbtx.
tx->vin) {
1487 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
1503 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1517 "Joins multiple distinct PSBTs with different inputs and outputs "
1518 "into one PSBT with inputs and outputs from all of the PSBTs\n"
1519 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1523 "The base64 strings of partially signed transactions",
1525 "A base64 string of a PSBT"}}}},
1527 "The base64-encoded partially signed transaction"},
1532 std::vector<PartiallySignedTransaction> psbtxs;
1535 if (txs.
size() <= 1) {
1538 "At least two PSBTs are required to join PSBTs.");
1541 uint32_t best_version = 1;
1542 uint32_t best_locktime = 0xffffffff;
1543 for (
size_t i = 0; i < txs.
size(); ++i) {
1548 strprintf(
"TX decode failed %s", error));
1550 psbtxs.push_back(psbtx);
1552 if (
static_cast<uint32_t
>(psbtx.
tx->nVersion) > best_version) {
1553 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1556 if (psbtx.
tx->nLockTime < best_locktime) {
1557 best_locktime = psbtx.
tx->nLockTime;
1564 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1565 merged_psbt.
tx->nLockTime = best_locktime;
1568 for (
auto &psbt : psbtxs) {
1569 for (
size_t i = 0; i < psbt.tx->vin.size(); ++i) {
1570 if (!merged_psbt.
AddInput(psbt.tx->vin[i],
1574 strprintf(
"Input %s:%d exists in multiple PSBTs",
1579 psbt.tx->vin[i].prevout.GetN()));
1582 for (
size_t i = 0; i < psbt.tx->vout.size(); ++i) {
1583 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1585 merged_psbt.
unknown.insert(psbt.unknown.begin(),
1586 psbt.unknown.end());
1591 std::vector<int> input_indices(merged_psbt.
inputs.size());
1592 std::iota(input_indices.begin(), input_indices.end(), 0);
1593 std::vector<int> output_indices(merged_psbt.
outputs.size());
1594 std::iota(output_indices.begin(), output_indices.end(), 0);
1597 Shuffle(input_indices.begin(), input_indices.end(),
1599 Shuffle(output_indices.begin(), output_indices.end(),
1604 shuffled_psbt.
tx->nVersion = merged_psbt.
tx->nVersion;
1605 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1606 for (
int i : input_indices) {
1607 shuffled_psbt.
AddInput(merged_psbt.
tx->vin[i],
1610 for (
int i : output_indices) {
1618 ssTx << shuffled_psbt;
1627 "Analyzes and provides information about the current status of a "
1628 "PSBT and its inputs\n",
1630 "A base64 string of a PSBT"}},
1645 "Whether a UTXO is provided"},
1647 "Whether the input is finalized"},
1651 "Things that are missing that are required to "
1652 "complete this input",
1660 "Public key ID, hash160 of the public "
1661 "key, of a public key whose BIP 32 "
1662 "derivation path is missing"},
1670 "Public key ID, hash160 of the public "
1671 "key, of a public key whose signature is "
1676 "Hash160 of the redeemScript that is missing"},
1679 "Role of the next person that this input needs to "
1684 "Estimated vsize of the final signed transaction"},
1687 "Estimated feerate of the final signed transaction in " +
1689 "/kB. Shown only if all UTXO slots in the PSBT have been "
1692 "The transaction fee paid. Shown only if all UTXO slots in "
1693 "the PSBT have been filled"},
1695 "Role of the next person that this psbt needs to go to"},
1697 "Error message (if there is one)"},
1707 strprintf(
"TX decode failed %s", error));
1714 for (
const auto &input : psbta.
inputs) {
1718 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1719 input_univ.
pushKV(
"is_final", input.is_final);
1722 if (!input.missing_pubkeys.empty()) {
1724 for (
const CKeyID &pubkey : input.missing_pubkeys) {
1727 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
1729 if (!input.missing_redeem_script.IsNull()) {
1730 missing.
pushKV(
"redeemscript",
1731 HexStr(input.missing_redeem_script));
1733 if (!input.missing_sigs.empty()) {
1735 for (
const CKeyID &pubkey : input.missing_sigs) {
1738 missing.
pushKV(
"signatures", missing_sigs_univ);
1740 if (!missing.
getKeys().empty()) {
1741 input_univ.
pushKV(
"missing", missing);
1745 if (!inputs_result.
empty()) {
1746 result.
pushKV(
"inputs", inputs_result);
1752 result.
pushKV(
"estimated_feerate",
1755 if (psbta.
fee != std::nullopt) {
1759 if (!psbta.
error.empty()) {
1770 "gettransactionstatus",
1771 "Return the current pool a transaction belongs to\n",
1774 "The transaction id"},
1782 "In which pool the transaction is currently located, "
1783 "either none, mempool, orphanage or conflicting"},
1785 "If the transaction is mined, this is the blockhash of the "
1786 "mining block, otherwise \"none\". This field is only "
1787 "present if -txindex is enabled."},
1799 if (mempool.
exists(txid)) {
1800 ret.
pushKV(
"pool",
"mempool");
1803 return orphanage.HaveTx(txid);
1805 ret.
pushKV(
"pool",
"orphanage");
1808 return conflicting.HaveTx(txid);
1810 ret.
pushKV(
"pool",
"conflicting");
1812 ret.
pushKV(
"pool",
"none");
1816 if (!
g_txindex->BlockUntilSyncedToCurrentChain()) {
1819 "Blockchain transactions are still in the process of "
1825 if (
g_txindex->FindTx(txid, blockhash, tx)) {
1828 ret.
pushKV(
"block",
"none");
1859 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)
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr)
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.
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.
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