Files
thehub/libs/server/UnspentOutputData.h
T

81 lines
2.2 KiB
C++
Raw Permalink Normal View History

/*
* This file is part of the Flowee project
2021-06-20 22:44:44 +02:00
* Copyright (C) 2018 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UNSPENTOUTPUTDATA_H
#define UNSPENTOUTPUTDATA_H
#include <utxo/UnspentOutputDatabase.h>
class UnspentOutputData
{
public:
UnspentOutputData(const UnspentOutput &uo);
UnspentOutputData() = default;
inline bool isValid() const {
return m_uo.isValid() && m_txVer >= 0 && m_outputValue >= 0;
}
inline uint256 prevTxId() const {
return m_uo.prevTxId();
}
inline int outIndex() const {
return m_uo.outIndex();
}
2019-06-11 17:31:57 +02:00
/// return the offset in the block. In bytes. Notice that offsetInBlock < 91 implies this is a coinbase.
inline int offsetInBlock() const {
return m_uo.offsetInBlock();
}
inline int blockHeight() const {
return m_uo.blockHeight();
}
inline bool isCoinbase() const {
return m_uo.isCoinbase();
}
inline Streaming::ConstBuffer data() const {
return m_uo.data();
}
inline int prevTxVersion() const {
return m_txVer;
}
inline std::int64_t outputValue() const {
return m_outputValue;
}
inline Streaming::ConstBuffer outputScript() const {
return m_outputScript;
}
2018-08-30 20:28:11 +02:00
/// return the UnspentOutputDatabase internal to make remove faster
/// pass in to UnspentOutputDatabase::remove() if available
inline uint64_t rmHint() const {
return m_uo.rmHint();
}
private:
UnspentOutput m_uo;
2018-11-20 15:27:38 +01:00
int m_txVer = -1;
std::int64_t m_outputValue = -1;
Streaming::ConstBuffer m_outputScript;
};
#endif