21 bool sign = amount < 0;
22 int64_t n_abs = (sign ? -amount : amount);
23 int64_t quotient = n_abs / COIN;
24 int64_t remainder = n_abs % COIN;
26 strprintf(
"%s%d.%08d", sign ?
"-" :
"", quotient, remainder));
34 while (it != script.
end()) {
36 std::vector<unsigned char> vch;
37 if (script.
GetOp(it, op, vch)) {
46 if (str.substr(0, 3) == std::string(
"OP_")) {
47 ret += str.substr(3, std::string::npos) +
" ";
65 {
static_cast<unsigned char>(
SIGHASH_ALL), std::string(
"ALL")},
67 {
static_cast<unsigned char>(
SIGHASH_NONE), std::string(
"NONE")},
69 {
static_cast<unsigned char>(
SIGHASH_SINGLE), std::string(
"SINGLE")},
91 std::vector<unsigned char> vch;
93 while (pc < script.
end()) {
97 if (!script.
GetOp(pc, opcode, vch)) {
102 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
107 std::string strSigHashDecode;
113 const unsigned char chSigHashType = vch.back();
115 strSigHashDecode =
"[" +
mapSigHashTypes.find(chSigHashType)->second +
"]";
119 str +=
HexStr(vch) + strSigHashDecode;
143 std::vector<std::vector<unsigned char>> solns;
157 std::vector<CTxDestination> addresses;
169 out.
pushKV(
"reqSigs", nRequired);
176 out.
pushKV(
"addresses", a);
185 entry.
pushKV(
"vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
186 entry.
pushKV(
"weight", GetTransactionWeight(tx));
190 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
201 in.
pushKV(
"scriptSig", o);
202 if (!tx.
vin[i].scriptWitness.IsNull()) {
204 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
207 in.
pushKV(
"txinwitness", txinwitness);
216 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
222 out.
pushKV(
"n", (int64_t)i);
226 out.
pushKV(
"scriptPubKey", o);
229 entry.
pushKV(
"vout", vout);
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex, int serialize_flags)
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
UniValue ret(UniValue::VARR)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
txnouttype Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
Double ended buffer combining vector and stream-like interfaces.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
const std::vector< CTxIn > vin
size_t GetSerializeSize(const T &t, int nVersion=0)
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...
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
Parse a standard scriptPubKey with one or more destination addresses.
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)
An input of a transaction.
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
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
const char * GetTxnOutputType(txnouttype t)
Get the name of a txnouttype as a C string, or nullptr if unknown.
bool pushKV(const std::string &key, const UniValue &val)
An output of a transaction.
std::string FormatScript(const CScript &script)
const char * GetOpName(opcodetype opcode)
std::string SighashToStr(unsigned char sighash_type)
const_iterator end() const
const_iterator begin() const
Serialized script, used inside transaction inputs and outputs.
std::string GetHex() const
std::string EncodeDestination(const CTxDestination &dest)
The basic transaction that is broadcasted on the network and contained in blocks. ...
UniValue ValueFromAmount(const CAmount &amount)