28 static_assert(
COIN > 1);
29 int64_t quotient = amount /
COIN;
30 int64_t remainder = amount %
COIN;
33 remainder = -remainder;
36 strprintf(
"%s%d.%08d", amount < 0 ?
"-" :
"", quotient, remainder));
44 while (it !=
script.end()) {
46 std::vector<unsigned char> vch;
47 if (
script.GetOp(it, op, vch)) {
56 if (str.substr(0, 3) == std::string(
"OP_")) {
57 ret += str.substr(3, std::string::npos) +
" ";
63 HexStr(std::vector<uint8_t>(it - vch.size(), it)));
72 return ret.substr(0,
ret.empty() ?
ret.npos :
ret.size() - 1);
76 {
static_cast<unsigned char>(
SIGHASH_ALL), std::string(
"ALL")},
78 {
static_cast<unsigned char>(
SIGHASH_NONE), std::string(
"NONE")},
80 {
static_cast<unsigned char>(
SIGHASH_SINGLE), std::string(
"SINGLE")},
102 std::vector<unsigned char> vch;
104 while (pc <
script.end()) {
108 if (!
script.GetOp(pc, opcode, vch)) {
113 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
117 if (fAttemptSighashDecode && !
script.IsUnspendable()) {
118 std::string strSigHashDecode;
124 const unsigned char chSigHashType = vch.back();
127 strSigHashDecode =
"[" + it->second +
"]";
131 str +=
HexStr(vch) + strSigHashDecode;
155 if (include_address) {
162 std::vector<std::vector<unsigned char>> solns;
187 const bool have_undo = txundo !=
nullptr;
191 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
202 in.
pushKV(
"scriptSig", std::move(o));
204 if (!tx.
vin[i].scriptWitness.IsNull()) {
206 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
209 in.
pushKV(
"txinwitness", std::move(txinwitness));
213 const CTxOut& prev_txout = prev_coin.
out;
215 amt_total_in += prev_txout.
nValue;
225 p.
pushKV(
"scriptPubKey", std::move(o_script_pub_key));
226 in.
pushKV(
"prevout", std::move(p));
230 vin.push_back(std::move(in));
232 entry.
pushKV(
"vin", std::move(vin));
235 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
241 out.pushKV(
"n", (int64_t)i);
245 out.pushKV(
"scriptPubKey", std::move(o));
249 amt_total_out += txout.
nValue;
252 entry.
pushKV(
"vout", std::move(vout));
255 const CAmount fee = amt_total_in - amt_total_out;
260 if (!block_hash.
IsNull()) {
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
bool MoneyRange(const CAmount &nValue)
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr CAmount COIN
The amount of satoshis in one BTC.
#define CHECK_NONFATAL(condition)
Identity function.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const Wtxid & GetWitnessHash() const LIFETIMEBOUND
unsigned int GetTotalSize() const
Get the total transaction size in bytes, including witness data.
const Txid & GetHash() const LIFETIMEBOUND
const std::vector< CTxIn > vin
An input of a transaction.
An output of a transaction.
Undo information for a CTransaction.
std::vector< Coin > vprevout
CTxOut out
unspent transaction output
uint32_t nHeight
at which height this containing transaction was included in the active block chain
unsigned int fCoinBase
whether containing transaction was a coinbase
Double ended buffer combining vector and stream-like interfaces.
An interface to be implemented by keystores that support signing.
void push_back(UniValue val)
void pushKV(std::string key, UniValue val)
constexpr bool IsNull() const
std::string GetHex() const
std::string GetHex() const
static int32_t GetTransactionWeight(const CTransaction &tx)
static const int WITNESS_SCALE_FACTOR
TxVerbosity
Verbose level for block's transaction.
@ SHOW_DETAILS_AND_PREVOUT
The same as previous option with information about prevouts if available.
@ SHOW_DETAILS
Include TXID, inputs, outputs, and other common block's transaction information.
std::string EncodeHexTx(const CTransaction &tx)
std::string SighashToStr(unsigned char sighash_type)
std::string FormatScript(const CScript &script)
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex, bool include_address, const SigningProvider *provider)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
const std::map< unsigned char, std::string > mapSigHashTypes
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex, const CTxUndo *txundo, TxVerbosity verbosity)
UniValue ValueFromAmount(const CAmount amount)
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
@ SCRIPT_VERIFY_STRICTENC
std::string EncodeDestination(const CTxDestination &dest)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static constexpr TransactionSerParams TX_WITH_WITNESS
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
std::string GetOpName(opcodetype opcode)
opcodetype
Script opcodes.
const SigningProvider & DUMMY_SIGNING_PROVIDER
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char > > &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.