 |
Bitcoin Core
22.99.0
P2P Digital Currency
|
Go to the documentation of this file.
24 static_assert(
COIN > 1);
25 int64_t quotient = amount /
COIN;
26 int64_t remainder = amount %
COIN;
29 remainder = -remainder;
32 strprintf(
"%s%d.%08d", amount < 0 ?
"-" :
"", quotient, remainder));
40 while (it != script.
end()) {
42 std::vector<unsigned char> vch;
43 if (script.
GetOp(it, op, vch)) {
52 if (str.substr(0, 3) == std::string(
"OP_")) {
53 ret += str.substr(3, std::string::npos) +
" ";
58 ret +=
strprintf(
"0x%x 0x%x ",
HexStr(std::vector<uint8_t>(it2, it - vch.size())),
59 HexStr(std::vector<uint8_t>(it - vch.size(), it)));
68 return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
72 {
static_cast<unsigned char>(
SIGHASH_ALL), std::string(
"ALL")},
74 {
static_cast<unsigned char>(
SIGHASH_NONE), std::string(
"NONE")},
76 {
static_cast<unsigned char>(
SIGHASH_SINGLE), std::string(
"SINGLE")},
98 std::vector<unsigned char> vch;
100 while (pc < script.
end()) {
104 if (!script.
GetOp(pc, opcode, vch)) {
109 if (vch.size() <=
static_cast<std::vector<unsigned char>::size_type
>(4)) {
114 std::string strSigHashDecode;
120 const unsigned char chSigHashType = vch.back();
123 strSigHashDecode =
"[" + it->second +
"]";
127 str +=
HexStr(vch) + strSigHashDecode;
157 if (include_hex) out.
pushKV(
"hex",
HexStr(scriptPubKey));
159 std::vector<std::vector<unsigned char>> solns;
174 entry.
pushKV(
"version",
static_cast<int64_t
>(
static_cast<uint32_t
>(tx.
nVersion)));
184 const bool have_undo = txundo !=
nullptr;
188 for (
unsigned int i = 0; i < tx.
vin.size(); i++) {
199 in.
pushKV(
"scriptSig", o);
201 if (!tx.
vin[i].scriptWitness.IsNull()) {
203 for (
const auto& item : tx.
vin[i].scriptWitness.stack) {
206 in.
pushKV(
"txinwitness", txinwitness);
210 const CTxOut& prev_txout = prev_coin.
out;
212 amt_total_in += prev_txout.
nValue;
222 p.
pushKV(
"scriptPubKey", o_script_pub_key);
232 for (
unsigned int i = 0; i < tx.
vout.size(); i++) {
238 out.
pushKV(
"n", (int64_t)i);
242 out.
pushKV(
"scriptPubKey", o);
246 amt_total_out += txout.
nValue;
249 entry.
pushKV(
"vout", vout);
252 const CAmount fee = amt_total_in - amt_total_out;
size_t GetSerializeSize(const T &t, int nVersion=0)
An input of a transaction.
std::string SighashToStr(unsigned char sighash_type)
const std::vector< CTxIn > vin
std::string ToString(const T &t)
Locale-independent version of std::to_string.
std::string FormatScript(const CScript &script)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode)
Create the assembly string representation of a CScript object.
Undo information for a CTransaction.
std::string GetOpName(opcodetype opcode)
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex, int serialize_flags, const CTxUndo *txundo, TxVerbosity verbosity)
bool MoneyRange(const CAmount &nValue)
opcodetype
Script opcodes.
unsigned int fCoinBase
whether containing transaction was a coinbase
const SigningProvider & DUMMY_SIGNING_PROVIDER
bool pushKV(const std::string &key, const UniValue &val)
The basic transaction that is broadcasted on the network and contained in blocks.
CTxOut out
unspent transaction output
void ScriptToUniv(const CScript &script, UniValue &out)
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags)
An output of a transaction.
uint32_t nHeight
at which height this containing transaction was included in the active block chain
const std::vector< CTxOut > vout
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool include_hex, bool include_address)
int64_t CAmount
Amount in satoshis (Can be negative)
std::string GetHex() const
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, unsigned int flags, ScriptError *serror)
@ SHOW_DETAILS_AND_PREVOUT
The same as previous option with information about prevouts if available.
Serialized script, used inside transaction inputs and outputs.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
std::vector< Coin > vprevout
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
static int64_t GetTransactionWeight(const CTransaction &tx)
const std::map< unsigned char, std::string > mapSigHashTypes
bool push_back(const UniValue &val)
Double ended buffer combining vector and stream-like interfaces.
const uint256 & GetWitnessHash() const
const uint256 & GetHash() const
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
static constexpr CAmount COIN
The amount of satoshis in one BTC.
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
static const int WITNESS_SCALE_FACTOR
UniValue ValueFromAmount(const CAmount amount)
std::string EncodeDestination(const CTxDestination &dest)
TxVerbosity
Verbose level for block's transaction.
@ SCRIPT_VERIFY_STRICTENC
static const int PROTOCOL_VERSION
network protocol versioning
bool GetOp(const_iterator &pc, opcodetype &opcodeRet, std::vector< unsigned char > &vchRet) const