Wallet API: transaction history in progress

This commit is contained in:
Ilya Kitaev 2016-04-22 13:33:09 +03:00
parent 02c9df5de2
commit 53a97bdcd3
5 changed files with 19 additions and 11 deletions

View file

@ -103,6 +103,7 @@ void TransactionHistoryImpl::refresh()
ti->m_amount = pd.m_amount; ti->m_amount = pd.m_amount;
ti->m_direction = TransactionInfo::Direction_In; ti->m_direction = TransactionInfo::Direction_In;
ti->m_hash = string_tools::pod_to_hex(pd.m_tx_hash); ti->m_hash = string_tools::pod_to_hex(pd.m_tx_hash);
ti->m_blockheight = pd.m_block_height;
// TODO: // TODO:
// ti->m_timestamp = pd.m_timestamp; // ti->m_timestamp = pd.m_timestamp;
m_history.push_back(ti); m_history.push_back(ti);

View file

@ -62,37 +62,42 @@ int TransactionInfoImpl::direction() const
bool TransactionInfoImpl::isHold() const bool TransactionInfoImpl::isHold() const
{ {
return false; return m_hold;
} }
bool TransactionInfoImpl::isFailed() const bool TransactionInfoImpl::isFailed() const
{ {
return false; return m_failed;
} }
uint64_t TransactionInfoImpl::amount() const uint64_t TransactionInfoImpl::amount() const
{ {
return 0; return m_amount;
} }
uint64_t TransactionInfoImpl::fee() const uint64_t TransactionInfoImpl::fee() const
{ {
return 0; return m_fee;
}
uint64_t TransactionInfoImpl::blockHeight() const
{
return m_blockheight;
} }
string TransactionInfoImpl::hash() const string TransactionInfoImpl::hash() const
{ {
return ""; return m_hash;
} }
std::time_t TransactionInfoImpl::timestamp() const std::time_t TransactionInfoImpl::timestamp() const
{ {
return std::time_t(0); return m_timestamp;
} }
string TransactionInfoImpl::paymentId() const string TransactionInfoImpl::paymentId() const
{ {
return ""; return m_paymentid;
} }
} // namespace } // namespace

View file

@ -49,6 +49,7 @@ public:
virtual uint64_t amount() const; virtual uint64_t amount() const;
//! always 0 for incoming txes //! always 0 for incoming txes
virtual uint64_t fee() const; virtual uint64_t fee() const;
virtual uint64_t blockHeight() const;
virtual std::string hash() const; virtual std::string hash() const;
virtual std::time_t timestamp() const; virtual std::time_t timestamp() const;

View file

@ -71,6 +71,7 @@ struct TransactionInfo
virtual bool isFailed() const = 0; virtual bool isFailed() const = 0;
virtual uint64_t amount() const = 0; virtual uint64_t amount() const = 0;
virtual uint64_t fee() const = 0; virtual uint64_t fee() const = 0;
virtual uint64_t blockHeight() const = 0;
virtual std::string hash() const = 0; virtual std::string hash() const = 0;
virtual std::time_t timestamp() const = 0; virtual std::time_t timestamp() const = 0;
virtual std::string paymentId() const = 0; virtual std::string paymentId() const = 0;

View file

@ -31,7 +31,6 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "wallet/wallet2_api.h" #include "wallet/wallet2_api.h"
#include "cryptonote_core/cryptonote_format_utils.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
@ -299,8 +298,11 @@ TEST_F(WalletManagerTest, WalletHistory)
auto transaction_print = [=] (Bitmonero::TransactionInfo * t) { auto transaction_print = [=] (Bitmonero::TransactionInfo * t) {
std::cout << "d: " std::cout << "d: "
<< (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out") << (t->direction() == Bitmonero::TransactionInfo::Direction_In ? "in" : "out")
<< ", a: " << t->amount() << ", bh: " << t->blockHeight()
<< ", a: " << Bitmonero::Wallet::displayAmount(t->amount())
<< ", f: " << Bitmonero::Wallet::displayAmount(t->fee())
<< ", h: " << t->hash() << ", h: " << t->hash()
<< ", pid: " << t->paymentId()
<< std::endl; << std::endl;
}; };
@ -308,8 +310,6 @@ TEST_F(WalletManagerTest, WalletHistory)
ASSERT_TRUE(t != nullptr); ASSERT_TRUE(t != nullptr);
transaction_print(t); transaction_print(t);
} }
} }