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)) {
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;
179 entry.
pushKV(
"version", static_cast<int64_t>(static_cast<uint32_t>(tx.
nVersion)));
189 const bool have_undo = txundo !=
nullptr;
193 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
204 in.
pushKV(
"scriptSig", o);
206 if (!tx.
vin[i].scriptWitness.IsNull()) {
208 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
211 in.
pushKV(
"txinwitness", txinwitness);
215 const CTxOut& prev_txout = prev_coin.
out;
217 amt_total_in += prev_txout.
nValue;
227 p.
pushKV(
"scriptPubKey", o_script_pub_key);
237 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
243 out.pushKV(
"n", (int64_t)i);
247 out.pushKV(
"scriptPubKey", o);
251 amt_total_out += txout.
nValue;
254 entry.
pushKV(
"vout", vout);
257 const CAmount fee = amt_total_in - amt_total_out;
262 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
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
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)
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack...
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 ...
std::string ToString(const T &t)
Locale-independent version of std::to_string.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a scriptPubKey for the destination.
Include TXID, inputs, outputs, and other common block's transaction information.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
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::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
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::string GetHex() const
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
const Txid & GetHash() const LIFETIMEBOUND
static constexpr TransactionSerParams TX_WITH_WITNESS
static constexpr CAmount COIN
The amount of satoshis in one BTC.