2016-01-18 15:33:29 +00:00
|
|
|
// Copyright (c) 2011-2016 The Cryptonote developers
|
2015-04-23 16:07:22 +00:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2015-04-06 16:13:07 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <limits>
|
|
|
|
#include <vector>
|
|
|
|
#include "crypto/hash.h"
|
|
|
|
#include "ITransaction.h"
|
|
|
|
#include "IObservable.h"
|
|
|
|
#include "IStreamSerializable.h"
|
|
|
|
|
|
|
|
namespace CryptoNote {
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
const uint32_t UNCONFIRMED_TRANSACTION_GLOBAL_OUTPUT_INDEX = std::numeric_limits<uint32_t>::max();
|
2015-04-06 16:13:07 +00:00
|
|
|
|
|
|
|
struct TransactionInformation {
|
|
|
|
// transaction info
|
2015-07-30 15:22:07 +00:00
|
|
|
Crypto::Hash transactionHash;
|
|
|
|
Crypto::PublicKey publicKey;
|
|
|
|
uint32_t blockHeight;
|
2015-04-06 16:13:07 +00:00
|
|
|
uint64_t timestamp;
|
|
|
|
uint64_t unlockTime;
|
|
|
|
uint64_t totalAmountIn;
|
|
|
|
uint64_t totalAmountOut;
|
|
|
|
std::vector<uint8_t> extra;
|
2015-07-30 15:22:07 +00:00
|
|
|
Crypto::Hash paymentId;
|
2015-04-06 16:13:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct TransactionOutputInformation {
|
|
|
|
// output info
|
|
|
|
TransactionTypes::OutputType type;
|
|
|
|
uint64_t amount;
|
2015-07-30 15:22:07 +00:00
|
|
|
uint32_t globalOutputIndex;
|
2015-04-06 16:13:07 +00:00
|
|
|
uint32_t outputInTransaction;
|
|
|
|
|
|
|
|
// transaction info
|
2015-07-30 15:22:07 +00:00
|
|
|
Crypto::Hash transactionHash;
|
|
|
|
Crypto::PublicKey transactionPublicKey;
|
2015-04-06 16:13:07 +00:00
|
|
|
|
|
|
|
union {
|
2015-07-30 15:22:07 +00:00
|
|
|
Crypto::PublicKey outputKey; // Type: Key
|
2015-04-06 16:13:07 +00:00
|
|
|
uint32_t requiredSignatures; // Type: Multisignature
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TransactionSpentOutputInformation: public TransactionOutputInformation {
|
2015-07-30 15:22:07 +00:00
|
|
|
uint32_t spendingBlockHeight;
|
2015-04-06 16:13:07 +00:00
|
|
|
uint64_t timestamp;
|
2015-07-30 15:22:07 +00:00
|
|
|
Crypto::Hash spendingTransactionHash;
|
|
|
|
Crypto::KeyImage keyImage; //!< \attention Used only for TransactionTypes::OutputType::Key
|
2015-04-06 16:13:07 +00:00
|
|
|
uint32_t inputInTransaction;
|
|
|
|
};
|
|
|
|
|
|
|
|
class ITransfersContainer : public IStreamSerializable {
|
|
|
|
public:
|
|
|
|
enum Flags : uint32_t {
|
|
|
|
// state
|
|
|
|
IncludeStateUnlocked = 0x01,
|
|
|
|
IncludeStateLocked = 0x02,
|
|
|
|
IncludeStateSoftLocked = 0x04,
|
2015-08-27 18:55:14 +00:00
|
|
|
IncludeStateSpent = 0x08,
|
2015-04-06 16:13:07 +00:00
|
|
|
// output type
|
|
|
|
IncludeTypeKey = 0x100,
|
|
|
|
IncludeTypeMultisignature = 0x200,
|
|
|
|
// combinations
|
|
|
|
IncludeStateAll = 0xff,
|
|
|
|
IncludeTypeAll = 0xff00,
|
|
|
|
|
|
|
|
IncludeKeyUnlocked = IncludeTypeKey | IncludeStateUnlocked,
|
|
|
|
IncludeKeyNotUnlocked = IncludeTypeKey | IncludeStateLocked | IncludeStateSoftLocked,
|
|
|
|
|
|
|
|
IncludeAllLocked = IncludeTypeAll | IncludeStateLocked | IncludeStateSoftLocked,
|
|
|
|
IncludeAllUnlocked = IncludeTypeAll | IncludeStateUnlocked,
|
|
|
|
IncludeAll = IncludeTypeAll | IncludeStateAll,
|
|
|
|
|
|
|
|
IncludeDefault = IncludeKeyUnlocked
|
|
|
|
};
|
|
|
|
|
2015-08-27 18:55:14 +00:00
|
|
|
virtual size_t transfersCount() const = 0;
|
|
|
|
virtual size_t transactionsCount() const = 0;
|
|
|
|
virtual uint64_t balance(uint32_t flags = IncludeDefault) const = 0;
|
|
|
|
virtual void getOutputs(std::vector<TransactionOutputInformation>& transfers, uint32_t flags = IncludeDefault) const = 0;
|
2015-12-09 13:19:03 +00:00
|
|
|
virtual bool getTransactionInformation(const Crypto::Hash& transactionHash, TransactionInformation& info,
|
|
|
|
uint64_t* amountIn = nullptr, uint64_t* amountOut = nullptr) const = 0;
|
2015-08-27 18:55:14 +00:00
|
|
|
virtual std::vector<TransactionOutputInformation> getTransactionOutputs(const Crypto::Hash& transactionHash, uint32_t flags = IncludeDefault) const = 0;
|
|
|
|
//only type flags are feasible for this function
|
|
|
|
virtual std::vector<TransactionOutputInformation> getTransactionInputs(const Crypto::Hash& transactionHash, uint32_t flags) const = 0;
|
|
|
|
virtual void getUnconfirmedTransactions(std::vector<Crypto::Hash>& transactions) const = 0;
|
|
|
|
virtual std::vector<TransactionSpentOutputInformation> getSpentOutputs() const = 0;
|
2015-04-06 16:13:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|