Changeset View
Changeset View
Standalone View
Standalone View
src/core_write.cpp
Show All 10 Lines | |||||
#include "serialize.h" | #include "serialize.h" | ||||
#include "streams.h" | #include "streams.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include "utilmoneystr.h" | #include "utilmoneystr.h" | ||||
#include "utilstrencodings.h" | #include "utilstrencodings.h" | ||||
#include <univalue.h> | #include <univalue.h> | ||||
#include <boost/assign/list_of.hpp> | |||||
std::string FormatScript(const CScript &script) { | std::string FormatScript(const CScript &script) { | ||||
std::string ret; | std::string ret; | ||||
CScript::const_iterator it = script.begin(); | CScript::const_iterator it = script.begin(); | ||||
opcodetype op; | opcodetype op; | ||||
while (it != script.end()) { | while (it != script.end()) { | ||||
CScript::const_iterator it2 = it; | CScript::const_iterator it2 = it; | ||||
std::vector<uint8_t> vch; | std::vector<uint8_t> vch; | ||||
if (script.GetOp2(it, op, &vch)) { | if (script.GetOp2(it, op, &vch)) { | ||||
Show All 27 Lines | while (it != script.end()) { | ||||
ret += strprintf("0x%x ", HexStr(it2, script.end())); | ret += strprintf("0x%x ", HexStr(it2, script.end())); | ||||
break; | break; | ||||
} | } | ||||
return ret.substr(0, ret.size() - 1); | return ret.substr(0, ret.size() - 1); | ||||
} | } | ||||
const std::map<uint8_t, std::string> mapSigHashTypes = | const std::map<uint8_t, std::string> mapSigHashTypes = { | ||||
boost::assign::map_list_of(static_cast<uint8_t>(SIGHASH_ALL), | {SIGHASH_ALL, "ALL"}, | ||||
std::string("ALL"))( | {SIGHASH_ALL | SIGHASH_ANYONECANPAY, "ALL|ANYONECANPAY"}, | ||||
static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_ANYONECANPAY), | {SIGHASH_ALL | SIGHASH_FORKID, "ALL|FORKID"}, | ||||
std::string("ALL|ANYONECANPAY"))( | {SIGHASH_ALL | SIGHASH_FORKID | SIGHASH_ANYONECANPAY, | ||||
static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_FORKID), | "ALL|FORKID|ANYONECANPAY"}, | ||||
std::string("ALL|FORKID"))(static_cast<uint8_t>(SIGHASH_ALL | | {SIGHASH_NONE, "NONE"}, | ||||
SIGHASH_FORKID | | {SIGHASH_NONE | SIGHASH_ANYONECANPAY, "NONE|ANYONECANPAY"}, | ||||
SIGHASH_ANYONECANPAY), | {SIGHASH_NONE | SIGHASH_FORKID, "NONE|FORKID"}, | ||||
std::string("ALL|FORKID|ANYONECANPAY"))( | {SIGHASH_NONE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY, | ||||
static_cast<uint8_t>(SIGHASH_NONE), std::string("NONE"))( | "NONE|FORKID|ANYONECANPAY"}, | ||||
static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_ANYONECANPAY), | {SIGHASH_SINGLE, "SINGLE"}, | ||||
std::string("NONE|ANYONECANPAY"))( | {SIGHASH_SINGLE | SIGHASH_ANYONECANPAY, "SINGLE|ANYONECANPAY"}, | ||||
static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_FORKID), | {SIGHASH_SINGLE | SIGHASH_FORKID, "SINGLE|FORKID"}, | ||||
std::string("NONE|FORKID"))(static_cast<uint8_t>(SIGHASH_NONE | | {SIGHASH_SINGLE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY, | ||||
SIGHASH_FORKID | | "SINGLE|FORKID|ANYONECANPAY"}, | ||||
SIGHASH_ANYONECANPAY), | }; | ||||
std::string("NONE|FORKID|ANYONECANPAY"))( | |||||
static_cast<uint8_t>(SIGHASH_SINGLE), std::string("SINGLE"))( | |||||
static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_ANYONECANPAY), | |||||
std::string("SINGLE|ANYONECANPAY"))( | |||||
static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_FORKID), | |||||
std::string("SINGLE|FORKID"))( | |||||
static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_FORKID | | |||||
SIGHASH_ANYONECANPAY), | |||||
std::string("SINGLE|FORKID|ANYONECANPAY")); | |||||
/** | /** | ||||
* Create the assembly string representation of a CScript object. | * Create the assembly string representation of a CScript object. | ||||
* @param[in] script CScript object to convert into the asm string | * @param[in] script CScript object to convert into the asm string | ||||
* representation. | * representation. | ||||
* @param[in] fAttemptSighashDecode Whether to attempt to decode sighash | * @param[in] fAttemptSighashDecode Whether to attempt to decode sighash | ||||
* types on data within the script that matches the format of a signature. Only | * types on data within the script that matches the format of a signature. Only | ||||
* pass true for scripts you believe could contain signatures. For example, pass | * pass true for scripts you believe could contain signatures. For example, pass | ||||
▲ Show 20 Lines • Show All 154 Lines • Show Last 20 Lines |