Bitcoin Core  21.99.0
P2P Digital Currency
core_io.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2020 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 <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 
23 // core_read.cpp
24 CScript ParseScript(const std::string& s);
25 std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
26 [[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
27 [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
28 bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
29 
38 bool ParseHashStr(const std::string& strHex, uint256& result);
39 std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
40 int ParseSighashString(const UniValue& sighash);
41 
42 // core_write.cpp
43 UniValue ValueFromAmount(const CAmount amount);
44 std::string FormatScript(const CScript& script);
45 std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
46 std::string SighashToStr(unsigned char sighash_type);
47 void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex, bool include_addresses);
48 void ScriptToUniv(const CScript& script, UniValue& out, bool include_address);
49 void TxToUniv(const CTransaction& tx, const uint256& hashBlock, bool include_addresses, UniValue& entry, bool include_hex = true, int serialize_flags = 0, const CTxUndo* txundo = nullptr);
50 
51 #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:239
ScriptToUniv
void ScriptToUniv(const CScript &script, UniValue &out, bool include_address)
Definition: core_write.cpp:144
TxToUniv
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, bool include_addresses, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
Definition: core_write.cpp:193
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
SighashToStr
std::string SighashToStr(unsigned char sighash_type)
Definition: core_write.cpp:78
FormatScript
std::string FormatScript(const CScript &script)
Definition: core_write.cpp:33
ValueFromAmount
UniValue ValueFromAmount(const CAmount amount)
Definition: core_write.cpp:20
UniValue
Definition: univalue.h:19
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
ParseScript
CScript ParseScript(const std::string &s)
Definition: core_read.cpp:55
DecodeHexBlockHeader
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
Definition: core_read.cpp:208
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
uint256
256-bit opaque blob.
Definition: uint256.h:124
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
attributes.h
EncodeHexTx
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Definition: core_write.cpp:137
CBlock
Definition: block.h:62
ScriptPubKeyToUniv
void ScriptPubKeyToUniv(const CScript &scriptPubKey, UniValue &out, bool fIncludeHex, bool include_addresses)
Definition: core_write.cpp:161
ParseHexUV
std::vector< unsigned char > ParseHexUV(const UniValue &v, const std::string &strName)
Definition: core_read.cpp:248
DecodeHexBlk
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
Definition: core_read.cpp:222
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:92
DecodeHexTx
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
Definition: core_read.cpp:198
ParseSighashString
int ParseSighashString(const UniValue &sighash)
Definition: core_read.cpp:258