From 613f3492a12a5f317e6edc611bb7ac8cd08e746f Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 11 Jul 2019 12:37:44 -0400 Subject: [PATCH] only set numBlocksToUnlock to non-zero if subaddress has balance --- src/wallet/MoneroWallet.cpp | 4 ++-- src/wallet/MoneroWallet.h | 2 +- todo.txt | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index e3160cc..204f518 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -2252,7 +2252,7 @@ namespace monero { } // private helper to initialize subaddresses using transfer details - vector MoneroWallet::getSubaddressesAux(const uint32_t accountIdx, vector subaddressIndices, vector transfers) const { + vector MoneroWallet::getSubaddressesAux(const uint32_t accountIdx, vector subaddressIndices, const vector& transfers) const { vector subaddresses; // get balances per subaddress as maps @@ -2282,7 +2282,7 @@ namespace monero { cryptonote::subaddress_index index = {accountIdx, subaddressIdx}; subaddress.numUnspentOutputs = count_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return !td.m_spent && td.m_subaddr_index == index; }); subaddress.isUsed = find_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return td.m_subaddr_index == index; }) != transfers.end(); - subaddress.numBlocksToUnlock = subaddress.isUsed.get() ? iter2->second.second : 0; + subaddress.numBlocksToUnlock = iter2 == balancePerSubaddress.end() ? 0 : iter2->second.second; subaddresses.push_back(subaddress); } diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index 8096a36..100b293 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -1142,6 +1142,6 @@ namespace monero { boost::optional listener = boost::none; // wallet's external listener MoneroSyncResult syncAux(boost::optional startHeight, boost::optional endHeight, boost::optional listener); - vector getSubaddressesAux(uint32_t accountIdx, vector subaddressIndices, vector transfers) const; + vector getSubaddressesAux(uint32_t accountIdx, vector subaddressIndices, const vector& transfers) const; }; } diff --git a/todo.txt b/todo.txt index f66766a..361d829 100644 --- a/todo.txt +++ b/todo.txt @@ -3,8 +3,6 @@ shared_ptr(new Foo()) vs make_shared strong vs weak references cannot reconcile integrals on getTransfers() test, need to add reconcile debug info including vals and pass error message testGetTransfers() cannot reconcile integrals: new MoneroTransferRequest().setAccountIndex(subaddress.getAccountIndex()).setSubaddressIndex(subaddress.getIndex()) -tx c40d5dbf49172a1a42111e414ee243e8c7a45cf0c09c5d91c5cef21672145755 should have outgoing but does not according to jni -tx 121158a7e51044e27de6958a9501cc9eba811b2e37bc651ab9a04e749d11cc38 should have outgoing but does not according to rpc comb code todos MEDIUM PRIORITY