From 171332e49930b498e6ff6dbf354c11b6ce6e9c11 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 30 May 2019 17:35:54 -0400 Subject: [PATCH] getAccounts() returns accounts with correct index --- src/wallet/MoneroWallet.cpp | 39 +++++++++++++++++++++++++++---------- src/wallet/MoneroWallet.h | 8 ++++---- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index 3bc4132..a25eed5 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -250,20 +250,39 @@ namespace monero { // isMultisigImportNeeded - list MoneroWallet::getAccounts() const { + vector MoneroWallet::getAccounts() const { cout << "getAccounts()" << endl; + vector accounts; + for (uint32_t accountIdx = 0; accountIdx < wallet2->get_num_subaddress_accounts(); accountIdx++) { + MoneroAccount account; + account.index = accountIdx; + accounts.push_back(account); + } + return accounts; + } + + vector MoneroWallet::getAccounts(const bool includeSubaddresses) const { + throw runtime_error("Not implemented"); + + cout << "getAccounts(includeSubaddresses)" << endl; + vector accounts; + for (uint32_t accountIdx = 0; accountIdx < wallet2->get_num_subaddress_accounts(); accountIdx++) { + MoneroAccount account; + account.index = accountIdx; + accounts.push_back(account); +// // build subaddresses +// for (uint32_t subaddressIdx = 0; subaddressIdx < wallet2->get_num_subaddresses(accountIdx); subaddressIdx++) { +// cout << "Account " << accountIdx << ", " << subaddressIdx << endl; +// } + } + return accounts; + } + + vector MoneroWallet::getAccounts(const string tag) const { throw runtime_error("Not implemented"); } - list MoneroWallet::getAccounts(const bool includeSubaddresses) const { - throw runtime_error("Not implemented"); - } - - list MoneroWallet::getAccounts(const string tag) const { - throw runtime_error("Not implemented"); - } - - list MoneroWallet::getAccounts(const bool includeSubaddresses, const string tag) const { + vector MoneroWallet::getAccounts(const bool includeSubaddresses, const string tag) const { throw runtime_error("Not implemented"); } diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index b893c5e..54cc9bc 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -338,7 +338,7 @@ namespace monero { * * @return List are all accounts within the wallet */ - list getAccounts() const; + vector getAccounts() const; /** * Get all accounts. @@ -346,7 +346,7 @@ namespace monero { * @param includeSubaddresses specifies if subaddresses should be included * @return List are all accounts */ - list getAccounts(const bool includeSubaddresses) const; + vector getAccounts(const bool includeSubaddresses) const; /** * Get accounts with a given tag. @@ -354,7 +354,7 @@ namespace monero { * @param tag is the tag for filtering accounts, all accounts if null * @return List are all accounts for the wallet with the given tag */ - list getAccounts(const string tag) const; + vector getAccounts(const string tag) const; /** * Get accounts with a given tag. @@ -363,7 +363,7 @@ namespace monero { * @param tag is the tag for filtering accounts, all accounts if null * @return List are all accounts for the wallet with the given tag */ - list getAccounts(const bool includeSubaddresses, const string tag) const; + vector getAccounts(const bool includeSubaddresses, const string tag) const; /** * Get an account without subaddress information.