2021-12-30 14:36:57 -03:00
|
|
|
// Copyright (c) 2009-2021 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2014-08-01 02:39:06 -04:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#ifndef BITCOIN_CORE_IO_H
|
|
|
|
#define BITCOIN_CORE_IO_H
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2021-09-10 23:29:00 -03:00
|
|
|
#include <consensus/amount.h>
|
2017-08-07 08:38:39 -04:00
|
|
|
|
2014-06-23 23:10:24 -04:00
|
|
|
#include <string>
|
2014-08-01 02:32:41 -04:00
|
|
|
#include <vector>
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2014-10-29 23:56:33 -03: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 07:13:17 -03:00
|
|
|
struct CMutableTransaction;
|
2014-09-14 07:43:56 -03:00
|
|
|
class uint256;
|
2014-07-29 11:12:44 -04:00
|
|
|
class UniValue;
|
2020-10-09 12:50:44 -03:00
|
|
|
class CTxUndo;
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2021-03-01 17:03:35 -03:00
|
|
|
/**
|
|
|
|
* Verbose level for block's transaction
|
|
|
|
*/
|
|
|
|
enum class TxVerbosity {
|
|
|
|
SHOW_TXID, //!< Only TXID for each block's transaction
|
2021-02-27 14:39:09 -03: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 17:03:35 -03:00
|
|
|
};
|
|
|
|
|
2014-06-23 23:10:24 -04:00
|
|
|
// core_read.cpp
|
2016-11-29 22:27:21 -03:00
|
|
|
CScript ParseScript(const std::string& s);
|
|
|
|
std::string ScriptToAsmStr(const CScript& script, const bool fAttemptSighashDecode = false);
|
2020-11-26 06:05:59 -03: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 11:59:17 -03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a hex string into 256 bits
|
|
|
|
* @param[in] strHex a hex-formatted, 64-character string
|
2020-12-24 10:37:17 -03:00
|
|
|
* @param[out] result the result of the parsing
|
2018-09-24 11:59:17 -03: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-29 22:27:21 -03:00
|
|
|
std::vector<unsigned char> ParseHexUV(const UniValue& v, const std::string& strName);
|
2018-06-28 22:05:05 -04:00
|
|
|
int ParseSighashString(const UniValue& sighash);
|
2014-06-23 23:10:24 -04:00
|
|
|
|
|
|
|
// core_write.cpp
|
2020-11-16 13:44:50 -03:00
|
|
|
UniValue ValueFromAmount(const CAmount amount);
|
2016-11-29 22:27:21 -03:00
|
|
|
std::string FormatScript(const CScript& script);
|
2016-11-20 11:54:51 -03:00
|
|
|
std::string EncodeHexTx(const CTransaction& tx, const int serializeFlags = 0);
|
2018-06-28 22:04:40 -04:00
|
|
|
std::string SighashToStr(unsigned char sighash_type);
|
2021-09-28 20:11:49 -03:00
|
|
|
void ScriptToUniv(const CScript& script, UniValue& out, bool include_hex = true, bool include_address = false);
|
2021-09-29 11:58:36 -03:00
|
|
|
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);
|
2014-06-23 23:10:24 -04:00
|
|
|
|
2014-11-03 12:16:40 -03:00
|
|
|
#endif // BITCOIN_CORE_IO_H
|