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()) {
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.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const uint256 & GetHash() const
const std::vector< CTxIn > vin
const uint256 & GetWitnessHash() const
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
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
static int64_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 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)
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex, int serialize_flags, const CTxUndo *txundo, TxVerbosity verbosity)
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 int serializeFlags)
const std::map< unsigned char, std::string > mapSigHashTypes
UniValue ValueFromAmount(const CAmount amount)
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
@ SCRIPT_VERIFY_STRICTENC
std::string EncodeDestination(const CTxDestination &dest)
std::string GetOpName(opcodetype opcode)
opcodetype
Script opcodes.
size_t GetSerializeSize(const T &t, int nVersion=0)
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.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
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