28 while (it != script.end()) {
30 std::vector<uint8_t> vch;
31 if (script.GetOp(it, op, vch)) {
44 if (str.substr(0, 3) == std::string(
"OP_")) {
45 ret += str.substr(3, std::string::npos) +
" ";
53 HexStr(std::vector<uint8_t>(it2, it - vch.size())),
54 HexStr(std::vector<uint8_t>(it - vch.size(), it)));
68 return ret.substr(0, ret.size() - 1);
76 "ALL|FORKID|ANYONECANPAY"},
81 "NONE|FORKID|ANYONECANPAY"},
86 "SINGLE|FORKID|ANYONECANPAY"},
107 const bool fAttemptSighashDecode) {
110 std::vector<uint8_t> vch;
112 while (pc < script.end()) {
117 if (!script.GetOp(pc, opcode, vch)) {
132 if (fAttemptSighashDecode && !script.IsUnspendable()) {
133 std::string strSigHashDecode;
150 const uint8_t chSigHashType = vch.back();
153 strSigHashDecode =
"[" + it->second +
"]";
160 str +=
HexStr(vch) + strSigHashDecode;
183 std::vector<std::vector<uint8_t>> solns;
197 std::vector<CTxDestination> addresses;
211 out.
pushKV(
"reqSigs", nRequired);
218 out.
pushKV(
"addresses", a);
223 entry.
pushKV(
"txid", tx.GetId().GetHex());
224 entry.
pushKV(
"hash", tx.GetHash().GetHex());
228 static_cast<int64_t
>(
static_cast<uint32_t
>(tx.nVersion)));
230 entry.
pushKV(
"locktime", (int64_t)tx.nLockTime);
237 const bool calculate_fee = txundo !=
nullptr;
241 for (
unsigned int i = 0; i < tx.vin.size(); i++) {
242 const CTxIn &txin = tx.vin[i];
244 if (tx.IsCoinBase()) {
247 in.
pushKV(
"txid", txin.prevout.GetTxId().GetHex());
248 in.
pushKV(
"vout", int64_t(txin.prevout.GetN()));
252 in.
pushKV(
"scriptSig", o);
256 amt_total_in += prev_txout.
nValue;
258 in.
pushKV(
"sequence", (int64_t)txin.nSequence);
265 for (
unsigned int i = 0; i < tx.vout.size(); i++) {
266 const CTxOut &txout = tx.vout[i];
271 out.
pushKV(
"n", int64_t(i));
275 out.
pushKV(
"scriptPubKey", o);
279 amt_total_out += txout.
nValue;
283 entry.
pushKV(
"vout", vout);
286 const Amount fee = amt_total_in - amt_total_out;
291 if (!hashBlock.
IsNull()) {
bool MoneyRange(const Amount nValue)
#define CHECK_NONFATAL(condition)
Identity function.
static bool IsMinimallyEncoded(const std::vector< uint8_t > &vch, const size_t nMaxNumSize)
An output of a transaction.
Restore the UTXO in a Coin at a given COutPoint.
std::vector< Coin > vprevout
Double ended buffer combining vector and stream-like interfaces.
void push_back(UniValue val)
void pushKV(std::string key, UniValue val)
std::string GetHex() const
const Config & GetConfig()
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
std::string EncodeHexTx(const CTransaction &tx)
std::string SighashToStr(uint8_t sighash_type)
std::string FormatScript(const CScript &script)
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex, const CTxUndo *txundo)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
const std::map< uint8_t, std::string > mapSigHashTypes
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
std::string GetOpName(opcodetype opcode)
opcodetype
Script opcodes.
@ FIRST_UNDEFINED_OP_VALUE
constexpr size_t MAX_SCRIPTNUM_BYTE_SIZE
@ SCRIPT_VERIFY_STRICTENC
@ SCRIPT_ENABLE_SIGHASH_FORKID
size_t GetSerializeSize(const T &t, int nVersion=0)
bool CheckTransactionSignatureEncoding(const valtype &vchSig, uint32_t flags, ScriptError *serror)
Check that the signature provided to authentify a transaction is properly encoded.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
bool ExtractDestinations(const CScript &scriptPubKey, TxoutType &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
static constexpr Amount zero() noexcept
A BlockHash is a unqiue identifier for a block.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
static const int PROTOCOL_VERSION
network protocol versioning