37    const bool outputs_is_obj = outputs_in.
isObject();
 
   49    for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
 
   73        if (sequenceObj.
isNum()) {
 
   74            int64_t seqNr64 = sequenceObj.
get_int64();
 
   78                nSequence = (uint32_t)seqNr64;
 
   84        rawTx.
vin.push_back(in);
 
   87    if (!outputs_is_obj) {
 
   90        for (
size_t i = 0; i < outputs.
size(); ++i) {
 
   95            if (output.
size() != 1) {
 
  100        outputs = std::move(outputs_dict);
 
  104    std::set<CTxDestination> destinations;
 
  105    bool has_data{
false};
 
  107    for (
const std::string& name_ : outputs.
getKeys()) {
 
  108        if (name_ == 
"data") {
 
  113            std::vector<unsigned char> data = 
ParseHexV(outputs[name_].getValStr(), 
"Data");
 
  116            rawTx.
vout.push_back(out);
 
  123            if (!destinations.insert(destination).second) {
 
  130            CTxOut out(nAmount, scriptPubKey);
 
  131            rawTx.
vout.push_back(out);
 
  152    entry.
pushKV(
"witness", witness);
 
  155    entry.
pushKV(
"error", strMessage);
 
  161    if (!prevTxsUnival.
isNull()) {
 
  163        for (
unsigned int idx = 0; idx < prevTxs.
size(); ++idx) {
 
  186            std::vector<unsigned char> pkData(
ParseHexO(prevOut, 
"scriptPubKey"));
 
  187            CScript scriptPubKey(pkData.begin(), pkData.end());
 
  190                auto coin = coins.find(out);
 
  191                if (coin != coins.end() && !coin->second.IsSpent() && coin->second.out.scriptPubKey != scriptPubKey) {
 
  192                    std::string err(
"Previous output scriptPubKey mismatch:\n");
 
  193                    err = err + 
ScriptToAsmStr(coin->second.out.scriptPubKey) + 
"\nvs:\n"+
 
  200                if (prevOut.
exists(
"amount")) {
 
  204                coins[out] = std::move(newcoin);
 
  210            if (keystore && (is_p2sh || is_p2wsh)) {
 
  218                if (rs.isNull() && ws.
isNull()) {
 
  223                std::vector<unsigned char> scriptData(!ws.
isNull() ? 
ParseHexV(ws, 
"witnessScript") : 
ParseHexV(rs, 
"redeemScript"));
 
  224                CScript script(scriptData.begin(), scriptData.end());
 
  231                if (!ws.
isNull() && !rs.isNull()) {
 
  236                    if (ws.
get_str() != rs.get_str()) {
 
  237                        std::vector<unsigned char> redeemScriptData(
ParseHexV(rs, 
"redeemScript"));
 
  238                        CScript redeemScript(redeemScriptData.begin(), redeemScriptData.end());
 
  239                        if (redeemScript != witness_output_script) {
 
  265                } 
else if (is_p2wsh) {
 
  285    std::map<int, bilingual_str> input_errors;
 
  287    bool complete = 
SignTransaction(mtx, keystore, coins, nHashType, input_errors);
 
  295    for (
const auto& err_pair : input_errors) {
 
  296        if (err_pair.second.original == 
"Missing amount") {
 
  304    result.
pushKV(
"complete", complete);
 
  305    if (!vErrors.
empty()) {
 
  306        if (result.
exists(
"errors")) {
 
  307            vErrors.
push_backV(result[
"errors"].getValues());
 
  309        result.
pushKV(
"errors", vErrors);
 
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
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
static const uint32_t SEQUENCE_FINAL
CScriptWitness scriptWitness
Only serialized through CTransaction.
An output of a transaction.
CTxOut out
unspent transaction output
uint32_t nHeight
at which height this containing transaction was included in the active block chain
Fillable signing provider that keeps keys in an address->secret map.
virtual bool AddCScript(const CScript &redeemScript)
An interface to be implemented by keystores that support signing.
const std::string & get_str() const
int64_t get_int64() const
const UniValue & get_obj() const
const std::vector< std::string > & getKeys() const
bool pushKVs(const UniValue &obj)
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool exists(const std::string &key) const
bool pushKV(const std::string &key, const UniValue &val)
bool push_backV(const std::vector< UniValue > &vec)
std::string ToString() const
int ParseSighashString(const UniValue &sighash)
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)
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
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.
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, bool rbf)
Create a transaction from univalue parameters.
static void TxInErrorToJSON(const CTxIn &txin, UniValue &vErrorsRet, const std::string &strMessage)
Pushes a JSON object for script verification or signing errors to vErrorsRet.
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_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 strName)
std::vector< unsigned char > ParseHexO(const UniValue &o, std::string strKey)
uint256 ParseHashO(const UniValue &o, std::string strKey)
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
static const uint32_t LOCKTIME_MAX
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
A mutable version of CTransaction.
std::vector< CTxOut > vout
std::vector< std::vector< unsigned char > > stack
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
const UniValue & find_value(const UniValue &obj, const std::string &name)
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