Bitcoin Core 32.99.0
P2P Digital Currency
rawtransaction_util.h
Go to the documentation of this file.
1// Copyright (c) 2017-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_RPC_RAWTRANSACTION_UTIL_H
6#define BITCOIN_RPC_RAWTRANSACTION_UTIL_H
7
8#include <addresstype.h>
9#include <consensus/amount.h>
10#include <rpc/util.h>
11
12#include <cstdint>
13#include <map>
14#include <optional>
15#include <string>
16#include <utility>
17#include <vector>
18
19struct bilingual_str;
21class UniValue;
23class Coin;
24class COutPoint;
25class SigningProvider;
26
36void SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore, const std::map<COutPoint, Coin>& coins, const UniValue& hashType, UniValue& result);
37void SignTransactionResultToJSON(CMutableTransaction& mtx, bool complete, const std::map<COutPoint, Coin>& coins, const std::map<int, bilingual_str>& input_errors, UniValue& result);
38
46void ParsePrevouts(const UniValue& prevTxsUnival, FlatSigningProvider* keystore, std::map<COutPoint, Coin>& coins);
47
49void AddInputs(CMutableTransaction& rawTx, const UniValue& inputs_in, bool rbf);
50
52UniValue NormalizeOutputs(const UniValue& outputs_in);
53
55std::vector<std::pair<CTxDestination, CAmount>> ParseOutputs(const UniValue& outputs);
56
58void AddOutputs(CMutableTransaction& rawTx, const UniValue& outputs_in);
59
61CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, std::optional<bool> rbf, uint32_t version);
62
63enum class ElisionMode {
64 None,
66 Silent,
67};
68
71 std::string txid_field_doc{"The transaction id"};
73 bool wallet{false};
77 std::optional<std::string> elision_summary{};
79 bool prevout{false};
81 bool prevout_optional{false};
83 bool fee{false};
85 bool hex{false};
87 std::optional<std::string> vin_item_doc{};
89 std::optional<std::string> prevout_doc{};
91 std::optional<std::string> fee_doc{};
93 std::optional<std::string> vin_inner_elision{};
94};
96std::vector<RPCResult> TxDoc(const TxDocOptions& opts = {});
97
98#endif // BITCOIN_RPC_RAWTRANSACTION_UTIL_H
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
A UTXO entry.
Definition: coins.h:46
An interface to be implemented by keystores that support signing.
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, const std::map< int, bilingual_str > &input_errors, UniValue &result)
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.
@ WithSummary
first field carries elision_summary as "...", rest skipped
@ Silent
all top-level fields skipped silently (no "..." line)
@ None
no elision, all top-level fields rendered normally
void AddOutputs(CMutableTransaction &rawTx, const UniValue &outputs_in)
Normalize, parse, and add outputs to the transaction.
std::vector< RPCResult > TxDoc(const TxDocOptions &opts={})
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
std::vector< std::pair< CTxDestination, CAmount > > ParseOutputs(const UniValue &outputs)
Parse normalized outputs into destination, amount tuples.
void AddInputs(CMutableTransaction &rawTx, const UniValue &inputs_in, bool rbf)
Normalize univalue-represented inputs and add them to the transaction.
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, std::optional< bool > rbf, uint32_t version)
Create a transaction from univalue parameters.
UniValue NormalizeOutputs(const UniValue &outputs_in)
Normalize univalue-represented outputs.
void ParsePrevouts(const UniValue &prevTxsUnival, FlatSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
A mutable version of CTransaction.
Definition: transaction.h:358
std::optional< std::string > prevout_doc
Customize the prevout field's description (only meaningful when prevout is true)
std::string txid_field_doc
The description of the txid field.
std::optional< std::string > vin_item_doc
Customize the vin item object's description (only meaningful when vin_inner_elision is set)
std::optional< std::string > elision_summary
Summary text shown as "..." required for elision_mode == WithSummary.
bool hex
Include hex field.
std::optional< std::string > vin_inner_elision
Elide vin inner fields but keep vin array with prevout expanded.
bool prevout
Include prevout field.
std::optional< std::string > fee_doc
Customize the fee field's description (only meaningful when fee is true)
ElisionMode elision_mode
Controls top-level field elision in the help.
bool fee
Include fee field.
bool prevout_optional
Mark prevout field as optional (omitted when undo data unavailable)
Bilingual messages:
Definition: translation.h:24