X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fwallet.cpp;h=2455b272488ca34727b73fc80b801bdc2a7f4f34;hb=63e4509c569f16145ab861717baf865fc6d05af1;hp=0d0cf99dedd852052561c827dd1994bbb63072bc;hpb=27e35b80c7f1b1bbf43f1d7b719a2569e8149f9f;p=novacoin.git diff --git a/src/wallet.cpp b/src/wallet.cpp index 0d0cf99..2455b27 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -773,7 +773,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl CWalletTx wtx(this,tx); // Get merkle branch if transaction was found in a block if (pblock) - wtx.SetMerkleBranch(*pblock); + wtx.SetMerkleBranch(pblock); return AddToWallet(wtx); } else @@ -1888,7 +1888,8 @@ bool CWallet::SelectCoinsMinConf(int64_t nTargetValue, unsigned int nSpendTime, } // Solve subset sum by stochastic approximation - sort(vValue.rbegin(), vValue.rend(), CompareValueOnly()); + std::sort(vValue.begin(), vValue.end(), CompareValueOnly()); + std::reverse(vValue.begin(), vValue.end()); vector vfBest; int64_t nBest; @@ -2885,29 +2886,38 @@ set< set > CWallet::GetAddressGroupings() { CWalletTx *pcoin = &walletEntry.second; - if (pcoin->vin.size() > 0 && IsMine(pcoin->vin[0])) + if (pcoin->vin.size() > 0) { + bool any_mine = false; // group all input addresses with each other BOOST_FOREACH(CTxIn txin, pcoin->vin) { CBitcoinAddress address; + if(!IsMine(txin)) // If this input isn't mine, ignore it + continue; if(!ExtractAddress(*this, mapWallet[txin.prevout.hash].vout[txin.prevout.n].scriptPubKey, address)) continue; grouping.insert(address); + any_mine = true; } // group change with input addresses - BOOST_FOREACH(CTxOut txout, pcoin->vout) + if (any_mine) + { + BOOST_FOREACH(CTxOut txout, pcoin->vout) if (IsChange(txout)) { - CWalletTx tx = mapWallet[pcoin->vin[0].prevout.hash]; CBitcoinAddress txoutAddr; if(!ExtractAddress(*this, txout.scriptPubKey, txoutAddr)) continue; grouping.insert(txoutAddr); } - groupings.insert(grouping); - grouping.clear(); + } + if (!grouping.empty()) + { + groupings.insert(grouping); + grouping.clear(); + } } // group lone addrs by themselves