Bitcoin Core  22.99.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 #include <attributes.h>
10 
11 #include <string>
12 #include <vector>
13 
14 class CBlock;
15 class CBlockHeader;
16 class CScript;
17 class CTransaction;
18 struct CMutableTransaction;
19 class uint256;
20 class UniValue;
21 class CTxUndo;
22 
26 enum class TxVerbosity {
27  SHOW_TXID,
28  SHOW_DETAILS,
30 };
31 
32 // core_read.cpp
33 CScript ParseScript(const std::string& s);
34 std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
35 [[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
36 [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
37 bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
38 
47 bool ParseHashStr(const std::string& strHex, uint256& result);
48 std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
49 int ParseSighashString(const UniValue& sighash);
50 
51 // core_write.cpp
52 UniValue ValueFromAmount(const CAmount amount);
53 std::string FormatScript(const CScript& script);
54 std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
55 std::string SighashToStr(unsigned char sighash_type);
56 void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address = true);
57 void ScriptToUniv(const CScript& script, UniValue& out);
58 void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS);
59 
60 #endif // BITCOIN_CORE_IO_H
ParseHashStr
bool ParseHashStr(const std::string &strHex, uint256 &result)
Parse a hex string into 256 bits.
Definition: core_read.cpp:240
CBlockHeader
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:20
CTxUndo
Undo information for a CTransaction.
Definition: undo.h:53
ScriptPubKeyToUniv
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool include_hex, bool include_address=true)
Definition: core_write.cpp:151
SighashToStr
std::string SighashToStr(unsigned char sighash_type)
Definition: core_write.cpp:80
ScriptToUniv
void ScriptToUniv(const CScript &script, UniValue &out)
Definition: core_write.cpp:146
FormatScript
std::string FormatScript(const CScript &script)
Definition: core_write.cpp:35
ValueFromAmount
UniValue ValueFromAmount(const CAmount amount)
Definition: core_write.cpp:22
UniValue
Definition: univalue.h:17
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
TxVerbosity::SHOW_TXID
@ SHOW_TXID
Only TXID for each block's transaction.
ParseScript
CScript ParseScript(const std::string &s)
Definition: core_read.cpp:65
DecodeHexBlockHeader
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
Definition: core_read.cpp:209
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
TxVerbosity::SHOW_DETAILS_AND_PREVOUT
@ SHOW_DETAILS_AND_PREVOUT
The same as previous option with information about prevouts if available.
uint256
256-bit opaque blob.
Definition: uint256.h:126
TxVerbosity::SHOW_DETAILS
@ SHOW_DETAILS
Include TXID, inputs, outputs, and other common block's transaction information.
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
attributes.h
EncodeHexTx
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Definition: core_write.cpp:139
CBlock
Definition: block.h:62
TxToUniv
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS)
Definition: core_write.cpp:168
ParseHexUV
std::vector< unsigned char > ParseHexUV(const UniValue &v, const std::string &strName)
Definition: core_read.cpp:249
DecodeHexBlk
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
Definition: core_read.cpp:223
CMutableTransaction
A mutable version of CTransaction.
Definition: transaction.h:344
amount.h
ScriptToAsmStr
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_write.cpp:94
TxVerbosity
TxVerbosity
Verbose level for block's transaction.
Definition: core_io.h:26
DecodeHexTx
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
Definition: core_read.cpp:199
ParseSighashString
int ParseSighashString(const UniValue &sighash)
Definition: core_read.cpp:259