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), | {static_cast<uint8_t>(SIGHASH_ALL), std::string("ALL")}, | ||||
deadalnix: Use C++ style constructor.
uint8_t(SIGHASH)
It'll be much more readable. | |||||
CCulianuAuthorUnsubmitted Not Done Inline ActionsYeah, that will look better. Good point. Will-do. CCulianu: Yeah, that will look better. Good point. Will-do. | |||||
deadalnixUnsubmitted Not Done Inline ActionsNice, it doesn't looks like it is necessary at all. deadalnix: Nice, it doesn't looks like it is necessary at all. | |||||
std::string("ALL"))( | {static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_ANYONECANPAY), | ||||
static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_ANYONECANPAY), | std::string("ALL|ANYONECANPAY")}, | ||||
std::string("ALL|ANYONECANPAY"))( | {static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_FORKID), | ||||
static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_FORKID), | std::string("ALL|FORKID")}, | ||||
std::string("ALL|FORKID"))(static_cast<uint8_t>(SIGHASH_ALL | | {static_cast<uint8_t>(SIGHASH_ALL | SIGHASH_FORKID | SIGHASH_ANYONECANPAY), | ||||
SIGHASH_FORKID | | std::string("ALL|FORKID|ANYONECANPAY")}, | ||||
SIGHASH_ANYONECANPAY), | {static_cast<uint8_t>(SIGHASH_NONE), std::string("NONE")}, | ||||
std::string("ALL|FORKID|ANYONECANPAY"))( | {static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_ANYONECANPAY), | ||||
static_cast<uint8_t>(SIGHASH_NONE), std::string("NONE"))( | std::string("NONE|ANYONECANPAY")}, | ||||
static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_ANYONECANPAY), | {static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_FORKID), | ||||
std::string("NONE|ANYONECANPAY"))( | std::string("NONE|FORKID")}, | ||||
static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_FORKID), | {static_cast<uint8_t>(SIGHASH_NONE | SIGHASH_FORKID | SIGHASH_ANYONECANPAY), | ||||
std::string("NONE|FORKID"))(static_cast<uint8_t>(SIGHASH_NONE | | std::string("NONE|FORKID|ANYONECANPAY")}, | ||||
SIGHASH_FORKID | | {static_cast<uint8_t>(SIGHASH_SINGLE), std::string("SINGLE")}, | ||||
SIGHASH_ANYONECANPAY), | {static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_ANYONECANPAY), | ||||
std::string("NONE|FORKID|ANYONECANPAY"))( | std::string("SINGLE|ANYONECANPAY")}, | ||||
static_cast<uint8_t>(SIGHASH_SINGLE), std::string("SINGLE"))( | {static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_FORKID), | ||||
static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_ANYONECANPAY), | std::string("SINGLE|FORKID")}, | ||||
std::string("SINGLE|ANYONECANPAY"))( | {static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_FORKID | | ||||
static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_FORKID), | |||||
std::string("SINGLE|FORKID"))( | |||||
static_cast<uint8_t>(SIGHASH_SINGLE | SIGHASH_FORKID | | |||||
SIGHASH_ANYONECANPAY), | SIGHASH_ANYONECANPAY), | ||||
std::string("SINGLE|FORKID|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 |
Use C++ style constructor.
It'll be much more readable.