2021-12-30 19:36:57 +02:00
|
|
|
// Copyright (c) 2009-2021 The Bitcoin Core developers
|
2014-12-13 12:09:33 +08:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-08-01 08:39:06 +02:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_CORE_IO_H
|
|
|
|
#define BITCOIN_CORE_IO_H
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2021-09-11 10:29:00 +08:00
|
|
|
#include <consensus/amount.h>
|
2018-09-25 07:00:36 +02:00
|
|
|
#include <attributes.h>
|
2017-08-07 14:38:39 +02:00
|
|
|
|
2014-06-23 23:10:24 -04:00
|
|
|
#include <string>
|
2014-08-01 08:32:41 +02:00
|
|
|
#include <vector>
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2014-10-30 02:56:33 +00:00
|
|
|
class CBlock;
|
2018-06-04 18:22:58 -04:00
|
|
|
class CBlockHeader;
|
2014-06-23 23:16:33 -04:00
|
|
|
class CScript;
|
2014-06-23 23:10:24 -04:00
|
|
|
class CTransaction;
|
2016-12-05 11:13:17 +01:00
|
|
|
struct CMutableTransaction;
|
2014-09-14 12:43:56 +02:00
|
|
|
class uint256;
|
2014-07-29 11:12:44 -04:00
|
|
|
class UniValue;
|
2020-10-09 08:50:44 -07:00
|
|
|
class CTxUndo;
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2021-03-01 20:03:35 +00:00
|
|
|
/**
|
|
|
|
* Verbose level for block's transaction
|
|
|
|
*/
|
|
|
|
enum class TxVerbosity {
|
|
|
|
SHOW_TXID, //!< Only TXID for each block's transaction
|
2021-02-27 17:39:09 +00:00
|
|
|
SHOW_DETAILS, //!< Include TXID, inputs, outputs, and other common block's transaction information
|
|
|
|
SHOW_DETAILS_AND_PREVOUT //!< The same as previous option with information about prevouts if available
|
2021-03-01 20:03:35 +00:00
|
|
|
};
|
|
|
|
|
2014-06-23 23:10:24 -04:00
|
|
|
// core_read.cpp
|
2016-11-30 10:27:21 +09:00
|
|
|
CScript ParseScript(const std::string& s);
|
|
|
|
std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
|
2020-11-26 09:05:59 +00:00
|
|
|
[[nodiscard]] bool DecodeHexTx(CMutableTransaction& tx, const std::string& hex_tx, bool try_no_witness = false, bool try_witness = true);
|
|
|
|
[[nodiscard]] bool DecodeHexBlk(CBlock&, const std::string& strHexBlk);
|
2018-06-04 18:22:58 -04:00
|
|
|
bool DecodeHexBlockHeader(CBlockHeader&, const std::string& hex_header);
|
2018-09-24 10:59:17 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a hex string into 256 bits
|
|
|
|
* @param[in] strHex a hex-formatted, 64-character string
|
2020-12-24 22:37:17 +09:00
|
|
|
* @param[out] result the result of the parsing
|
2018-09-24 10:59:17 -04:00
|
|
|
* @returns true if successful, false if not
|
|
|
|
*
|
|
|
|
* @see ParseHashV for an RPC-oriented version of this
|
|
|
|
*/
|
|
|
|
bool ParseHashStr(const std::string& strHex, uint256& result);
|
2016-11-30 10:27:21 +09:00
|
|
|
std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
|
2018-06-28 19:05:05 -07:00
|
|
|
int ParseSighashString(const UniValue& sighash);
|
2014-06-23 23:10:24 -04:00
|
|
|
|
|
|
|
// core_write.cpp
|
2020-11-16 16:44:50 +00:00
|
|
|
UniValue ValueFromAmount(const CAmount amount);
|
2016-11-30 10:27:21 +09:00
|
|
|
std::string FormatScript(const CScript& script);
|
2016-11-20 09:54:51 -05:00
|
|
|
std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
|
2018-06-28 19:04:40 -07:00
|
|
|
std::string SighashToStr(unsigned char sighash_type);
|
2021-05-10 15:23:39 -04:00
|
|
|
void ScriptPubKeyToUniv(const CScript& scriptPubKey, UniValue& out, bool include_hex, bool include_address = true);
|
2021-05-10 15:14:16 -04:00
|
|
|
void ScriptToUniv(const CScript& script, UniValue& out);
|
2021-02-27 17:39:09 +00:00
|
|
|
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);
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_CORE_IO_H
|