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()) {
std::string GetHex() const
void push_back(UniValue val)
std::vector< Coin > vprevout
The same as previous option with information about prevouts if available.
static const int WITNESS_SCALE_FACTOR
TxVerbosity
Verbose level for block's transaction.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
UniValue ValueFromAmount(const CAmount amount)
bool MoneyRange(const CAmount &nValue)
#define CHECK_NONFATAL(condition)
Identity function.
CTxOut out
unspent transaction output
unsigned int fCoinBase
whether containing transaction was a coinbase
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex, const CTxUndo *txundo, TxVerbosity verbosity)
static int32_t GetTransactionWeight(const CTransaction &tx)
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible...
const std::vector< CTxIn > vin
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
std::string EncodeHexTx(const CTransaction &tx)
const std::map< unsigned char, std::string > mapSigHashTypes
int64_t CAmount
Amount in satoshis (Can be negative)
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
Include TXID, inputs, outputs, and other common block's transaction information.
An input of a transaction.
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
Double ended buffer combining vector and stream-like interfaces.
const SigningProvider & DUMMY_SIGNING_PROVIDER
opcodetype
Script opcodes.
const std::vector< CTxOut > vout
An output of a transaction.
std::string FormatScript(const CScript &script)
constexpr bool IsNull() const
std::string SighashToStr(unsigned char sighash_type)
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
An interface to be implemented by keystores that support signing.
std::string GetOpName(opcodetype opcode)
void pushKV(std::string key, UniValue val)
Serialized script, used inside transaction inputs and outputs.
Undo information for a CTransaction.
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
std::string GetHex() const
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeDestination(const CTxDestination &dest)
unsigned int GetTotalSize() const
Get the total transaction size in bytes, including witness data.
The basic transaction that is broadcasted on the network and contained in blocks. ...
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex, bool include_address, const SigningProvider *provider)
const Wtxid & GetWitnessHash() const LIFETIMEBOUND
std::string ToString(const T &t)
Locale-independent version of std::to_string.
const Txid & GetHash() const LIFETIMEBOUND
static constexpr TransactionSerParams TX_WITH_WITNESS
static constexpr CAmount COIN
The amount of satoshis in one BTC.