diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ea129d510..0bbf6b8ba 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3032,11 +3032,13 @@ UniValue getalldata(const UniValue& params, bool fHelp,const CPubKey&) } //Create Ordered List - map orderedTxs; + // Pointers into mapWallet, not copies (a CWalletTx copy deep-copies every note's witness list). + // As before, the first tx inserted for an nOrderPos wins. + map orderedTxs; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const uint256& wtxid = it->first; const CWalletTx& wtx = (*it).second; - orderedTxs.insert(std::pair(wtx.nOrderPos, wtx)); + orderedTxs.insert(std::make_pair(wtx.nOrderPos, &wtx)); unsigned int txType = 0; // 0 Unassigend @@ -3229,9 +3231,9 @@ UniValue getalldata(const UniValue& params, bool fHelp,const CPubKey&) uint64_t t = GetTime(); - for (map::reverse_iterator it = orderedTxs.rbegin(); it != orderedTxs.rend(); ++it) + for (map::reverse_iterator it = orderedTxs.rbegin(); it != orderedTxs.rend(); ++it) { - const CWalletTx& wtx = (*it).second; + const CWalletTx& wtx = *(*it).second; if (!CheckFinalTx(wtx)) continue; @@ -3515,17 +3517,19 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey& throw runtime_error("Filter must be greater that 0."); //Created Ordered Transaction Map - map orderedTxs; + // Pointers into mapWallet, not copies (a CWalletTx copy deep-copies every note's witness list). + // As before, the first tx inserted for an nOrderPos wins. + map orderedTxs; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - orderedTxs.insert(std::pair(wtx.nOrderPos, wtx)); + orderedTxs.insert(std::make_pair(wtx.nOrderPos, &wtx)); } uint64_t t = GetTime(); //Reverse Iterate thru transactions - for (map::reverse_iterator it = orderedTxs.rbegin(); it != orderedTxs.rend(); ++it) { - const CWalletTx& wtx = (*it).second; + for (map::reverse_iterator it = orderedTxs.rbegin(); it != orderedTxs.rend(); ++it) { + const CWalletTx& wtx = *(*it).second; bool includeTransaction = true; //Excude transactions with less confirmations than required @@ -3698,17 +3702,19 @@ UniValue z_listsentbyaddress(const UniValue& params, bool fHelp,const CPubKey&) throw runtime_error("Filter must be greater that 0."); //Created Ordered Transaction Map - map orderedTxs; + // Pointers into mapWallet, not copies (a CWalletTx copy deep-copies every note's witness list). + // As before, the first tx inserted for an nOrderPos wins. + map orderedTxs; for (map::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; - orderedTxs.insert(std::pair(wtx.nOrderPos, wtx)); + orderedTxs.insert(std::make_pair(wtx.nOrderPos, &wtx)); } uint64_t t = GetTime(); //Reverse Iterate thru transactions - for (map::reverse_iterator it = orderedTxs.rbegin(); it != orderedTxs.rend(); ++it) { - const CWalletTx& wtx = (*it).second; + for (map::reverse_iterator it = orderedTxs.rbegin(); it != orderedTxs.rend(); ++it) { + const CWalletTx& wtx = *(*it).second; if (!CheckFinalTx(wtx)) continue;