2016-05-16 20:23:01 +02:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
|
|
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
2023-09-18 19:17:33 +02:00
|
|
|
// Copyright (c) 2023 The Dash Core developers
|
2016-05-16 20:23:01 +02:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_SPENTINDEX_H
|
|
|
|
#define BITCOIN_SPENTINDEX_H
|
|
|
|
|
2023-09-18 20:39:11 +02:00
|
|
|
#include <addressindex.h>
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <amount.h>
|
|
|
|
#include <script/script.h>
|
|
|
|
#include <serialize.h>
|
2023-09-18 20:39:11 +02:00
|
|
|
#include <uint256.h>
|
2016-05-16 20:23:01 +02:00
|
|
|
|
2023-09-25 16:49:30 +02:00
|
|
|
#include <tuple>
|
|
|
|
|
2016-05-16 20:23:01 +02:00
|
|
|
struct CSpentIndexKey {
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2023-09-18 19:17:33 +02:00
|
|
|
uint256 m_tx_hash;
|
|
|
|
uint32_t m_tx_index{0};
|
2016-05-16 20:23:01 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2016-05-16 20:23:01 +02:00
|
|
|
CSpentIndexKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-18 19:17:33 +02:00
|
|
|
CSpentIndexKey(uint256 txout_hash, uint32_t txout_index) :
|
|
|
|
m_tx_hash{txout_hash}, m_tx_index{txout_index} {};
|
|
|
|
|
2016-05-16 20:23:01 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_tx_hash.SetNull();
|
|
|
|
m_tx_index = 0;
|
2016-05-16 20:23:01 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
|
|
|
SERIALIZE_METHODS(CSpentIndexKey, obj)
|
|
|
|
{
|
2023-09-18 19:17:33 +02:00
|
|
|
READWRITE(obj.m_tx_hash, obj.m_tx_index);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
2016-05-16 20:23:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CSpentIndexValue {
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2023-09-18 19:17:33 +02:00
|
|
|
uint256 m_tx_hash;
|
|
|
|
uint32_t m_tx_index{0};
|
|
|
|
int32_t m_block_height{0};
|
|
|
|
CAmount m_amount{0};
|
2023-09-13 18:52:54 +02:00
|
|
|
uint8_t m_address_type{AddressType::UNKNOWN};
|
2023-09-18 19:17:33 +02:00
|
|
|
uint160 m_address_bytes;
|
2016-05-16 20:23:01 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2016-05-16 20:23:01 +02:00
|
|
|
CSpentIndexValue() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-13 18:52:54 +02:00
|
|
|
CSpentIndexValue(uint256 txin_hash, uint32_t txin_index, int32_t block_height, CAmount amount, uint8_t address_type,
|
2023-09-18 19:17:33 +02:00
|
|
|
uint160 address_bytes) :
|
|
|
|
m_tx_hash{txin_hash},
|
|
|
|
m_tx_index{txin_index},
|
|
|
|
m_block_height{block_height},
|
|
|
|
m_amount{amount},
|
|
|
|
m_address_type{address_type},
|
|
|
|
m_address_bytes{address_bytes} {};
|
|
|
|
|
2016-05-16 20:23:01 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_tx_hash.SetNull();
|
|
|
|
m_tx_index = 0;
|
|
|
|
m_block_height = 0;
|
|
|
|
m_amount = 0;
|
|
|
|
m_address_type = AddressType::UNKNOWN;
|
|
|
|
m_address_bytes.SetNull();
|
2016-05-16 20:23:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsNull() const {
|
2023-09-18 19:17:33 +02:00
|
|
|
return m_tx_hash.IsNull();
|
2016-05-16 20:23:01 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
SERIALIZE_METHODS(CSpentIndexValue, obj)
|
|
|
|
{
|
2023-09-18 19:17:33 +02:00
|
|
|
READWRITE(obj.m_tx_hash, obj.m_tx_index, obj.m_block_height, obj.m_amount, obj.m_address_type, obj.m_address_bytes);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
2016-05-16 20:23:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CSpentIndexKeyCompare
|
|
|
|
{
|
|
|
|
bool operator()(const CSpentIndexKey& a, const CSpentIndexKey& b) const {
|
2023-09-25 16:49:30 +02:00
|
|
|
auto to_tuple = [](const CSpentIndexKey& obj) {
|
2023-09-18 19:17:33 +02:00
|
|
|
return std::tie(obj.m_tx_hash, obj.m_tx_index);
|
2023-09-25 16:49:30 +02:00
|
|
|
};
|
|
|
|
return to_tuple(a) < to_tuple(b);
|
2016-05-16 20:23:01 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-11 13:42:17 +02:00
|
|
|
struct CSpentIndexTxInfo
|
|
|
|
{
|
|
|
|
std::map<CSpentIndexKey, CSpentIndexValue, CSpentIndexKeyCompare> mSpentInfo;
|
|
|
|
};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
struct CTimestampIndexIteratorKey {
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2023-09-18 19:17:33 +02:00
|
|
|
uint32_t m_time;
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CTimestampIndexIteratorKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-18 19:17:33 +02:00
|
|
|
CTimestampIndexIteratorKey(uint32_t time) : m_time{time} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_time = 0;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
2023-09-13 18:25:32 +02:00
|
|
|
return 4;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Serialize(Stream& s) const {
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata32be(s, m_time);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Unserialize(Stream& s) {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_time = ser_readdata32be(s);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CTimestampIndexKey {
|
|
|
|
public:
|
2023-09-18 19:17:33 +02:00
|
|
|
uint32_t m_block_time;
|
|
|
|
uint256 m_block_hash;
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CTimestampIndexKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-18 19:17:33 +02:00
|
|
|
CTimestampIndexKey(uint32_t block_time, uint256 block_hash) :
|
|
|
|
m_block_time{block_time}, m_block_hash{block_hash} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_block_time = 0;
|
|
|
|
m_block_hash.SetNull();
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
2023-09-13 18:25:32 +02:00
|
|
|
return 36;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Serialize(Stream& s) const {
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata32be(s, m_block_time);
|
|
|
|
m_block_hash.Serialize(s);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Unserialize(Stream& s) {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_block_time = ser_readdata32be(s);
|
|
|
|
m_block_hash.Unserialize(s);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CAddressUnspentKey {
|
|
|
|
public:
|
2023-09-13 18:52:54 +02:00
|
|
|
uint8_t m_address_type{AddressType::UNKNOWN};
|
2023-09-18 19:17:33 +02:00
|
|
|
uint160 m_address_bytes;
|
|
|
|
uint256 m_tx_hash;
|
|
|
|
size_t m_tx_index{0};
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CAddressUnspentKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-13 18:52:54 +02:00
|
|
|
CAddressUnspentKey(uint8_t address_type, uint160 address_bytes, uint256 tx_hash, size_t tx_index) :
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type{address_type}, m_address_bytes{address_bytes}, m_tx_hash{tx_hash}, m_tx_index{tx_index} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = AddressType::UNKNOWN;
|
|
|
|
m_address_bytes.SetNull();
|
|
|
|
m_tx_hash.SetNull();
|
|
|
|
m_tx_index = 0;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
|
|
return 57;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Stream>
|
|
|
|
void Serialize(Stream& s) const {
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata8(s, m_address_type);
|
|
|
|
m_address_bytes.Serialize(s);
|
|
|
|
m_tx_hash.Serialize(s);
|
|
|
|
ser_writedata32(s, m_tx_index);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Stream>
|
|
|
|
void Unserialize(Stream& s) {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = ser_readdata8(s);
|
|
|
|
m_address_bytes.Unserialize(s);
|
|
|
|
m_tx_hash.Unserialize(s);
|
|
|
|
m_tx_index = ser_readdata32(s);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
2017-09-15 18:34:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CAddressUnspentValue {
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2023-09-18 19:17:33 +02:00
|
|
|
CAmount m_amount{-1};
|
|
|
|
CScript m_tx_script;
|
|
|
|
int32_t m_block_height;
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CAddressUnspentValue() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-18 19:17:33 +02:00
|
|
|
CAddressUnspentValue(CAmount amount, CScript tx_script, int32_t block_height) :
|
|
|
|
m_amount{amount}, m_tx_script{tx_script}, m_block_height{block_height} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_amount = -1;
|
|
|
|
m_tx_script.clear();
|
|
|
|
m_block_height = 0;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsNull() const {
|
2023-09-18 19:17:33 +02:00
|
|
|
return (m_amount == -1);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
SERIALIZE_METHODS(CAddressUnspentValue, obj)
|
|
|
|
{
|
2023-09-18 19:17:33 +02:00
|
|
|
READWRITE(obj.m_amount, obj.m_tx_script, obj.m_block_height);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
2017-09-15 18:34:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CAddressIndexKey {
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2023-09-13 18:52:54 +02:00
|
|
|
uint8_t m_address_type{AddressType::UNKNOWN};
|
2023-09-18 19:17:33 +02:00
|
|
|
uint160 m_address_bytes;
|
|
|
|
int32_t m_block_height{0};
|
|
|
|
uint32_t m_block_tx_pos{0};
|
|
|
|
uint256 m_tx_hash;
|
|
|
|
size_t m_tx_index{0};
|
|
|
|
bool m_tx_spent{false};
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CAddressIndexKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-13 18:52:54 +02:00
|
|
|
CAddressIndexKey(uint8_t address_type, uint160 address_bytes, int32_t block_height, uint32_t block_tx_pos, uint256 tx_hash,
|
2023-09-18 19:17:33 +02:00
|
|
|
size_t tx_index, bool tx_spent) :
|
|
|
|
m_address_type{address_type},
|
|
|
|
m_address_bytes{address_bytes},
|
|
|
|
m_block_height{block_height},
|
|
|
|
m_block_tx_pos{block_tx_pos},
|
|
|
|
m_tx_hash{tx_hash},
|
|
|
|
m_tx_index{tx_index},
|
|
|
|
m_tx_spent{tx_spent} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = AddressType::UNKNOWN;
|
|
|
|
m_address_bytes.SetNull();
|
|
|
|
m_block_height = 0;
|
|
|
|
m_block_tx_pos = 0;
|
|
|
|
m_tx_hash.SetNull();
|
|
|
|
m_tx_index = 0;
|
|
|
|
m_tx_spent = false;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
2023-09-13 18:25:32 +02:00
|
|
|
return 66;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Serialize(Stream& s) const {
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata8(s, m_address_type);
|
|
|
|
m_address_bytes.Serialize(s);
|
2023-09-13 18:25:32 +02:00
|
|
|
// Heights are stored big-endian for key sorting in LevelDB
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata32be(s, m_block_height);
|
|
|
|
ser_writedata32be(s, m_block_tx_pos);
|
|
|
|
m_tx_hash.Serialize(s);
|
|
|
|
ser_writedata32(s, m_tx_index);
|
|
|
|
char f = m_tx_spent;
|
2023-09-13 18:25:32 +02:00
|
|
|
ser_writedata8(s, f);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Unserialize(Stream& s) {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = ser_readdata8(s);
|
|
|
|
m_address_bytes.Unserialize(s);
|
|
|
|
m_block_height = ser_readdata32be(s);
|
|
|
|
m_block_tx_pos = ser_readdata32be(s);
|
|
|
|
m_tx_hash.Unserialize(s);
|
|
|
|
m_tx_index = ser_readdata32(s);
|
2023-09-13 18:25:32 +02:00
|
|
|
char f = ser_readdata8(s);
|
2023-09-18 19:17:33 +02:00
|
|
|
m_tx_spent = f;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CAddressIndexIteratorKey {
|
|
|
|
public:
|
2023-09-13 18:52:54 +02:00
|
|
|
uint8_t m_address_type{AddressType::UNKNOWN};
|
2023-09-18 19:17:33 +02:00
|
|
|
uint160 m_address_bytes;
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CAddressIndexIteratorKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-13 18:52:54 +02:00
|
|
|
CAddressIndexIteratorKey(uint8_t address_type, uint160 address_bytes) :
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type{address_type}, m_address_bytes{address_bytes} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = AddressType::UNKNOWN;
|
|
|
|
m_address_bytes.SetNull();
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
2023-09-13 18:25:32 +02:00
|
|
|
return 21;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Serialize(Stream& s) const {
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata8(s, m_address_type);
|
|
|
|
m_address_bytes.Serialize(s);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
template<typename Stream>
|
2017-09-19 21:36:55 +02:00
|
|
|
void Unserialize(Stream& s) {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = ser_readdata8(s);
|
|
|
|
m_address_bytes.Unserialize(s);
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
2023-09-13 18:25:32 +02:00
|
|
|
};
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
struct CAddressIndexIteratorHeightKey {
|
|
|
|
public:
|
2023-09-13 18:52:54 +02:00
|
|
|
uint8_t m_address_type{AddressType::UNKNOWN};
|
2023-09-18 19:17:33 +02:00
|
|
|
uint160 m_address_bytes;
|
|
|
|
int32_t m_block_height{0};
|
2023-09-13 18:25:32 +02:00
|
|
|
|
|
|
|
public:
|
2017-09-15 18:34:04 +02:00
|
|
|
CAddressIndexIteratorHeightKey() {
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2023-09-13 18:52:54 +02:00
|
|
|
CAddressIndexIteratorHeightKey(uint8_t address_type, uint160 address_bytes, int32_t block_height) :
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type{address_type}, m_address_bytes{address_bytes}, m_block_height{block_height} {};
|
|
|
|
|
2017-09-15 18:34:04 +02:00
|
|
|
void SetNull() {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = AddressType::UNKNOWN;
|
|
|
|
m_address_bytes.SetNull();
|
|
|
|
m_block_height = 0;
|
2017-09-15 18:34:04 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 18:25:32 +02:00
|
|
|
public:
|
|
|
|
size_t GetSerializeSize(int nType, int nVersion) const {
|
|
|
|
return 25;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Stream>
|
|
|
|
void Serialize(Stream& s) const {
|
2023-09-18 19:17:33 +02:00
|
|
|
ser_writedata8(s, m_address_type);
|
|
|
|
m_address_bytes.Serialize(s);
|
|
|
|
ser_writedata32be(s, m_block_height);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Stream>
|
|
|
|
void Unserialize(Stream& s) {
|
2023-09-18 19:17:33 +02:00
|
|
|
m_address_type = ser_readdata8(s);
|
|
|
|
m_address_bytes.Unserialize(s);
|
|
|
|
m_block_height = ser_readdata32be(s);
|
2023-09-13 18:25:32 +02:00
|
|
|
}
|
|
|
|
};
|
2017-09-15 18:34:04 +02:00
|
|
|
|
2016-05-16 20:23:01 +02:00
|
|
|
#endif // BITCOIN_SPENTINDEX_H
|