18 #include <boost/assign/list_of.hpp>
19 #include <boost/foreach.hpp>
26 while (it != script.
end()) {
28 std::vector<unsigned char> vch;
29 if (script.
GetOp2(it, op, &vch)) {
38 if (str.substr(0, 3) == std::string(
"OP_")) {
39 ret += str.substr(3, std::string::npos) +
" ";
53 return ret.substr(0, ret.size() - 1);
57 boost::assign::map_list_of
58 (
static_cast<unsigned char>(
SIGHASH_ALL), std::string(
"ALL"))
60 (
static_cast<unsigned char>(
SIGHASH_NONE), std::string(
"NONE"))
62 (
static_cast<unsigned char>(
SIGHASH_SINGLE), std::string(
"SINGLE"))
77 std::vector<unsigned char> vch;
79 while (pc < script.
end()) {
83 if (!script.
GetOp(pc, opcode, vch)) {
88 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
93 std::string strSigHashDecode;
99 const unsigned char chSigHashType = vch.back();
101 strSigHashDecode =
"[" +
mapSigHashTypes.find(chSigHashType)->second +
"]";
105 str +=
HexStr(vch) + strSigHashDecode;
128 std::vector<CTxDestination> addresses;
140 out.
pushKV(
"reqSigs", nRequired);
146 out.
pushKV(
"addresses", a);
157 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
168 in.
pushKV(
"scriptSig", o);
169 if (!tx.
vin[i].scriptWitness.IsNull()) {
171 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
174 in.
pushKV(
"txinwitness", txinwitness);
183 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
189 out.
pushKV(
"value", outValue);
190 out.
pushKV(
"n", (int64_t)i);
194 out.
pushKV(
"scriptPubKey", o);
197 entry.
pushKV(
"vout", vout);
base58-encoded Bitcoin addresses.
Double ended buffer combining vector and stream-like interfaces.
const_iterator begin() const
const_iterator end() const
Serialized script, used inside transaction inputs and outputs.
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
bool GetOp(iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet)
bool GetOp2(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > *pvchRet) const
The basic transaction that is broadcasted on the network and contained in blocks.
const std::vector< CTxOut > vout
const uint256 & GetHash() const
uint256 GetWitnessHash() const
const std::vector< CTxIn > vin
An input of a transaction.
An output of a transaction.
bool push_back(const UniValue &val)
bool pushKV(const std::string &key, const UniValue &val)
std::string GetHex() const
std::string FormatScript(const CScript &script)
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex)
std::string EncodeHexTx(const CTransaction &tx, const int serialFlags)
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
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry)
bool CheckSignatureEncoding(const vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
@ SCRIPT_VERIFY_STRICTENC
const char * GetOpName(opcodetype opcode)
opcodetype
Script opcodes.
bool ExtractDestinations(const CScript &scriptPubKey, txnouttype &typeRet, vector< CTxDestination > &addressRet, int &nRequiredRet)
const char * GetTxnOutputType(txnouttype t)
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)