More methods

This commit is contained in:
Neozaru 2014-06-17 09:10:23 +02:00
parent c1ea0ef1fc
commit 46417193b9
2 changed files with 40 additions and 1 deletions

View File

@ -70,6 +70,33 @@ amount_t Wallet::getUnlockedBalance() const {
return fromMini(getUnlockedBalanceMini());
}
const std::vector<Transfer> Wallet::getIncomingTransfers() const {
std::vector<Transfer> 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) {

View File

@ -1,7 +1,8 @@
#pragma once
#include <string>
// #include <inttypes.h>
#include <vector>
#include <inttypes.h>
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<Transfer> getIncomingTransfers() const;
private:
tools::wallet2* wallet_impl;