20 bool sign = amount < 0;
21 int64_t n_abs = (sign ? -amount : amount);
22 int64_t quotient = n_abs /
COIN;
23 int64_t remainder = n_abs %
COIN;
25 strprintf(
"%s%d.%08d", sign ?
"-" :
"", quotient, remainder));
33 while (it != script.end()) {
35 std::vector<unsigned char> vch;
36 if (script.
GetOp(it, op, vch)) {
45 if (str.substr(0, 3) == std::string(
"OP_")) {
46 ret += str.substr(3, std::string::npos) +
" ";
51 ret +=
strprintf(
"0x%x 0x%x ",
HexStr(std::vector<uint8_t>(it2, it - vch.size())),
52 HexStr(std::vector<uint8_t>(it - vch.size(),
it)));
58 ret +=
strprintf(
"0x%x ",
HexStr(std::vector<uint8_t>(it2, script.end())));
61 return ret.substr(0, ret.size() - 1);
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();
116 strSigHashDecode =
"[" +
it->second +
"]";
120 str +=
HexStr(vch) + strSigHashDecode;
144 std::vector<std::vector<unsigned char>> solns;
158 std::vector<CTxDestination> addresses;
170 out.
pushKV(
"reqSigs", nRequired);
177 out.
pushKV(
"addresses", a);
186 entry.
pushKV(
"version", static_cast<int64_t>(static_cast<uint32_t>(tx.
nVersion)));
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);
219 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
225 out.
pushKV(
"n", (int64_t)i);
229 out.
pushKV(
"scriptPubKey", o);
232 entry.
pushKV(
"vout", vout);
static int64_t GetTransactionWeight(const CTransaction &tx)
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.
static const int WITNESS_SCALE_FACTOR
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
static const CAmount COIN
std::string GetHex() const
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.
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 std::vector< CTxOut > vout
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack...
bool pushKV(const std::string &key, const UniValue &val)
An output of a transaction.
std::string FormatScript(const CScript &script)
const uint256 & GetWitnessHash() const
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.
Serialized script, used inside transaction inputs and outputs.
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 EncodeDestination(const CTxDestination &dest)
const uint256 & GetHash() const
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. ...
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
UniValue ValueFromAmount(const CAmount &amount)