From 46417193b9f449858c75c004d7d55ea9fef7357e Mon Sep 17 00:00:00 2001 From: Neozaru Date: Tue, 17 Jun 2014 09:10:23 +0200 Subject: [PATCH] More methods --- src/monero_wallet_wrapper/MoneroWallet.cc | 27 +++++++++++++++++++++++ src/monero_wallet_wrapper/MoneroWallet.hh | 14 +++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/monero_wallet_wrapper/MoneroWallet.cc b/src/monero_wallet_wrapper/MoneroWallet.cc index f2621a857..335c24b08 100644 --- a/src/monero_wallet_wrapper/MoneroWallet.cc +++ b/src/monero_wallet_wrapper/MoneroWallet.cc @@ -70,6 +70,33 @@ amount_t Wallet::getUnlockedBalance() const { return fromMini(getUnlockedBalanceMini()); } +const std::vector Wallet::getIncomingTransfers() const { + + std::vector lTransfers; + + tools::wallet2::transfer_container lIncomingTransfers; + + + /* TODO : Throw exception */ + wallet_impl->get_transfers(lIncomingTransfers); + + + for(tools::wallet2::transfer_details lTransferDetail : lIncomingTransfers) { + Transfer lTransfer; + lTransfer.block_height = lTransferDetail.m_block_height; + lTransfer.global_output_index = lTransferDetail.m_global_output_index; + lTransfer.local_output_index = lTransferDetail.m_internal_output_index; + lTransfer.spent = lTransferDetail.m_spent; + lTransfer.amount_mini = lTransferDetail.amount(); + + lTransfer.amount = fromMini(lTransfer.amount_mini); + + lTransfers.push_back(lTransfer); + } + + return lTransfers; + +} bool Wallet::walletExists(const std::string pWalletFile, bool& oWallet_data_exists, bool& oWallet_keys_exist) { diff --git a/src/monero_wallet_wrapper/MoneroWallet.hh b/src/monero_wallet_wrapper/MoneroWallet.hh index dc36f71b0..5e0ace5f5 100644 --- a/src/monero_wallet_wrapper/MoneroWallet.hh +++ b/src/monero_wallet_wrapper/MoneroWallet.hh @@ -1,7 +1,8 @@ #pragma once #include -// #include +#include +#include namespace tools { class wallet2; } @@ -44,6 +45,15 @@ namespace Errors { } +struct Transfer { + uint64_t block_height; + uint64_t global_output_index; + size_t local_output_index; + bool spent; + amount_mini_t amount_mini; + amount_t amount; +}; + class Wallet { public: @@ -63,6 +73,8 @@ public: static bool walletExists(const std::string pWalletFile, bool& oWallet_data_exists, bool& oWallet_keys_exist); static Wallet generateWallet(const std::string pWalletFile, const std::string& pWalletPassword); + const std::vector getIncomingTransfers() const; + private: tools::wallet2* wallet_impl;