Bitcoin Core  31.0.0
P2P Digital Currency
core_io.h
Go to the documentation of this file.
1 // Copyright (c) 2009-present 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 <util/result.h>
10 
11 #include <functional>
12 #include <string>
13 
14 class CBlock;
15 class CBlockHeader;
16 class CScript;
17 class CTransaction;
18 struct CMutableTransaction;
19 class SigningProvider;
20 class uint256;
21 class UniValue;
22 class CTxUndo;
23 class CTxOut;
24 
28 enum class TxVerbosity {
29  SHOW_TXID,
30  SHOW_DETAILS,
32 };
33 
34 CScript ParseScript(const std::string& s);
35 std::string ScriptToAsmStr(const CScript& script, bool fAttemptSighashDecode = false);
36 [[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
37 [[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
38 bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
39 
40 [[nodiscard]] util::Result<int> SighashFromStr(const std::string& sighash);
41 
43 std::string FormatScript(const CScript& script);
44 std::string EncodeHexTx(const CTransaction& tx);
45 std::string SighashToStr(unsigned char sighash_type);
46 void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex = true, bool include_address = false, const SigningProvider* provider = nullptr);
47 void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry, bool include_hex = true, const CTxUndo* txundo = nullptr, TxVerbosity verbosity = TxVerbosity::SHOW_DETAILS, std::function<bool(const CTxOut&)> is_change_func = {});
48 
49 #endif // BITCOIN_CORE_IO_H
util::Result< int > SighashFromStr(const std::string &sighash)
Definition: core_io.cpp:266
std::string FormatScript(const CScript &script)
Definition: core_io.cpp:298
The same as previous option with information about prevouts if available.
bool DecodeHexBlk(CBlock &, const std::string &strHexBlk)
Definition: core_io.cpp:250
Definition: block.h:73
TxVerbosity
Verbose level for block&#39;s transaction.
Definition: core_io.h:28
bool DecodeHexBlockHeader(CBlockHeader &, const std::string &hex_header)
Definition: core_io.cpp:237
void TxToUniv(const CTransaction &tx, const uint256 &block_hash, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr, TxVerbosity verbosity=TxVerbosity::SHOW_DETAILS, std::function< bool(const CTxOut &)> is_change_func={})
Definition: core_io.cpp:430
std::string ScriptToAsmStr(const CScript &script, bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_io.cpp:357
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Include TXID, inputs, outputs, and other common block&#39;s transaction information.
void ScriptToUniv(const CScript &script, UniValue &out, bool include_hex=true, bool include_address=false, const SigningProvider *provider=nullptr)
Definition: core_io.cpp:409
std::string SighashToStr(unsigned char sighash_type)
Definition: core_io.cpp:343
An output of a transaction.
Definition: transaction.h:139
256-bit opaque blob.
Definition: uint256.h:195
std::string EncodeHexTx(const CTransaction &tx)
Definition: core_io.cpp:402
An interface to be implemented by keystores that support signing.
Only TXID for each block&#39;s transaction.
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
Undo information for a CTransaction.
Definition: undo.h:52
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
Definition: core_io.cpp:227
A mutable version of CTransaction.
Definition: transaction.h:357
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:280
UniValue ValueFromAmount(CAmount amount)
Definition: core_io.cpp:285
CScript ParseScript(const std::string &s)
Definition: core_io.cpp:94
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:26