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",
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",
122 "Whether specified block is in the active chain or not "
123 "(only present with explicit \"blockhash\" argument)"},
125 "The serialized, hex-encoded data for 'txid'"},
127 "The transaction id (same as provided)"},
130 "The serialized transaction size"},
142 "The transaction id"},
152 "The script sequence number"},
173 "The required sigs"},
175 "The type, eg 'pubkeyhash'"},
188 "The confirmations"},
198 "\"mytxid\" false \"myblockhash\"") +
200 "\"mytxid\" true \"myblockhash\"")},
206 bool in_active_chain =
true;
215 "The genesis block coinbase is not considered an "
216 "ordinary transaction and cannot be retrieved");
221 bool fVerbose =
false;
222 if (!request.params[1].isNull()) {
223 fVerbose = request.params[1].isNum()
224 ? (request.params[1].getInt<
int>() != 0)
225 : request.params[1].get_bool();
228 if (!request.params[2].isNull()) {
232 ParseHashV(request.params[2],
"parameter 3"));
236 "Block hash not found");
241 bool f_txindex_ready =
false;
243 f_txindex_ready =
g_txindex->BlockUntilSyncedToCurrentChain();
254 return !blockindex->nStatus.hasData())) {
256 "Block not available");
258 errmsg =
"No such transaction found in the provided block";
261 "No such mempool transaction. Use -txindex or provide "
262 "a block hash to enable blockchain transaction queries";
263 }
else if (!f_txindex_ready) {
264 errmsg =
"No such mempool transaction. Blockchain "
265 "transactions are still in the process of being "
268 errmsg =
"No such mempool or blockchain transaction";
272 errmsg +
". Use gettransaction for wallet transactions.");
281 result.
pushKV(
"in_active_chain", in_active_chain);
291 "createrawtransaction",
292 "Create a transaction spending the given inputs and creating new "
294 "Outputs can be addresses or data.\n"
295 "Returns hex-encoded raw transaction.\n"
296 "Note that the transaction's inputs are not signed, and\n"
297 "it is not stored in the wallet or transmitted to the network.\n",
314 "The output number"},
317 "'locktime' argument"},
318 "The sequence number"},
326 "The outputs (key-value pairs), where none of "
327 "the keys are duplicated.\n"
328 "That is, each address can only appear once and there can only "
329 "be one 'data' object.\n"
330 "For compatibility reasons, a dictionary, which holds the "
331 "key-value pairs directly, is also\n"
332 " accepted as second parameter.",
341 "A key-value pair. The key (string) is the "
342 "bitcoin address, the value (float or string) is "
354 "A key-value pair. The key must be \"data\", the "
355 "value is hex-encoded data"},
361 "Raw locktime. Non-0 value also locktime-activates inputs"},
364 "hex string of the transaction"},
367 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
368 "\" \"[{\\\"address\\\":10000.00}]\"") +
370 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
371 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
373 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
374 "\", \"[{\\\"address\\\":10000.00}]\"") +
376 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
377 "\", \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
382 request.params[1], request.params[2]);
391 "decoderawtransaction",
392 "Return a JSON object representing the serialized, hex-encoded "
396 "The transaction hex string"},
417 "The transaction id"},
427 "The script sequence number"},
448 "The required sigs"},
450 "The type, eg 'pubkeyhash'"},
468 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
484 "Decode a hex-encoded script.\n",
487 "the hex-encoded script"},
505 "address of P2SH script wrapping this redeem script (not "
506 "returned if the script is already a P2SH)"},
514 if (request.params[0].get_str().size() > 0) {
515 std::vector<uint8_t> scriptData(
516 ParseHexV(request.params[0],
"argument"));
517 script = CScript(scriptData.begin(), scriptData.end());
540 "combinerawtransaction",
541 "Combine multiple partially signed transactions into one "
543 "The combined transaction may be another partially signed transaction "
545 "fully signed transaction.",
551 "The hex strings of partially signed "
556 "A hex-encoded raw transaction"},
561 "The hex-encoded raw transaction with signature(s)"},
563 R
"('["myhex1", "myhex2", "myhex3"]')")},
567 std::vector<CMutableTransaction> txVariants(txs.
size());
569 for (
unsigned int idx = 0; idx < txs.
size(); idx++) {
570 if (!
DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
573 strprintf(
"TX decode failed for tx %d", idx));
577 if (txVariants.empty()) {
579 "Missing transactions");
600 for (
const CTxIn &txin : mergedTx.
vin) {
611 const CTransaction txConst(mergedTx);
613 for (
size_t i = 0; i < mergedTx.
vin.size(); i++) {
614 CTxIn &txin = mergedTx.
vin[i];
618 "Input not found or already spent");
626 if (txv.vin.size() > i) {
633 &mergedTx, i, txout.
nValue),
646 "signrawtransactionwithkey",
647 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
648 "The second argument is an array of base58-encoded private\n"
649 "keys that will be the only keys used to sign the transaction.\n"
650 "The third optional argument (may be null) is an array of previous "
651 "transaction outputs that\n"
652 "this transaction depends on but may not yet be in the block chain.\n",
655 "The transaction hex string"},
660 "The base58-encoded private keys for signing",
663 "private key in base58-encoding"},
670 "The previous dependent transaction outputs",
681 "The output number"},
686 "(required for P2SH) redeem script"},
694 "The signature hash type. Must be one of:\n"
697 " \"SINGLE|FORKID\"\n"
698 " \"ALL|FORKID|ANYONECANPAY\"\n"
699 " \"NONE|FORKID|ANYONECANPAY\"\n"
700 " \"SINGLE|FORKID|ANYONECANPAY\""},
708 "The hex-encoded raw transaction with signature(s)"},
710 "If the transaction has a complete set of signatures"},
714 "Script verification errors (if there are any)",
721 "The hash of the referenced, previous transaction"},
723 "The index of the output to spent and used as "
726 "The hex-encoded signature script"},
728 "Script sequence number"},
730 "Verification or signing error related to the "
737 "\"myhex\" \"[\\\"key1\\\",\\\"key2\\\"]\"") +
739 "\"myhex\", \"[\\\"key1\\\",\\\"key2\\\"]\"")},
743 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
750 for (
size_t idx = 0; idx < keys.
size(); ++idx) {
755 "Invalid private key");
761 std::map<COutPoint, Coin> coins;
762 for (
const CTxIn &txin : mtx.
vin) {
782 "Return a JSON object representing the serialized, base64-encoded "
783 "partially signed Bitcoin transaction.\n",
786 "The PSBT base64 string"},
795 "The decoded network-serialized unsigned transaction.",
798 "The layout is the same as the output of "
799 "decoderawtransaction."},
803 "The unknown global fields",
806 "(key-value pair) An unknown key-value pair"},
819 "Transaction output for UTXOs",
831 "The type, eg 'pubkeyhash'"},
833 " Bitcoin address if there is one"},
837 "partial_signatures",
842 "The public key and signature that corresponds "
846 "The sighash type to be used"},
855 "The type, eg 'pubkeyhash'"},
865 "The public key with the derivation path as "
869 "The fingerprint of the master key"},
883 "The unknown global fields",
886 "(key-value pair) An unknown key-value pair"},
906 "The type, eg 'pubkeyhash'"},
918 "The public key this path corresponds to"},
920 "The fingerprint of the master key"},
926 "The unknown global fields",
929 "(key-value pair) An unknown key-value pair"},
934 "The transaction fee paid if all UTXOs slots in the PSBT have "
953 result.
pushKV(
"tx", tx_univ);
956 if (psbtx.
unknown.size() > 0) {
958 for (
auto entry : psbtx.
unknown) {
961 result.
pushKV(
"unknown", unknowns);
966 bool have_all_utxos =
true;
968 for (
size_t i = 0; i < psbtx.
inputs.size(); ++i) {
983 have_all_utxos =
false;
988 out.
pushKV(
"scriptPubKey", o);
991 have_all_utxos =
false;
1001 in.
pushKV(
"partial_signatures", partial_sigs);
1005 uint8_t sighashbyte =
1007 if (sighashbyte > 0) {
1015 in.
pushKV(
"redeem_script", r);
1026 "master_fingerprint",
1028 ReadBE32(entry.second.fingerprint)));
1033 in.
pushKV(
"bip32_derivs", keypaths);
1042 in.
pushKV(
"final_scriptSig", scriptsig);
1046 if (input.
unknown.size() > 0) {
1048 for (
auto entry : input.
unknown) {
1052 in.
pushKV(
"unknown", unknowns);
1057 result.
pushKV(
"inputs", inputs);
1062 for (
size_t i = 0; i < psbtx.
outputs.size(); ++i) {
1069 out.
pushKV(
"redeem_script", r);
1079 "master_fingerprint",
1081 ReadBE32(entry.second.fingerprint)));
1086 out.
pushKV(
"bip32_derivs", keypaths);
1090 if (output.
unknown.size() > 0) {
1092 for (
auto entry : output.
unknown) {
1096 out.
pushKV(
"unknown", unknowns);
1104 output_value += psbtx.
tx->vout[i].nValue;
1107 have_all_utxos =
false;
1110 result.
pushKV(
"outputs", outputs);
1111 if (have_all_utxos) {
1112 result.
pushKV(
"fee", total_in - output_value);
1123 "Combine multiple partially signed Bitcoin transactions into one "
1125 "Implements the Combiner role.\n",
1131 "The base64 strings of partially signed transactions",
1134 "A base64 string of a PSBT"},
1139 "The base64-encoded partially signed transaction"},
1141 "combinepsbt", R
"('["mybase64_1", "mybase64_2", "mybase64_3"]')")},
1145 std::vector<PartiallySignedTransaction> psbtxs;
1149 "Parameter 'txs' cannot be empty");
1151 for (
size_t i = 0; i < txs.
size(); ++i) {
1158 psbtxs.push_back(psbtx);
1168 ssTx << merged_psbt;
1177 "Finalize the inputs of a PSBT. If the transaction is fully signed, it "
1179 "network serialized transaction which can be broadcast with "
1180 "sendrawtransaction. Otherwise a PSBT will be\n"
1181 "created which has the final_scriptSigfields filled for inputs that "
1183 "Implements the Finalizer and Extractor roles.\n",
1186 "A base64 string of a PSBT"},
1188 "If true and the transaction is complete,\n"
1189 " extract and return the complete "
1190 "transaction in normal network serialization instead of the "
1198 "The base64-encoded partially signed transaction if not "
1201 "The hex-encoded network transaction if extracted"},
1203 "If the transaction has a complete set of signatures"},
1217 request.params[1].isNull() ||
1218 (!request.params[1].isNull() && request.params[1].get_bool());
1225 std::string result_str;
1229 result_str =
HexStr(ssTx);
1230 result.
pushKV(
"hex", result_str);
1234 result.
pushKV(
"psbt", result_str);
1236 result.
pushKV(
"complete", complete);
1246 "Creates a transaction in the Partially Signed Transaction format.\n"
1247 "Implements the Creator role.\n",
1264 "The output number"},
1267 "'locktime' argument"},
1268 "The sequence number"},
1276 "The outputs (key-value pairs), where none of "
1277 "the keys are duplicated.\n"
1278 "That is, each address can only appear once and there can only "
1279 "be one 'data' object.\n"
1280 "For compatibility reasons, a dictionary, which holds the "
1281 "key-value pairs directly, is also\n"
1282 " accepted as second parameter.",
1291 "A key-value pair. The key (string) is the "
1292 "bitcoin address, the value (float or string) is "
1304 "A key-value pair. The key must be \"data\", the "
1305 "value is hex-encoded data"},
1311 "Raw locktime. Non-0 value also locktime-activates inputs"},
1314 "The resulting raw transaction (base64-encoded string)"},
1316 "createpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1317 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
1322 request.params[1], request.params[2]);
1327 for (
size_t i = 0; i < rawTx.
vin.size(); ++i) {
1330 for (
size_t i = 0; i < rawTx.
vout.size(); ++i) {
1346 "Converts a network serialized transaction to a PSBT. "
1347 "This should be used only with createrawtransaction and "
1348 "fundrawtransaction\n"
1349 "createpsbt and walletcreatefundedpsbt should be used for new "
1353 "The hex string of a raw transaction"},
1355 "If true, any signatures in the input will be discarded and "
1357 " will continue. If false, RPC will "
1358 "fail if any signatures are present."},
1361 "The resulting raw transaction (base64-encoded string)"},
1363 "\nCreate a transaction\n" +
1365 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]"
1366 "\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"") +
1367 "\nConvert the transaction to a PSBT\n" +
1373 bool permitsigdata = request.params[1].isNull()
1375 : request.params[1].get_bool();
1376 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
1378 "TX decode failed");
1382 for (CTxIn &input : tx.
vin) {
1383 if (!input.scriptSig.empty() && !permitsigdata) {
1385 "Inputs must not have scriptSigs");
1387 input.scriptSig.clear();
1393 for (
size_t i = 0; i < tx.
vin.size(); ++i) {
1396 for (
size_t i = 0; i < tx.
vout.size(); ++i) {
1412 "Updates all inputs and outputs in a PSBT with data from output "
1413 "descriptors, the UTXO set or the mempool.\n",
1416 "A base64 string of a PSBT"},
1420 "An array of either strings or objects",
1423 "An output descriptor"},
1427 "An object with an output descriptor and extra information",
1430 "An output descriptor"},
1432 "Up to what index HD chains should be explored (either "
1433 "end or [begin,end])"},
1438 "The base64-encoded partially signed transaction with inputs "
1453 if (!request.params[1].isNull()) {
1454 auto descs = request.params[1].get_array();
1455 for (
size_t i = 0; i < descs.size(); ++i) {
1478 for (
const CTxIn &txin : psbtx.
tx->vin) {
1488 for (
size_t i = 0; i < psbtx.
tx->vin.size(); ++i) {
1504 for (
unsigned int i = 0; i < psbtx.
tx->vout.size(); ++i) {
1518 "Joins multiple distinct PSBTs with different inputs and outputs "
1519 "into one PSBT with inputs and outputs from all of the PSBTs\n"
1520 "No input in any of the PSBTs can be in more than one of the PSBTs.\n",
1524 "The base64 strings of partially signed transactions",
1526 "A base64 string of a PSBT"}}}},
1528 "The base64-encoded partially signed transaction"},
1533 std::vector<PartiallySignedTransaction> psbtxs;
1536 if (txs.
size() <= 1) {
1539 "At least two PSBTs are required to join PSBTs.");
1542 uint32_t best_version = 1;
1543 uint32_t best_locktime = 0xffffffff;
1544 for (
size_t i = 0; i < txs.
size(); ++i) {
1551 psbtxs.push_back(psbtx);
1553 if (
static_cast<uint32_t
>(psbtx.
tx->nVersion) > best_version) {
1554 best_version =
static_cast<uint32_t
>(psbtx.
tx->nVersion);
1557 if (psbtx.
tx->nLockTime < best_locktime) {
1558 best_locktime = psbtx.
tx->nLockTime;
1565 merged_psbt.
tx->nVersion =
static_cast<int32_t
>(best_version);
1566 merged_psbt.
tx->nLockTime = best_locktime;
1569 for (
auto &psbt : psbtxs) {
1570 for (
size_t i = 0; i < psbt.tx->vin.size(); ++i) {
1571 if (!merged_psbt.
AddInput(psbt.tx->vin[i],
1575 strprintf(
"Input %s:%d exists in multiple PSBTs",
1580 psbt.tx->vin[i].prevout.GetN()));
1583 for (
size_t i = 0; i < psbt.tx->vout.size(); ++i) {
1584 merged_psbt.
AddOutput(psbt.tx->vout[i], psbt.outputs[i]);
1586 merged_psbt.
unknown.insert(psbt.unknown.begin(),
1587 psbt.unknown.end());
1592 std::vector<int> input_indices(merged_psbt.
inputs.size());
1593 std::iota(input_indices.begin(), input_indices.end(), 0);
1594 std::vector<int> output_indices(merged_psbt.
outputs.size());
1595 std::iota(output_indices.begin(), output_indices.end(), 0);
1598 Shuffle(input_indices.begin(), input_indices.end(),
1600 Shuffle(output_indices.begin(), output_indices.end(),
1605 shuffled_psbt.
tx->nVersion = merged_psbt.
tx->nVersion;
1606 shuffled_psbt.
tx->nLockTime = merged_psbt.
tx->nLockTime;
1607 for (
int i : input_indices) {
1608 shuffled_psbt.
AddInput(merged_psbt.
tx->vin[i],
1611 for (
int i : output_indices) {
1619 ssTx << shuffled_psbt;
1628 "Analyzes and provides information about the current status of a "
1629 "PSBT and its inputs\n",
1631 "A base64 string of a PSBT"}},
1646 "Whether a UTXO is provided"},
1648 "Whether the input is finalized"},
1652 "Things that are missing that are required to "
1653 "complete this input",
1661 "Public key ID, hash160 of the public "
1662 "key, of a public key whose BIP 32 "
1663 "derivation path is missing"},
1671 "Public key ID, hash160 of the public "
1672 "key, of a public key whose signature is "
1677 "Hash160 of the redeemScript that is missing"},
1680 "Role of the next person that this input needs to "
1685 "Estimated vsize of the final signed transaction"},
1688 "Estimated feerate of the final signed transaction in " +
1690 "/kB. Shown only if all UTXO slots in the PSBT have been "
1693 "The transaction fee paid. Shown only if all UTXO slots in "
1694 "the PSBT have been filled"},
1696 "Role of the next person that this psbt needs to go to"},
1698 "Error message (if there is one)"},
1715 for (
const auto &input : psbta.
inputs) {
1719 input_univ.
pushKV(
"has_utxo", input.has_utxo);
1720 input_univ.
pushKV(
"is_final", input.is_final);
1723 if (!input.missing_pubkeys.empty()) {
1725 for (
const CKeyID &pubkey : input.missing_pubkeys) {
1728 missing.
pushKV(
"pubkeys", missing_pubkeys_univ);
1730 if (!input.missing_redeem_script.IsNull()) {
1731 missing.
pushKV(
"redeemscript",
1732 HexStr(input.missing_redeem_script));
1734 if (!input.missing_sigs.empty()) {
1736 for (
const CKeyID &pubkey : input.missing_sigs) {
1739 missing.
pushKV(
"signatures", missing_sigs_univ);
1741 if (!missing.
getKeys().empty()) {
1742 input_univ.
pushKV(
"missing", missing);
1746 if (!inputs_result.
empty()) {
1747 result.
pushKV(
"inputs", inputs_result);
1753 result.
pushKV(
"estimated_feerate",
1756 if (psbta.
fee != std::nullopt) {
1760 if (!psbta.
error.empty()) {
1771 "gettransactionstatus",
1772 "Return the current pool a transaction belongs to\n",
1775 "The transaction id"},
1783 "In which pool the transaction is currently located, "
1784 "either none, mempool, orphanage or conflicting"},
1786 "If the transaction is mined, this is the blockhash of the "
1787 "mining block, otherwise \"none\". This field is only "
1788 "present if -txindex is enabled."},
1800 if (mempool.
exists(txid)) {
1801 ret.
pushKV(
"pool",
"mempool");
1804 return orphanage.HaveTx(txid);
1806 ret.
pushKV(
"pool",
"orphanage");
1809 return conflicting.HaveTx(txid);
1811 ret.
pushKV(
"pool",
"conflicting");
1813 ret.
pushKV(
"pool",
"none");
1817 if (!
g_txindex->BlockUntilSyncedToCurrentChain()) {
1820 "Blockchain transactions are still in the process of "
1826 if (
g_txindex->FindTx(txid, blockhash, tx)) {
1829 ret.
pushKV(
"block",
"none");
1860 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(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, 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
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