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)) {
123 if (vch.size() <=
static_cast<std::vector<uint8_t>::size_type
>(4)) {
128 if (fAttemptSighashDecode && !script.IsUnspendable()) {
129 std::string strSigHashDecode;
146 const uint8_t chSigHashType = vch.back();
149 strSigHashDecode =
"[" + it->second +
"]";
156 str +=
HexStr(vch) + strSigHashDecode;
169std::string
EncodeHexTx(
const CTransaction &tx,
const int serializeFlags) {
179 std::vector<std::vector<uint8_t>> solns;
193 std::vector<CTxDestination> addresses;
207 out.
pushKV(
"reqSigs", nRequired);
214 out.
pushKV(
"addresses", a);
218 UniValue &entry,
bool include_hex,
int serialize_flags,
220 entry.
pushKV(
"txid", tx.GetId().GetHex());
221 entry.
pushKV(
"hash", tx.GetHash().GetHex());
225 static_cast<int64_t
>(
static_cast<uint32_t
>(tx.nVersion)));
227 entry.
pushKV(
"locktime", (int64_t)tx.nLockTime);
234 const bool calculate_fee = txundo !=
nullptr;
238 for (
unsigned int i = 0; i < tx.vin.size(); i++) {
239 const CTxIn &txin = tx.vin[i];
241 if (tx.IsCoinBase()) {
244 in.
pushKV(
"txid", txin.prevout.GetTxId().GetHex());
245 in.
pushKV(
"vout", int64_t(txin.prevout.GetN()));
249 in.
pushKV(
"scriptSig", o);
253 amt_total_in += prev_txout.
nValue;
255 in.
pushKV(
"sequence", (int64_t)txin.nSequence);
262 for (
unsigned int i = 0; i < tx.vout.size(); i++) {
263 const CTxOut &txout = tx.vout[i];
268 out.
pushKV(
"n", int64_t(i));
272 out.
pushKV(
"scriptPubKey", o);
276 amt_total_out += txout.
nValue;
280 entry.
pushKV(
"vout", vout);
283 const Amount fee = amt_total_in - amt_total_out;
288 if (!hashBlock.
IsNull()) {
bool MoneyRange(const Amount nValue)
#define CHECK_NONFATAL(condition)
Identity function.
Double ended buffer combining vector and stream-like interfaces.
An output of a transaction.
Restore the UTXO in a Coin at a given COutPoint.
std::vector< Coin > vprevout
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 SighashToStr(uint8_t sighash_type)
std::string FormatScript(const CScript &script)
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.
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex, int serialize_flags, const CTxUndo *txundo)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
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
@ 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