aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-04-06 13:56:57 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-04-06 13:56:57 +0300
commitd97e9ef8a55f92841b30dd31807beb1c06ec264b (patch)
treec243bb45eb9eaee27e1d2ff299f978d6c31eda07 /src/wallet
parentWallet::createTransaction API introduced (diff)
downloadmonero-d97e9ef8a55f92841b30dd31807beb1c06ec264b.tar.xz
Transaction API continued
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2_api.cpp24
-rw-r--r--src/wallet/wallet2_api.h1
2 files changed, 21 insertions, 4 deletions
diff --git a/src/wallet/wallet2_api.cpp b/src/wallet/wallet2_api.cpp
index ae26a1eb3..3947084e3 100644
--- a/src/wallet/wallet2_api.cpp
+++ b/src/wallet/wallet2_api.cpp
@@ -81,6 +81,7 @@ public:
int status() const;
std::string errorString() const;
bool commit();
+ uint64_t amount() const;
uint64_t dust() const;
uint64_t fee() const;
// TODO: continue with interface;
@@ -365,11 +366,13 @@ Transaction *WalletImpl::createTransaction(const string &dst_addr, uint64_t amou
bool has_payment_id;
bool payment_id_seen = false;
crypto::hash8 new_payment_id;
+ // TODO: how this number affects (https://bitcointalk.org/index.php?topic=753252.msg9985441#msg9985441)
size_t fake_outs_count = m_wallet->default_mixin();
if (fake_outs_count == 0)
fake_outs_count = DEFAULT_MIX;
TransactionImpl * transaction = new TransactionImpl(this);
+
do {
if(!cryptonote::get_account_integrated_address_from_str(de.addr, has_payment_id, new_payment_id, m_wallet->testnet(), dst_addr)) {
@@ -377,7 +380,6 @@ Transaction *WalletImpl::createTransaction(const string &dst_addr, uint64_t amou
m_status = Status_Error;
m_errorString = "Invalid destination address";
break;
-
}
de.amount = amount;
@@ -510,6 +512,9 @@ string TransactionImpl::errorString() const
bool TransactionImpl::commit()
{
+
+ LOG_PRINT_L0("m_pending_tx size: " << m_pending_tx.size());
+ assert(m_pending_tx.size() == 1);
try {
while (!m_pending_tx.empty()) {
auto & ptx = m_pending_tx.back();
@@ -541,10 +546,21 @@ bool TransactionImpl::commit()
return m_status == Status_Ok;
}
+uint64_t TransactionImpl::amount() const
+{
+ uint64_t result = 0;
+ for (const auto &ptx : m_pending_tx) {
+ for (const auto &dest : ptx.dests) {
+ result += dest.amount;
+ }
+ }
+ return result;
+}
+
uint64_t TransactionImpl::dust() const
{
uint32_t result = 0;
- for (auto ptx : m_pending_tx) {
+ for (const auto & ptx : m_pending_tx) {
result += ptx.dust;
}
return result;
@@ -553,7 +569,7 @@ uint64_t TransactionImpl::dust() const
uint64_t TransactionImpl::fee() const
{
uint32_t result = 0;
- for (auto ptx : m_pending_tx) {
+ for (const auto ptx : m_pending_tx) {
result += ptx.fee;
}
return result;
@@ -638,7 +654,7 @@ WalletManager *WalletManagerFactory::getWalletManager()
{
if (!g_walletManager) {
- epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL, LOG_LEVEL_0);
+ epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL, LOG_LEVEL_MAX);
g_walletManager = new WalletManagerImpl();
}
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index c85cda2de..c064aeba8 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -49,6 +49,7 @@ struct Transaction
virtual int status() const = 0;
virtual std::string errorString() const = 0;
virtual bool commit() = 0;
+ virtual uint64_t amount() const = 0;
virtual uint64_t dust() const = 0;
virtual uint64_t fee() const = 0;
};