2015-05-27 12:08:46 +00:00
|
|
|
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
|
2014-08-13 10:38:35 +00:00
|
|
|
//
|
|
|
|
// This file is part of Bytecoin.
|
|
|
|
//
|
|
|
|
// Bytecoin is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Bytecoin 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 Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
|
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-04-06 16:13:07 +00:00
|
|
|
WalletUserTransactionsCache() {}
|
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
|
|
|
|
|
|
|
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
|