7#include <chainparams.h>
73 entry.
pushKV(
"confirmations",
79 entry.
pushKV(
"confirmations", 0);
88 "\nReturn 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'.\n",
102 "The transaction id"},
106 "If false, return a string, otherwise return a json object",
110 "The block in which to look for the transaction"},
113 RPCResult{
"if verbose is not set or set to false",
115 "The serialized, hex-encoded data for 'txid'"},
117 "if verbose is set to true",
123 "Whether specified block is in the active chain or not "
124 "(only present with explicit \"blockhash\" argument)"},
126 "The serialized, hex-encoded data for 'txid'"},
128 "The transaction id (same as provided)"},
131 "The serialized transaction size"},
143 "The transaction id"},
153 "The script sequence number"},
174 "The required sigs"},
176 "The type, eg 'pubkeyhash'"},
189 "The confirmations"},
199 "\"mytxid\" false \"myblockhash\"") +
201 "\"mytxid\" true \"myblockhash\"")},
207 bool in_active_chain =
true;
216 "The genesis block coinbase is not considered an "
217 "ordinary transaction and cannot be retrieved");
222 bool fVerbose =
false;
223 if (!request.params[1].isNull()) {
224 fVerbose = request.params[1].isNum()
225 ? (request.params[1].getInt<
int>() != 0)
226 : request.params[1].get_bool();
229 if (!request.params[2].isNull()) {
233 ParseHashV(request.params[2],
"parameter 3"));
237 "Block hash not found");
242 bool f_txindex_ready =
false;
244 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
255 return !blockindex->nStatus.hasData())) {
257 "Block not available");
259 errmsg =
"No such transaction found in the provided block";
262 "No such mempool transaction. Use -txindex or provide "
263 "a block hash to enable blockchain transaction queries";
264 }
else if (!f_txindex_ready) {
265 errmsg =
"No such mempool transaction. Blockchain "
266 "transactions are still in the process of being "
269 errmsg =
"No such mempool or blockchain transaction";
273 errmsg +
". Use gettransaction for wallet transactions.");
282 result.
pushKV(
"in_active_chain", in_active_chain);
292 "createrawtransaction",
293 "Create a transaction spending the given inputs and creating new "
295 "Outputs can be addresses or data.\n"
296 "Returns hex-encoded raw transaction.\n"
297 "Note that the transaction's inputs are not signed, and\n"
298 "it is not stored in the wallet or transmitted to the network.\n",
315 "The output number"},
318 "'locktime' argument"},
319 "The sequence number"},
327 "The outputs (key-value pairs), where none of "
328 "the keys are duplicated.\n"
329 "That is, each address can only appear once and there can only "
330 "be one 'data' object.\n"
331 "For compatibility reasons, a dictionary, which holds the "
332 "key-value pairs directly, is also\n"
333 " accepted as second parameter.",
342 "A key-value pair. The key (string) is the "
343 "bitcoin address, the value (float or string) is "
355 "A key-value pair. The key must be \"data\", the "
356 "value is hex-encoded data"},
362 "Raw locktime. Non-0 value also locktime-activates inputs"},
365 "hex string of the transaction"},
368 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
369 "\" \"[{\\\"address\\\":10000.00}]\"") +
371 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
372 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
374 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
375 "\", \"[{\\\"address\\\":10000.00}]\"") +
377 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
378 "\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
383 request.params[1], request.params[2]);
392 "decoderawtransaction",
393 "Return a JSON object representing the serialized, hex-encoded "
397 "The transaction hex string"},
418 "The transaction id"},
428 "The script sequence number"},
449 "The required sigs"},
451 "The type, eg 'pubkeyhash'"},
469 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
485 "Decode a hex-encoded script.\n",
488 "the hex-encoded script"},
506 "address of P2SH script wrapping this redeem script (not "
507 "returned if the script is already a P2SH)"},
515 if (request.params[0].get_str().size() > 0) {
516 std::vector<uint8_t> scriptData(
517 ParseHexV(request.params[0],
"argument"));
518 script = CScript(scriptData.begin(), scriptData.end());
541 "combinerawtransaction",
542 "Combine multiple partially signed transactions into one "
544 "The combined transaction may be another partially signed transaction "
546 "fully signed transaction.",
552 "The hex strings of partially signed "
557 "A hex-encoded raw transaction"},
562 "The hex-encoded raw transaction with signature(s)"},
564 R
"('["myhex1", "myhex2", "myhex3"]')")},
568 std::vector<CMutableTransaction> txVariants(txs.
size());
570 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
571 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
574 strprintf(
"TX decode failed for tx %d", idx));
578 if (txVariants.empty()) {
580 "Missing transactions");
601 for (
const CTxIn &txin : mergedTx.
vin) {
612 const CTransaction txConst(mergedTx);
614 for (
size_t i = 0; i < mergedTx.
vin.size(); i++) {
615 CTxIn &txin = mergedTx.
vin[i];
619 "Input not found or already spent");
627 if (txv.vin.size() > i) {
634 &mergedTx, i, txout.
nValue),
647 "signrawtransactionwithkey",
648 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
649 "The second argument is an array of base58-encoded private\n"
650 "keys that will be the only keys used to sign the transaction.\n"
651 "The third optional argument (may be null) is an array of previous "
652 "transaction outputs that\n"
653 "this transaction depends on but may not yet be in the block chain.\n",
656 "The transaction hex string"},
661 "The base58-encoded private keys for signing",
664 "private key in base58-encoding"},
671 "The previous dependent transaction outputs",
682 "The output number"},
687 "(required for P2SH) redeem script"},
695 "The signature hash type. Must be one of:\n"
698 " \"SINGLE|FORKID\"\n"
699 " \"ALL|FORKID|ANYONECANPAY\"\n"
700 " \"NONE|FORKID|ANYONECANPAY\"\n"
701 " \"SINGLE|FORKID|ANYONECANPAY\""},
709 "The hex-encoded raw transaction with signature(s)"},
711 "If the transaction has a complete set of signatures"},
715 "Script verification errors (if there are any)",
722 "The hash of the referenced, previous transaction"},
724 "The index of the output to spent and used as "
727 "The hex-encoded signature script"},
729 "Script sequence number"},
731 "Verification or signing error related to the "
738 "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") +
740 "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")},
744 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
751 for (
size_t idx = 0; idx < keys.
size(); ++idx) {
756 "Invalid private key");
762 std::map<COutPoint, Coin> coins;
763 for (
const CTxIn &txin : mtx.
vin) {
783 "Return a JSON object representing the serialized, base64-encoded "
784 "partially signed Bitcoin transaction.\n",
787 "The PSBT base64 string"},
796 "The decoded network-serialized unsigned transaction.",
799 "The layout is the same as the output of "
800 "decoderawtransaction."},
804 "The unknown global fields",
807 "(key-value pair) An unknown key-value pair"},
820 "Transaction output for UTXOs",
832 "The type, eg 'pubkeyhash'"},
834 " Bitcoin address if there is one"},
838 "partial_signatures",
843 "The public key and signature that corresponds "
847 "The sighash type to be used"},
856 "The type, eg 'pubkeyhash'"},
866 "The public key with the derivation path as "
870 "The fingerprint of the master key"},
884 "The unknown global fields",
887 "(key-value pair) An unknown key-value pair"},
907 "The type, eg 'pubkeyhash'"},
919 "The public key this path corresponds to"},
921 "The fingerprint of the master key"},
927 "The unknown global fields",
930 "(key-value pair) An unknown key-value pair"},
935 "The transaction fee paid if all UTXOs slots in the PSBT have "
954 result.
pushKV(
"tx", tx_univ);
957 if (psbtx.
unknown.size() > 0) {
959 for (
auto entry : psbtx.
unknown) {
962 result.
pushKV(
"unknown", unknowns);
967 bool have_all_utxos =
true;
969 for (
size_t i = 0; i < psbtx.
inputs.size(); ++i) {
984 have_all_utxos =
false;
989 out.
pushKV(
"scriptPubKey", o);
992 have_all_utxos =
false;
1002 in.
pushKV(
"partial_signatures", partial_sigs);
1006 uint8_t sighashbyte =
1008 if (sighashbyte > 0) {
1016 in.
pushKV(
"redeem_script", r);
1027 "master_fingerprint",
1029 ReadBE32(entry.second.fingerprint)));
1034 in.
pushKV(
"bip32_derivs", keypaths);
1043 in.
pushKV(
"final_scriptSig", scriptsig);
1047 if (input.
unknown.size() > 0) {
1049 for (
auto entry : input.
unknown) {
1053 in.
pushKV(
"unknown", unknowns);
1058 result.
pushKV(
"inputs", inputs);
1063 for (
size_t i = 0; i < psbtx.
outputs.size(); ++i) {
1070 out.
pushKV(
"redeem_script", r);
1080 "master_fingerprint",
1082 ReadBE32(entry.second.fingerprint)));
1087 out.
pushKV(
"bip32_derivs", keypaths);
1091 if (output.
unknown.size() > 0) {
1093 for (
auto entry : output.
unknown) {
1097 out.
pushKV(
"unknown", unknowns);
1105 output_value += psbtx.
tx->vout[i].nValue;
1108 have_all_utxos =
false;
1111 result.
pushKV(
"outputs", outputs);
1112 if (have_all_utxos) {
1113 result.
pushKV(
"fee", total_in - output_value);
1124 "Combine multiple partially signed Bitcoin transactions into one "
1126 "Implements the Combiner role.\n",
1132 "The base64 strings of partially signed transactions",
1135 "A base64 string of a PSBT"},
1140 "The base64-encoded partially signed transaction"},
1142 "combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")},
1146 std::vector<PartiallySignedTransaction> psbtxs;
1150 "Parameter 'txs' cannot be empty");
1152 for (
size_t i = 0; i < txs.
size(); ++i) {
1159 psbtxs.push_back(psbtx);
1169 ssTx << merged_psbt;
1178 "Finalize the inputs of a PSBT. If the transaction is fully signed, it "
1180 "network serialized transaction which can be broadcast with "
1181 "sendrawtransaction. Otherwise a PSBT will be\n"
1182 "created which has the final_scriptSigfields filled for inputs that "
1184 "Implements the Finalizer and Extractor roles.\n",
1187 "A base64 string of a PSBT"},
1189 "If true and the transaction is complete,\n"
1190 " extract and return the complete "
1191 "transaction in normal network serialization instead of the "
1199 "The base64-encoded partially signed transaction if not "
1202 "The hex-encoded network transaction if extracted"},
1204 "If the transaction has a complete set of signatures"},
1218 request.params[1].isNull() ||
1219 (!request.params[1].isNull() && request.params[1].get_bool());
1226 std::string result_str;
1230 result_str =
HexStr(ssTx);
1231 result.
pushKV(
"hex", result_str);
1235 result.
pushKV(
"psbt", result_str);
1237 result.
pushKV(
"complete", complete);
1247 "Creates a transaction in the Partially Signed Transaction format.\n"
1248 "Implements the Creator role.\n",
1265 "The output number"},
1268 "'locktime' argument"},
1269 "The sequence number"},
1277 "The outputs (key-value pairs), where none of "
1278 "the keys are duplicated.\n"
1279 "That is, each address can only appear once and there can only "
1280 "be one 'data' object.\n"
1281 "For compatibility reasons, a dictionary, which holds the "
1282 "key-value pairs directly, is also\n"
1283 " accepted as second parameter.",
1292 "A key-value pair. The key (string) is the "
1293 "bitcoin address, the value (float or string) is "
1305 "A key-value pair. The key must be \"data\", the "
1306 "value is hex-encoded data"},
1312 "Raw locktime. Non-0 value also locktime-activates inputs"},
1315 "The resulting raw transaction (base64-encoded string)"},
1317 "createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1318 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
1323 request.params[1], request.params[2]);
1328 for (
size_t i = 0; i < rawTx.
vin.size(); ++i) {
1331 for (
size_t i = 0; i < rawTx.
vout.size(); ++i) {
1347 "Converts a network serialized transaction to a PSBT. "
1348 "This should be used only with createrawtransaction and "
1349 "fundrawtransaction\n"
1350 "createpsbt and walletcreatefundedpsbt should be used for new "
1354 "The hex string of a raw transaction"},
1356 "If true, any signatures in the input will be discarded and "
1358 " will continue. If false, RPC will "
1359 "fail if any signatures are present."},
1362 "The resulting raw transaction (base64-encoded string)"},
1364 "\nCreate a transaction\n" +
1366 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1367 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1368 "\nConvert the transaction to a PSBT\n" +
1374 bool permitsigdata = request.params[1].isNull()
1376 : request.params[1].get_bool();
1377 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
1379 "TX decode failed");
1383 for (CTxIn &input : tx.
vin) {
1384 if (!input.scriptSig.empty() && !permitsigdata) {
1386 "Inputs must not have scriptSigs");
1388 input.scriptSig.clear();
1394 for (
size_t i = 0; i < tx.
vin.size(); ++i) {
1397 for (
size_t i = 0; i < tx.
vout.size(); ++i) {
1413 "Updates all inputs and outputs in a PSBT with data from output "
1414 "descriptors, the UTXO set or the mempool.\n",
1417 "A base64 string of a PSBT"},
1421 "An array of either strings or objects",
1424 "An output descriptor"},
1428 "An object with an output descriptor and extra information",
1431 "An output descriptor"},
1433 "Up to what index HD chains should be explored (either "
1434 "end or [begin,end])"},
1439 "The base64-encoded partially signed transaction with inputs "
1454 if (!request.params[1].isNull()) {
1455 auto descs = request.params[1].get_array();
1456 for (
size_t i = 0; i < descs.size(); ++i) {
1479 for (
const CTxIn &txin : psbtx.
tx->vin) {
1489 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
1505 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1519 "Joins multiple distinct PSBTs with different inputs and outputs "
1520 "into one PSBT with inputs and outputs from all of the PSBTs\n"
1521 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1525 "The base64 strings of partially signed transactions",
1527 "A base64 string of a PSBT"}}}},
1529 "The base64-encoded partially signed transaction"},
1534 std::vector<PartiallySignedTransaction> psbtxs;
1537 if (txs.
size() <= 1) {
1540 "At least two PSBTs are required to join PSBTs.");
1543 uint32_t best_version = 1;
1544 uint32_t best_locktime = 0xffffffff;
1545 for (
size_t i = 0; i < txs.
size(); ++i) {
1552 psbtxs.push_back(psbtx);
1554 if (
static_cast<uint32_t
>(psbtx.
tx->nVersion) > best_version) {
1555 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1558 if (psbtx.
tx->nLockTime < best_locktime) {
1559 best_locktime = psbtx.
tx->nLockTime;
1566 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1567 merged_psbt.
tx->nLockTime = best_locktime;
1570 for (
auto &psbt : psbtxs) {
1571 for (
size_t i = 0; i < psbt.tx->vin.size(); ++i) {
1572 if (!merged_psbt.
AddInput(psbt.tx->vin[i],
1576 strprintf(
"Input %s:%d exists in multiple PSBTs",
1581 psbt.tx->vin[i].prevout.GetN()));
1584 for (
size_t i = 0; i < psbt.tx->vout.size(); ++i) {
1585 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1587 merged_psbt.
unknown.insert(psbt.unknown.begin(),
1588 psbt.unknown.end());
1593 std::vector<int> input_indices(merged_psbt.
inputs.size());
1594 std::iota(input_indices.begin(), input_indices.end(), 0);
1595 std::vector<int> output_indices(merged_psbt.
outputs.size());
1596 std::iota(output_indices.begin(), output_indices.end(), 0);
1599 Shuffle(input_indices.begin(), input_indices.end(),
1601 Shuffle(output_indices.begin(), output_indices.end(),
1606 shuffled_psbt.
tx->nVersion = merged_psbt.
tx->nVersion;
1607 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1608 for (
int i : input_indices) {
1609 shuffled_psbt.
AddInput(merged_psbt.
tx->vin[i],
1612 for (
int i : output_indices) {
1620 ssTx << shuffled_psbt;
1629 "Analyzes and provides information about the current status of a "
1630 "PSBT and its inputs\n",
1632 "A base64 string of a PSBT"}},
1647 "Whether a UTXO is provided"},
1649 "Whether the input is finalized"},
1653 "Things that are missing that are required to "
1654 "complete this input",
1662 "Public key ID, hash160 of the public "
1663 "key, of a public key whose BIP 32 "
1664 "derivation path is missing"},
1672 "Public key ID, hash160 of the public "
1673 "key, of a public key whose signature is "
1678 "Hash160 of the redeemScript that is missing"},
1681 "Role of the next person that this input needs to "
1686 "Estimated vsize of the final signed transaction"},
1689 "Estimated feerate of the final signed transaction in " +
1691 "/kB. Shown only if all UTXO slots in the PSBT have been "
1694 "The transaction fee paid. Shown only if all UTXO slots in "
1695 "the PSBT have been filled"},
1697 "Role of the next person that this psbt needs to go to"},
1699 "Error message (if there is one)"},
1716 for (
const auto &input : psbta.
inputs) {
1720 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1721 input_univ.
pushKV(
"is_final", input.is_final);
1724 if (!input.missing_pubkeys.empty()) {
1726 for (
const CKeyID &pubkey : input.missing_pubkeys) {
1729 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
1731 if (!input.missing_redeem_script.IsNull()) {
1732 missing.
pushKV(
"redeemscript",
1733 HexStr(input.missing_redeem_script));
1735 if (!input.missing_sigs.empty()) {
1737 for (
const CKeyID &pubkey : input.missing_sigs) {
1740 missing.
pushKV(
"signatures", missing_sigs_univ);
1742 if (!missing.
getKeys().empty()) {
1743 input_univ.
pushKV(
"missing", missing);
1747 if (!inputs_result.
empty()) {
1748 result.
pushKV(
"inputs", inputs_result);
1754 result.
pushKV(
"estimated_feerate",
1757 if (psbta.
fee != std::nullopt) {
1761 if (!psbta.
error.empty()) {
1772 "gettransactionstatus",
1773 "Return the current pool a transaction belongs to\n",
1776 "The transaction id"},
1784 "In which pool the transaction is currently located, "
1785 "either none, mempool, orphanage or conflicting"},
1787 "If the transaction is mined, this is the blockhash of the "
1788 "mining block, otherwise \"none\". This field is only "
1789 "present if -txindex is enabled."},
1801 if (mempool.
exists(txid)) {
1802 ret.
pushKV(
"pool",
"mempool");
1805 return orphanage.HaveTx(txid);
1807 ret.
pushKV(
"pool",
"orphanage");
1810 return conflicting.HaveTx(txid);
1812 ret.
pushKV(
"pool",
"conflicting");
1814 ret.
pushKV(
"pool",
"none");
1818 if (!
g_txindex->BlockUntilSyncedToCurrentChain()) {
1821 "Blockchain transactions are still in the process of "
1827 if (
g_txindex->FindTx(txid, blockhash, tx)) {
1830 ret.
pushKV(
"block",
"none");
1861 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.
Double ended buffer combining vector and stream-like interfaces.
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(std::function< void(bilingual_str)> shutdown_fnc=[](bilingual_str msg) { AbortNode(msg.original, msg);}) 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, int serialize_flags=0, const CTxUndo *txundo=nullptr)
std::string SighashToStr(uint8_t sighash_type)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
static uint32_t ReadBE32(const uint8_t *ptr)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
CKey DecodeSecret(const std::string &str)
bool error(const char *fmt, const Args &...args)
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx)
Provides helpful miscellaneous information about where a PSBT is in the signing workflow.
TransactionError BroadcastTransaction(const NodeContext &node, const CTransactionRef tx, std::string &err_string, const Amount max_tx_fee, bool relay, bool wait_callback)
Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
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.
int RPCSerializationFlags()
Retrieves any serialization flags requested in command line argument.
NodeContext & EnsureAnyNodeContext(const std::any &context)
CTxMemPool & EnsureMemPool(const NodeContext &node)
ChainstateManager & EnsureChainman(const NodeContext &node)
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
void UpdateInput(CTxIn &input, const SignatureData &data)
SignatureData DataFromTransaction(const CMutableTransaction &tx, unsigned int nIn, const CTxOut &txout)
Extract signature data from a transaction input, and insert it.
const SigningProvider & DUMMY_SIGNING_PROVIDER
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
The arg is optional 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