Bitcoin Core  24.1.0
P2P Digital Currency
core_io.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_CORE_IO_H
6 #define BITCOIN_CORE_IO_H
7 
8 #include <consensus/amount.h>
9 
10 #include <string>
11 #include <vector>
12 
13 class CBlock;
14 class CBlockHeader;
15 class CScript;
16 class CTransaction;
17 struct CMutableTransaction;
18 class uint256;
19 class UniValue;
20 class CTxUndo;
21 
25 enum class TxVerbosity {
26  SHOW_TXID,
27  SHOW_DETAILS,
29 };
30 
31 // core_read.cpp
32 CScript ParseScript(const std::string& s);
33 std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
34 [[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
35 [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
36 bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
37 
46 bool ParseHashStr(const std::string& strHex, uint256& result);
47 std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
49 
50 // core_write.cpp
51 UniValue ValueFromAmount(const CAmount amount);
52 std::string FormatScript(const CScript& script);
53 std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
54 std::string SighashToStr(unsigned char sighash_type);
55 void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex = true, bool include_address = false);
56 void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS);
57 
58 #endif // BITCOIN_CORE_IO_H
std::vector< unsigned char > ParseHexUV(const UniValue &v, const std::string &strName)
Definition: core_read.cpp:245
std::string FormatScript(const CScript &script)
Definition: core_write.cpp:39
The same as previous option with information about prevouts if available.
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
Definition: core_read.cpp:219
Definition: block.h:68
TxVerbosity
Verbose level for block&#39;s transaction.
Definition: core_io.h:25
static unsigned const char sighash[]
Definition: sighash.json.h:2
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
Definition: core_read.cpp:205
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_write.cpp:98
Include TXID, inputs, outputs, and other common block&#39;s transaction information.
int ParseSighashString(const UniValue &sighash)
Definition: core_read.cpp:255
std::string SighashToStr(unsigned char sighash_type)
Definition: core_write.cpp:84
256-bit opaque blob.
Definition: uint256.h:119
Only TXID for each block&#39;s transaction.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:410
Undo information for a CTransaction.
Definition: undo.h:53
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
Definition: core_read.cpp:195
UniValue ValueFromAmount(const CAmount amount)
Definition: core_write.cpp:26
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Definition: core_write.cpp:143
A mutable version of CTransaction.
Definition: transaction.h:372
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex=true, bool include_address=false)
Definition: core_write.cpp:150
bool ParseHashStr(const std::string &strHex, uint256 &result)
Parse a hex string into 256 bits.
Definition: core_read.cpp:236
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:287
CScript ParseScript(const std::string &s)
Definition: core_read.cpp:62
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
Definition: core_write.cpp:171
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:21