2015-04-23 16:07:22 +00:00
|
|
|
// Copyright (c) 2011-2015 The Cryptonote developers
|
2014-06-25 17:21:42 +00:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-08-13 10:51:37 +00:00
|
|
|
#include "cryptonote_core/account.h"
|
|
|
|
#include "cryptonote_core/Currency.h"
|
|
|
|
|
2014-06-25 17:21:42 +00:00
|
|
|
#include "INode.h"
|
|
|
|
#include "WalletSendTransactionContext.h"
|
|
|
|
#include "WalletUserTransactionsCache.h"
|
|
|
|
#include "WalletUnconfirmedTransactions.h"
|
|
|
|
#include "WalletRequest.h"
|
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
#include "ITransfersContainer.h"
|
|
|
|
|
2014-06-25 17:21:42 +00:00
|
|
|
namespace CryptoNote {
|
|
|
|
|
|
|
|
class WalletTransactionSender
|
|
|
|
{
|
|
|
|
public:
|
2015-04-06 16:13:07 +00:00
|
|
|
WalletTransactionSender(const cryptonote::Currency& currency, WalletUserTransactionsCache& transactionsCache, cryptonote::account_keys keys, ITransfersContainer& transfersContainer);
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
void init(cryptonote::account_keys keys, ITransfersContainer& transfersContainer);
|
2014-06-25 17:21:42 +00:00
|
|
|
void stop();
|
|
|
|
|
|
|
|
std::shared_ptr<WalletRequest> makeSendRequest(TransactionId& transactionId, std::deque<std::shared_ptr<WalletEvent> >& events, const std::vector<Transfer>& transfers,
|
|
|
|
uint64_t fee, const std::string& extra = "", uint64_t mixIn = 0, uint64_t unlockTimestamp = 0);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::shared_ptr<WalletRequest> makeGetRandomOutsRequest(std::shared_ptr<SendTransactionContext> context);
|
|
|
|
std::shared_ptr<WalletRequest> doSendTransaction(std::shared_ptr<SendTransactionContext> context, std::deque<std::shared_ptr<WalletEvent> >& events);
|
2015-04-06 16:13:07 +00:00
|
|
|
void prepareInputs(const std::list<TransactionOutputInformation>& selectedTransfers, std::vector<cryptonote::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::outs_for_amount>& outs,
|
2014-06-25 17:21:42 +00:00
|
|
|
std::vector<cryptonote::tx_source_entry>& sources, uint64_t mixIn);
|
|
|
|
void splitDestinations(TransferId firstTransferId, size_t transfersCount, const cryptonote::tx_destination_entry& changeDts,
|
|
|
|
const TxDustPolicy& dustPolicy, std::vector<cryptonote::tx_destination_entry>& splittedDests);
|
|
|
|
void digitSplitStrategy(TransferId firstTransferId, size_t transfersCount, const cryptonote::tx_destination_entry& change_dst, uint64_t dust_threshold,
|
|
|
|
std::vector<cryptonote::tx_destination_entry>& splitted_dsts, uint64_t& dust);
|
|
|
|
void sendTransactionRandomOutsByAmount(std::shared_ptr<SendTransactionContext> context, std::deque<std::shared_ptr<WalletEvent> >& events,
|
|
|
|
boost::optional<std::shared_ptr<WalletRequest> >& nextRequest, std::error_code ec);
|
2015-04-06 16:13:07 +00:00
|
|
|
void relayTransactionCallback(std::shared_ptr<SendTransactionContext> context, std::deque<std::shared_ptr<WalletEvent> >& events,
|
2014-06-25 17:21:42 +00:00
|
|
|
boost::optional<std::shared_ptr<WalletRequest> >& nextRequest, std::error_code ec);
|
|
|
|
void notifyBalanceChanged(std::deque<std::shared_ptr<WalletEvent> >& events);
|
|
|
|
|
2014-08-13 10:51:37 +00:00
|
|
|
void validateTransfersAddresses(const std::vector<Transfer>& transfers);
|
|
|
|
bool validateDestinationAddress(const std::string& address);
|
2014-06-25 17:21:42 +00:00
|
|
|
|
2015-04-06 16:13:07 +00:00
|
|
|
uint64_t selectTransfersToSend(uint64_t neededMoney, bool addDust, uint64_t dust, std::list<TransactionOutputInformation>& selectedTransfers);
|
|
|
|
|
2014-08-13 10:51:37 +00:00
|
|
|
const cryptonote::Currency& m_currency;
|
2014-06-25 17:21:42 +00:00
|
|
|
cryptonote::account_keys m_keys;
|
|
|
|
WalletUserTransactionsCache& m_transactionsCache;
|
|
|
|
uint64_t m_upperTransactionSizeLimit;
|
|
|
|
|
|
|
|
bool m_isStoping;
|
2015-04-06 16:13:07 +00:00
|
|
|
ITransfersContainer& m_transferDetails;
|
2014-06-25 17:21:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace CryptoNote */
|