2016-01-18 15:33:29 +00:00
|
|
|
// Copyright (c) 2011-2016 The Cryptonote developers
|
2015-09-18 11:55:31 +00:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2014-06-25 17:21:42 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "crypto/hash.h"
|
2015-07-30 15:22:07 +00:00
|
|
|
#include "IWalletLegacy.h"
|
2015-04-06 16:13:07 +00:00
|
|
|
#include "ITransfersContainer.h"
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
#include "WalletLegacy/WalletLegacyEvent.h"
|
|
|
|
#include "WalletLegacy/WalletUnconfirmedTransactions.h"
|
2015-04-06 16:13:07 +00:00
|
|
|
|
2015-05-27 12:08:46 +00:00
|
|
|
namespace CryptoNote {
|
2015-04-06 16:13:07 +00:00
|
|
|
class ISerializer;
|
|
|
|
}
|
2014-06-25 17:21:42 +00:00
|
|
|
|
|
|
|
namespace CryptoNote {
|
|
|
|
|
|
|
|
class WalletUserTransactionsCache
|
|
|
|
{
|
|
|
|
public:
|
2015-08-05 13:09:05 +00:00
|
|
|
explicit WalletUserTransactionsCache(uint64_t mempoolTxLiveTime = 60 * 60 * 24);
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-07-15 12:23:00 +00:00
|
|
|
bool serialize(CryptoNote::ISerializer& serializer);
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
uint64_t unconfirmedTransactionsAmount() const;
|
|
|
|
uint64_t unconfrimedOutsAmount() const;
|
2014-06-25 17:21:42 +00:00
|
|
|
size_t getTransactionCount() const;
|
|
|
|
size_t getTransferCount() const;
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
TransactionId addNewTransaction(uint64_t amount, uint64_t fee, const std::string& extra, const std::vector<WalletLegacyTransfer>& transfers, uint64_t unlockTime);
|
2015-05-27 12:08:46 +00:00
|
|
|
void updateTransaction(TransactionId transactionId, const CryptoNote::Transaction& tx, uint64_t amount, const std::list<TransactionOutputInformation>& usedOutputs);
|
2015-04-06 16:13:07 +00:00
|
|
|
void updateTransactionSendingState(TransactionId transactionId, std::error_code ec);
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
std::shared_ptr<WalletLegacyEvent> onTransactionUpdated(const TransactionInformation& txInfo, int64_t txBalance);
|
|
|
|
std::shared_ptr<WalletLegacyEvent> onTransactionDeleted(const Crypto::Hash& transactionHash);
|
2015-04-06 16:13:07 +00:00
|
|
|
|
2014-06-25 17:21:42 +00:00
|
|
|
TransactionId findTransactionByTransferId(TransferId transferId) const;
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
bool getTransaction(TransactionId transactionId, WalletLegacyTransaction& transaction) const;
|
|
|
|
WalletLegacyTransaction& getTransaction(TransactionId transactionId);
|
|
|
|
bool getTransfer(TransferId transferId, WalletLegacyTransfer& transfer) const;
|
|
|
|
WalletLegacyTransfer& getTransfer(TransferId transferId);
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
bool isUsed(const TransactionOutputInformation& out) const;
|
2015-07-09 14:52:47 +00:00
|
|
|
void reset();
|
2015-04-06 16:13:07 +00:00
|
|
|
|
2015-08-05 13:09:05 +00:00
|
|
|
std::vector<TransactionId> deleteOutdatedTransactions();
|
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
private:
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
TransactionId findTransactionByHash(const Crypto::Hash& hash);
|
|
|
|
TransactionId insertTransaction(WalletLegacyTransaction&& Transaction);
|
|
|
|
TransferId insertTransfers(const std::vector<WalletLegacyTransfer>& transfers);
|
2015-04-06 16:13:07 +00:00
|
|
|
void updateUnconfirmedTransactions();
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
typedef std::vector<WalletLegacyTransfer> UserTransfers;
|
|
|
|
typedef std::vector<WalletLegacyTransaction> UserTransactions;
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
void getGoodItems(UserTransactions& transactions, UserTransfers& transfers);
|
|
|
|
void getGoodTransaction(TransactionId txId, size_t offset, UserTransactions& transactions, UserTransfers& transfers);
|
2014-06-25 17:21:42 +00:00
|
|
|
|
|
|
|
void getTransfersByTx(TransactionId id, UserTransfers& transfers);
|
|
|
|
|
|
|
|
UserTransactions m_transactions;
|
|
|
|
UserTransfers m_transfers;
|
2015-04-06 16:13:07 +00:00
|
|
|
WalletUnconfirmedTransactions m_unconfirmedTransactions;
|
2014-06-25 17:21:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace CryptoNote
|