24 bool sign = amount < 0;
25 int64_t n_abs = (sign ? -amount : amount);
26 int64_t quotient = n_abs / COIN;
27 int64_t remainder = n_abs % COIN;
28 remainder = remainder / pow(10, 8 - units);
30 if (units == 0 && remainder == 0) {
31 return strprintf(
"%s%d", sign ?
"-" :
"", quotient);
34 return strprintf(
"%s%d.%0" + std::to_string(units) +
"d", sign ?
"-" :
"", quotient, remainder);
53 while (it != script.
end()) {
55 std::vector<unsigned char> vch;
56 if (script.
GetOp2(it, op, &vch)) {
65 if (str.substr(0, 3) == std::string(
"OP_")) {
66 ret += str.substr(3, std::string::npos) +
" ";
80 return ret.substr(0, ret.size() - 1);
84 {
static_cast<unsigned char>(
SIGHASH_ALL), std::string(
"ALL")},
86 {
static_cast<unsigned char>(
SIGHASH_NONE), std::string(
"NONE")},
88 {
static_cast<unsigned char>(
SIGHASH_SINGLE), std::string(
"SINGLE")},
103 std::vector<unsigned char> vch;
105 while (pc < script.
end()) {
109 if (!script.
GetOp(pc, opcode, vch)) {
114 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
119 std::string strSigHashDecode;
125 const unsigned char chSigHashType = vch.back();
127 strSigHashDecode =
"[" +
mapSigHashTypes.find(chSigHashType)->second +
"]";
131 str +=
HexStr(vch) + strSigHashDecode;
154 std::vector<CTxDestination> addresses;
166 out.
pushKV(
"reqSigs", nRequired);
175 std::string _assetAddress;
178 assetInfo.
pushKV(
"name", name);
213 out.
pushKV(
"asset", assetInfo);
226 assetInfo.
pushKV(
"qualifier_type", data.
flag ?
"adding qualifier" :
"removing qualifier");
227 assetInfo.
pushKV(
"address", address);
230 assetInfo.
pushKV(
"restricted_type", data.
flag ?
"freezing address" :
"unfreezing address");
231 assetInfo.
pushKV(
"address", address);
235 assetInfo.
pushKV(
"restricted_type", data.
flag ?
"freezing" :
"unfreezing");
236 assetInfo.
pushKV(
"address",
"all addresses");
241 out.
pushKV(
"asset_data", assetInfo);
249 out.
pushKV(
"addresses", a);
258 entry.
pushKV(
"vsize", (GetTransactionWeight(tx) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR);
262 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
273 in.
pushKV(
"scriptSig", o);
274 if (!tx.
vin[i].scriptWitness.IsNull()) {
276 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
279 in.
pushKV(
"txinwitness", txinwitness);
288 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
294 out.
pushKV(
"n", (int64_t)i);
298 out.
pushKV(
"scriptPubKey", o);
301 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.
uint256 GetWitnessHash() const
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
UniValue ValueFromAmount(const CAmount &amount, const int8_t units)
size_t GetSerializeSize(const T &t, int nType, int nVersion=0)
bool AssetFromScript(const CScript &scriptPubKey, CNewAsset &assetNew, std::string &strAddress)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Double ended buffer combining vector and stream-like interfaces.
bool AssetNullDataFromScript(const CScript &scriptPubKey, CNullAssetTxData &assetData, std::string &strAddress)
std::string ValueFromAmountString(const CAmount &amount, const int8_t units)
bool ReissueAssetFromScript(const CScript &scriptPubKey, CReissueAsset &reissue, std::string &strAddress)
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 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 corbies (Can be negative)
bool GlobalAssetNullDataFromScript(const CScript &scriptPubKey, CNullAssetTxData &assetData)
bool IsAssetNameValid(const std::string &name, AssetType &assetType, std::string &error)
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 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 GetAssetInfoFromScript(const CScript &scriptPubKey, std::string &strName, CAmount &nAmount)
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)
const_iterator end() const
std::string EncodeDestination(const CTxDestination &dest)
const_iterator begin() const
Serialized script, used inside transaction inputs and outputs.
std::string verifier_string
std::string GetHex() const
bool AssetNullVerifierDataFromScript(const CScript &scriptPubKey, CNullAssetTxVerifierString &verifierData)
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
The basic transaction that is broadcasted on the network and contained in blocks. ...
std::string EncodeAssetData(std::string decoded)
unspendable OP_RAVEN_ASSET script that carries data
bool IsAssetNameAnOwner(const std::string &name)
Check if an asset is an owner.
bool GetOp2(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet) const