22 static_assert(
COIN > 1);
23 int64_t quotient = amount /
COIN;
24 int64_t remainder = amount %
COIN;
27 remainder = -remainder;
30 strprintf(
"%s%d.%08d", amount < 0 ?
"-" :
"", quotient, remainder));
38 while (it != script.
end()) {
40 std::vector<unsigned char> vch;
41 if (script.
GetOp(it, op, vch)) {
50 if (str.substr(0, 3) == std::string(
"OP_")) {
51 ret += str.substr(3, std::string::npos) +
" ";
56 ret +=
strprintf(
"0x%x 0x%x ",
HexStr(std::vector<uint8_t>(it2, it - vch.size())),
57 HexStr(std::vector<uint8_t>(it - vch.size(), it)));
66 return ret.substr(0, ret.size() - 1);
70 {
static_cast<unsigned char>(
SIGHASH_ALL), std::string(
"ALL")},
72 {
static_cast<unsigned char>(
SIGHASH_NONE), std::string(
"NONE")},
74 {
static_cast<unsigned char>(
SIGHASH_SINGLE), std::string(
"SINGLE")},
96 std::vector<unsigned char> vch;
98 while (pc < script.
end()) {
102 if (!script.
GetOp(pc, opcode, vch)) {
107 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
112 std::string strSigHashDecode;
118 const unsigned char chSigHashType = vch.back();
121 strSigHashDecode =
"[" + it->second +
"]";
125 str +=
HexStr(vch) + strSigHashDecode;
149 std::vector<std::vector<unsigned char>> solns;
162 UniValue& out,
bool fIncludeHex,
bool include_addresses)
166 std::vector<CTxDestination> addresses;
183 if (include_addresses) {
188 out.
pushKV(
"addresses", a);
189 out.
pushKV(
"reqSigs", nRequired);
199 entry.
pushKV(
"version", static_cast<int64_t>(static_cast<uint32_t>(tx.
nVersion)));
209 const bool calculate_fee = txundo !=
nullptr;
213 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
224 in.
pushKV(
"scriptSig", o);
226 if (!tx.
vin[i].scriptWitness.IsNull()) {
228 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
231 in.
pushKV(
"txinwitness", txinwitness);
235 amt_total_in += prev_txout.
nValue;
243 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
249 out.
pushKV(
"n", (int64_t)i);
253 out.
pushKV(
"scriptPubKey", o);
257 amt_total_out += txout.
nValue;
260 entry.
pushKV(
"vout", vout);
263 const CAmount fee = amt_total_in - amt_total_out;
static int64_t GetTransactionWeight(const CTransaction &tx)
std::vector< Coin > vprevout
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
static const int WITNESS_SCALE_FACTOR
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
static const CAmount COIN
UniValue ValueFromAmount(const CAmount amount)
bool MoneyRange(const CAmount &nValue)
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
Double ended buffer combining vector and stream-like interfaces.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
const std::vector< CTxIn > vin
size_t GetSerializeSize(const T &t, int nVersion=0)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex, bool include_addresses)
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
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)
opcodetype
Script opcodes.
bool push_back(const UniValue &val)
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
An input of a transaction.
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
const uint256 & GetWitnessHash() const
const uint256 & GetHash() const
const std::vector< CTxOut > vout
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool pushKV(const std::string &key, const UniValue &val)
An output of a transaction.
std::string FormatScript(const CScript &script)
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string SighashToStr(unsigned char sighash_type)
bool ExtractDestinations(const CScript &scriptPubKey, TxoutType &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, bool include_addresses, UniValue &entry, bool include_hex, int serialize_flags, const CTxUndo *txundo)
Serialized script, used inside transaction inputs and outputs.
Undo information for a CTransaction.
static const int PROTOCOL_VERSION
network protocol versioning
std::string GetOpName(opcodetype opcode)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::string GetHex() const
std::string EncodeDestination(const CTxDestination &dest)
The basic transaction that is broadcasted on the network and contained in blocks. ...