34 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
49 if (
rbf.value_or(
true)) {
51 }
else if (
rawTx.nLockTime) {
70 rawTx.vin.push_back(in);
86 for (
size_t i = 0; i < outputs.
size(); ++i) {
91 if (output.
size() != 1) {
108 if (
name_ ==
"data") {
113 std::vector<unsigned char> data =
ParseHexV(outputs[
name_].getValStr(),
"Data");
142 CTxOut out(nAmount, scriptPubKey);
143 rawTx.vout.push_back(out);
155 rawTx.nLockTime = nLockTime;
161 rawTx.version = version;
177 entry.
pushKV(
"txid",
txin.prevout.hash.ToString());
180 for (
unsigned int i = 0; i <
txin.scriptWitness.stack.size(); i++) {
183 entry.
pushKV(
"witness", std::move(witness));
194 for (
unsigned int idx = 0; idx <
prevTxs.size(); ++idx) {
211 int nOut =
prevOut.find_value(
"vout").getInt<
int>();
221 auto coin = coins.find(out);
222 if (coin != coins.end() && !coin->second.IsSpent() && coin->second.out.scriptPubKey != scriptPubKey) {
223 std::string err(
"Previous output scriptPubKey mismatch:\n");
224 err = err +
ScriptToAsmStr(coin->second.out.scriptPubKey) +
"\nvs:\n"+
231 if (
prevOut.exists(
"amount")) {
235 coins[out] = std::move(
newcoin);
249 if (
rs.isNull() && ws.isNull()) {
262 if (!ws.isNull() && !
rs.isNull()) {
267 if (ws.get_str() !=
rs.get_str()) {
330 if (
err_pair.second.original ==
"Missing amount") {
338 result.
pushKV(
"complete", complete);
340 if (result.
exists(
"errors")) {
341 vErrors.push_backV(result[
"errors"].getValues());
353 {
RPCResult::Type::NUM,
"vsize",
"The virtual transaction size (differs from size for witness transactions)"},
385 std::vector<RPCResult>{{
RPCResult::Type::BOOL,
"ischange",
true,
"Output script is change (only present if true)"}} :
386 std::vector<RPCResult>{}
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination corresponds to one with an address.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
int64_t CAmount
Amount in satoshis (Can be negative)
static CAmount AmountFromValue(const UniValue &value)
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
bool IsPayToScriptHash() const
bool IsPayToWitnessScriptHash() const
A reference to a CScript: the Hash160 of its serialization.
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
static const uint32_t MAX_SEQUENCE_NONFINAL
This is the maximum sequence number that enables both nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
static const uint32_t SEQUENCE_FINAL
Setting nSequence to this value for every input in a transaction disables nLockTime/IsFinalTx().
An output of a transaction.
CTxOut out
unspent transaction output
An interface to be implemented by keystores that support signing.
void push_back(UniValue val)
const UniValue & find_value(std::string_view key) const
const UniValue & get_obj() const
const std::vector< std::string > & getKeys() const
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, UniValue val)
static transaction_identifier FromUint256(const uint256 &id)
std::string EncodeHexTx(const CTransaction &tx)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
const std::string CURRENCY_UNIT
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
@ SIGHASH_DEFAULT
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg, std::vector< int > *error_locations)
static constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION
static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION
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.
void AddInputs(CMutableTransaction &rawTx, const UniValue &inputs_in, std::optional< bool > rbf)
void AddOutputs(CMutableTransaction &rawTx, const UniValue &outputs_in)
Normalize, parse, and add outputs to the transaction.
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, std::optional< bool > rbf, const uint32_t version)
Create a transaction from univalue parameters.
std::vector< RPCResult > DecodeTxDoc(const std::string &txid_field_doc, bool wallet)
Explain the UniValue "decoded" transaction object, may include extra fields if processed by wallet.
static void TxInErrorToJSON(const CTxIn &txin, UniValue &vErrorsRet, const std::string &strMessage)
Pushes a JSON object for script verification or signing errors to vErrorsRet.
std::vector< std::pair< CTxDestination, CAmount > > ParseOutputs(const UniValue &outputs)
Parse normalized outputs into destination, amount tuples.
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.
UniValue JSONRPCError(int code, const std::string &message)
@ RPC_TYPE_ERROR
Unexpected type was passed as parameter.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string_view name)
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string_view strKey)
std::optional< int > ParseSighashString(const UniValue &sighash)
Returns a sighash value corresponding to the passed in argument.
uint256 ParseHashO(const UniValue &o, std::string_view strKey)
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
std::vector< RPCResult > ScriptPubKeyDoc()
static const uint32_t LOCKTIME_MAX
A mutable version of CTransaction.
@ NUM_TIME
Special numeric to denote unix epoch time.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
bool SignalsOptInRBF(const CTransaction &tx)
Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,...
static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.