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.
GetOp2(it, op, &vch)) {
46 if (str.substr(0, 3) == std::string(
"OP_")) {
47 ret += str.substr(3, std::string::npos) +
" ";
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")},
84 std::vector<unsigned char> vch;
86 while (pc < script.
end()) {
90 if (!script.
GetOp(pc, opcode, vch)) {
95 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
100 std::string strSigHashDecode;
106 const unsigned char chSigHashType = vch.back();
108 strSigHashDecode =
"[" +
mapSigHashTypes.find(chSigHashType)->second +
"]";
112 str +=
HexStr(vch) + strSigHashDecode;
135 std::vector<CTxDestination> addresses;
147 out.
pushKV(
"reqSigs", nRequired);
153 out.
pushKV(
"addresses", a);
166 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
177 in.
pushKV(
"scriptSig", o);
178 if (!tx.
vin[i].scriptWitness.IsNull()) {
180 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
183 in.
pushKV(
"txinwitness", txinwitness);
192 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
198 out.
pushKV(
"n", (int64_t)i);
202 out.
pushKV(
"scriptPubKey", o);
205 entry.
pushKV(
"vout", vout);
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex, int serialize_flags)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
bool GetOp2(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet) const
int64_t GetTransactionWeight(const CTransaction &tx)
const_iterator begin() const
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
uint256 GetWitnessHash() const
size_t GetSerializeSize(const T &t, int nType, int nVersion=0)
std::string GetHex() const
base58-encoded Fabcoin addresses.
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Double ended buffer combining vector and stream-like interfaces.
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
const std::vector< CTxIn > vin
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, std::vector< CTxDestination > &addressRet, int &nRequiredRet)
const std::map< unsigned char, std::string > mapSigHashTypes
int64_t CAmount
Amount in lius (Can be negative)
opcodetype
Script opcodes.
bool push_back(const UniValue &val)
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...
const char * GetTxnOutputType(txnouttype t)
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)
Signature sign(Secret const &_k, h256 const &_hash)
Returns siganture of message hash.
PlatformStyle::TableColorType type
Serialized script, used inside transaction inputs and outputs.
const uint256 & GetHash() const
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
The basic transaction that is broadcasted on the network and contained in blocks. ...
UniValue ValueFromAmount(const CAmount &amount)
const_iterator end() const