|
|
@ -297,7 +297,7 @@ bool CWallet::Unlock(const SecureString& strWalletPassphrase) |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) |
|
|
|
for (const MasterKeyMap::value_type& pMasterKey : mapMasterKeys) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) |
|
|
|
if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -320,7 +320,7 @@ bool CWallet::ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, |
|
|
|
|
|
|
|
|
|
|
|
CCrypter crypter; |
|
|
|
CCrypter crypter; |
|
|
|
CKeyingMaterial _vMasterKey; |
|
|
|
CKeyingMaterial _vMasterKey; |
|
|
|
BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys) |
|
|
|
for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) |
|
|
|
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -412,7 +412,7 @@ std::set<uint256> CWallet::GetConflicts(const uint256& txid) const |
|
|
|
|
|
|
|
|
|
|
|
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range; |
|
|
|
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range; |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) |
|
|
|
for (const CTxIn& txin : wtx.tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mapTxSpends.count(txin.prevout) <= 1) |
|
|
|
if (mapTxSpends.count(txin.prevout) <= 1) |
|
|
|
continue; // No conflict if zero or one spends
|
|
|
|
continue; // No conflict if zero or one spends
|
|
|
@ -544,7 +544,7 @@ void CWallet::AddToSpends(const uint256& wtxid) |
|
|
|
if (thisTx.IsCoinBase()) // Coinbases don't spend anything!
|
|
|
|
if (thisTx.IsCoinBase()) // Coinbases don't spend anything!
|
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, thisTx.tx->vin) |
|
|
|
for (const CTxIn& txin : thisTx.tx->vin) |
|
|
|
AddToSpends(txin.prevout, wtxid); |
|
|
|
AddToSpends(txin.prevout, wtxid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -659,7 +659,7 @@ DBErrors CWallet::ReorderTransactions() |
|
|
|
} |
|
|
|
} |
|
|
|
std::list<CAccountingEntry> acentries; |
|
|
|
std::list<CAccountingEntry> acentries; |
|
|
|
walletdb.ListAccountCreditDebit("", acentries); |
|
|
|
walletdb.ListAccountCreditDebit("", acentries); |
|
|
|
BOOST_FOREACH(CAccountingEntry& entry, acentries) |
|
|
|
for (CAccountingEntry& entry : acentries) |
|
|
|
{ |
|
|
|
{ |
|
|
|
txByTime.insert(std::make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); |
|
|
|
txByTime.insert(std::make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); |
|
|
|
} |
|
|
|
} |
|
|
@ -689,7 +689,7 @@ DBErrors CWallet::ReorderTransactions() |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
int64_t nOrderPosOff = 0; |
|
|
|
int64_t nOrderPosOff = 0; |
|
|
|
BOOST_FOREACH(const int64_t& nOffsetStart, nOrderPosOffsets) |
|
|
|
for (const int64_t& nOffsetStart : nOrderPosOffsets) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (nOrderPos >= nOffsetStart) |
|
|
|
if (nOrderPos >= nOffsetStart) |
|
|
|
++nOrderPosOff; |
|
|
|
++nOrderPosOff; |
|
|
@ -778,7 +778,7 @@ bool CWallet::GetAccountPubkey(CPubKey &pubKey, std::string strAccount, bool bFo |
|
|
|
for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin(); |
|
|
|
for (std::map<uint256, CWalletTx>::iterator it = mapWallet.begin(); |
|
|
|
it != mapWallet.end() && account.vchPubKey.IsValid(); |
|
|
|
it != mapWallet.end() && account.vchPubKey.IsValid(); |
|
|
|
++it) |
|
|
|
++it) |
|
|
|
BOOST_FOREACH(const CTxOut& txout, (*it).second.tx->vout) |
|
|
|
for (const CTxOut& txout : (*it).second.tx->vout) |
|
|
|
if (txout.scriptPubKey == scriptPubKey) { |
|
|
|
if (txout.scriptPubKey == scriptPubKey) { |
|
|
|
bForceNew = true; |
|
|
|
bForceNew = true; |
|
|
|
break; |
|
|
|
break; |
|
|
@ -804,7 +804,7 @@ void CWallet::MarkDirty() |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) |
|
|
|
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) |
|
|
|
item.second.MarkDirty(); |
|
|
|
item.second.MarkDirty(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -922,7 +922,7 @@ bool CWallet::LoadToWallet(const CWalletTx& wtxIn) |
|
|
|
wtx.BindWallet(this); |
|
|
|
wtx.BindWallet(this); |
|
|
|
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); |
|
|
|
wtxOrdered.insert(std::make_pair(wtx.nOrderPos, TxPair(&wtx, (CAccountingEntry*)0))); |
|
|
|
AddToSpends(hash); |
|
|
|
AddToSpends(hash); |
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) { |
|
|
|
for (const CTxIn& txin : wtx.tx->vin) { |
|
|
|
if (mapWallet.count(txin.prevout.hash)) { |
|
|
|
if (mapWallet.count(txin.prevout.hash)) { |
|
|
|
CWalletTx& prevtx = mapWallet[txin.prevout.hash]; |
|
|
|
CWalletTx& prevtx = mapWallet[txin.prevout.hash]; |
|
|
|
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { |
|
|
|
if (prevtx.nIndex == -1 && !prevtx.hashUnset()) { |
|
|
@ -954,7 +954,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransactionRef& ptx, const CBlockI |
|
|
|
AssertLockHeld(cs_wallet); |
|
|
|
AssertLockHeld(cs_wallet); |
|
|
|
|
|
|
|
|
|
|
|
if (pIndex != NULL) { |
|
|
|
if (pIndex != NULL) { |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) { |
|
|
|
for (const CTxIn& txin : tx.vin) { |
|
|
|
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(txin.prevout); |
|
|
|
std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range = mapTxSpends.equal_range(txin.prevout); |
|
|
|
while (range.first != range.second) { |
|
|
|
while (range.first != range.second) { |
|
|
|
if (range.first->second != tx.GetHash()) { |
|
|
|
if (range.first->second != tx.GetHash()) { |
|
|
@ -1035,7 +1035,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx) |
|
|
|
} |
|
|
|
} |
|
|
|
// If a transaction changes 'conflicted' state, that changes the balance
|
|
|
|
// If a transaction changes 'conflicted' state, that changes the balance
|
|
|
|
// available of the outputs it spends. So force those to be recomputed
|
|
|
|
// available of the outputs it spends. So force those to be recomputed
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) |
|
|
|
for (const CTxIn& txin : wtx.tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mapWallet.count(txin.prevout.hash)) |
|
|
|
if (mapWallet.count(txin.prevout.hash)) |
|
|
|
mapWallet[txin.prevout.hash].MarkDirty(); |
|
|
|
mapWallet[txin.prevout.hash].MarkDirty(); |
|
|
@ -1096,7 +1096,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx) |
|
|
|
} |
|
|
|
} |
|
|
|
// If a transaction changes 'conflicted' state, that changes the balance
|
|
|
|
// If a transaction changes 'conflicted' state, that changes the balance
|
|
|
|
// available of the outputs it spends. So force those to be recomputed
|
|
|
|
// available of the outputs it spends. So force those to be recomputed
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) |
|
|
|
for (const CTxIn& txin : wtx.tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mapWallet.count(txin.prevout.hash)) |
|
|
|
if (mapWallet.count(txin.prevout.hash)) |
|
|
|
mapWallet[txin.prevout.hash].MarkDirty(); |
|
|
|
mapWallet[txin.prevout.hash].MarkDirty(); |
|
|
@ -1114,7 +1114,7 @@ void CWallet::SyncTransaction(const CTransactionRef& ptx, const CBlockIndex *pin |
|
|
|
// If a transaction changes 'conflicted' state, that changes the balance
|
|
|
|
// If a transaction changes 'conflicted' state, that changes the balance
|
|
|
|
// available of the outputs it spends. So force those to be
|
|
|
|
// available of the outputs it spends. So force those to be
|
|
|
|
// recomputed, also:
|
|
|
|
// recomputed, also:
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const CTxIn& txin : tx.vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mapWallet.count(txin.prevout.hash)) |
|
|
|
if (mapWallet.count(txin.prevout.hash)) |
|
|
|
mapWallet[txin.prevout.hash].MarkDirty(); |
|
|
|
mapWallet[txin.prevout.hash].MarkDirty(); |
|
|
@ -1230,7 +1230,7 @@ CAmount CWallet::GetChange(const CTxOut& txout) const |
|
|
|
|
|
|
|
|
|
|
|
bool CWallet::IsMine(const CTransaction& tx) const |
|
|
|
bool CWallet::IsMine(const CTransaction& tx) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const CTxOut& txout, tx.vout) |
|
|
|
for (const CTxOut& txout : tx.vout) |
|
|
|
if (IsMine(txout)) |
|
|
|
if (IsMine(txout)) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -1244,7 +1244,7 @@ bool CWallet::IsFromMe(const CTransaction& tx) const |
|
|
|
CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const |
|
|
|
CAmount CWallet::GetDebit(const CTransaction& tx, const isminefilter& filter) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAmount nDebit = 0; |
|
|
|
CAmount nDebit = 0; |
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const CTxIn& txin : tx.vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nDebit += GetDebit(txin, filter); |
|
|
|
nDebit += GetDebit(txin, filter); |
|
|
|
if (!MoneyRange(nDebit)) |
|
|
|
if (!MoneyRange(nDebit)) |
|
|
@ -1257,7 +1257,7 @@ bool CWallet::IsAllFromMe(const CTransaction& tx, const isminefilter& filter) co |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const CTxIn& txin : tx.vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto mi = mapWallet.find(txin.prevout.hash); |
|
|
|
auto mi = mapWallet.find(txin.prevout.hash); |
|
|
|
if (mi == mapWallet.end()) |
|
|
|
if (mi == mapWallet.end()) |
|
|
@ -1277,7 +1277,7 @@ bool CWallet::IsAllFromMe(const CTransaction& tx, const isminefilter& filter) co |
|
|
|
CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const |
|
|
|
CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAmount nCredit = 0; |
|
|
|
CAmount nCredit = 0; |
|
|
|
BOOST_FOREACH(const CTxOut& txout, tx.vout) |
|
|
|
for (const CTxOut& txout : tx.vout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nCredit += GetCredit(txout, filter); |
|
|
|
nCredit += GetCredit(txout, filter); |
|
|
|
if (!MoneyRange(nCredit)) |
|
|
|
if (!MoneyRange(nCredit)) |
|
|
@ -1289,7 +1289,7 @@ CAmount CWallet::GetCredit(const CTransaction& tx, const isminefilter& filter) c |
|
|
|
CAmount CWallet::GetChange(const CTransaction& tx) const |
|
|
|
CAmount CWallet::GetChange(const CTransaction& tx) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
CAmount nChange = 0; |
|
|
|
CAmount nChange = 0; |
|
|
|
BOOST_FOREACH(const CTxOut& txout, tx.vout) |
|
|
|
for (const CTxOut& txout : tx.vout) |
|
|
|
{ |
|
|
|
{ |
|
|
|
nChange += GetChange(txout); |
|
|
|
nChange += GetChange(txout); |
|
|
|
if (!MoneyRange(nChange)) |
|
|
|
if (!MoneyRange(nChange)) |
|
|
@ -1525,7 +1525,7 @@ void CWallet::ReacceptWalletTransactions() |
|
|
|
std::map<int64_t, CWalletTx*> mapSorted; |
|
|
|
std::map<int64_t, CWalletTx*> mapSorted; |
|
|
|
|
|
|
|
|
|
|
|
// Sort pending wallet transactions based on their initial wallet insertion order
|
|
|
|
// Sort pending wallet transactions based on their initial wallet insertion order
|
|
|
|
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) |
|
|
|
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const uint256& wtxid = item.first; |
|
|
|
const uint256& wtxid = item.first; |
|
|
|
CWalletTx& wtx = item.second; |
|
|
|
CWalletTx& wtx = item.second; |
|
|
@ -1539,7 +1539,7 @@ void CWallet::ReacceptWalletTransactions() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Try to add wallet transactions to memory pool
|
|
|
|
// Try to add wallet transactions to memory pool
|
|
|
|
BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted) |
|
|
|
for (PAIRTYPE(const int64_t, CWalletTx*)& item : mapSorted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletTx& wtx = *(item.second); |
|
|
|
CWalletTx& wtx = *(item.second); |
|
|
|
|
|
|
|
|
|
|
@ -1767,7 +1767,7 @@ bool CWalletTx::IsTrusted() const |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
// Trusted if all inputs are from us and are in the mempool:
|
|
|
|
// Trusted if all inputs are from us and are in the mempool:
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx->vin) |
|
|
|
for (const CTxIn& txin : tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Transactions not sent by us: not trusted
|
|
|
|
// Transactions not sent by us: not trusted
|
|
|
|
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); |
|
|
|
const CWalletTx* parent = pwallet->GetWalletTx(txin.prevout.hash); |
|
|
@ -1796,7 +1796,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
// Sort them in chronological order
|
|
|
|
// Sort them in chronological order
|
|
|
|
std::multimap<unsigned int, CWalletTx*> mapSorted; |
|
|
|
std::multimap<unsigned int, CWalletTx*> mapSorted; |
|
|
|
BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) |
|
|
|
for (PAIRTYPE(const uint256, CWalletTx)& item : mapWallet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletTx& wtx = item.second; |
|
|
|
CWalletTx& wtx = item.second; |
|
|
|
// Don't rebroadcast if newer than nTime:
|
|
|
|
// Don't rebroadcast if newer than nTime:
|
|
|
@ -1804,7 +1804,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(int64_t nTime, CCon |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
mapSorted.insert(std::make_pair(wtx.nTimeReceived, &wtx)); |
|
|
|
mapSorted.insert(std::make_pair(wtx.nTimeReceived, &wtx)); |
|
|
|
} |
|
|
|
} |
|
|
|
BOOST_FOREACH(PAIRTYPE(const unsigned int, CWalletTx*)& item, mapSorted) |
|
|
|
for (PAIRTYPE(const unsigned int, CWalletTx*)& item : mapSorted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletTx& wtx = *item.second; |
|
|
|
CWalletTx& wtx = *item.second; |
|
|
|
if (wtx.RelayWalletTransaction(connman)) |
|
|
|
if (wtx.RelayWalletTransaction(connman)) |
|
|
@ -2228,7 +2228,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin |
|
|
|
|
|
|
|
|
|
|
|
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); |
|
|
|
random_shuffle(vCoins.begin(), vCoins.end(), GetRandInt); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(const COutput &output, vCoins) |
|
|
|
for (const COutput &output : vCoins) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!output.fSpendable) |
|
|
|
if (!output.fSpendable) |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -2328,7 +2328,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm |
|
|
|
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
|
|
|
// coin control -> return all selected outputs (we want all selected to go into the transaction for sure)
|
|
|
|
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs) |
|
|
|
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(const COutput& out, vCoins) |
|
|
|
for (const COutput& out : vCoins) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!out.fSpendable) |
|
|
|
if (!out.fSpendable) |
|
|
|
continue; |
|
|
|
continue; |
|
|
@ -2345,7 +2345,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm |
|
|
|
std::vector<COutPoint> vPresetInputs; |
|
|
|
std::vector<COutPoint> vPresetInputs; |
|
|
|
if (coinControl) |
|
|
|
if (coinControl) |
|
|
|
coinControl->ListSelected(vPresetInputs); |
|
|
|
coinControl->ListSelected(vPresetInputs); |
|
|
|
BOOST_FOREACH(const COutPoint& outpoint, vPresetInputs) |
|
|
|
for (const COutPoint& outpoint : vPresetInputs) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); |
|
|
|
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash); |
|
|
|
if (it != mapWallet.end()) |
|
|
|
if (it != mapWallet.end()) |
|
|
@ -2433,7 +2433,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov |
|
|
|
coinControl.fOverrideFeeRate = overrideEstimatedFeeRate; |
|
|
|
coinControl.fOverrideFeeRate = overrideEstimatedFeeRate; |
|
|
|
coinControl.nFeeRate = specificFeeRate; |
|
|
|
coinControl.nFeeRate = specificFeeRate; |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, tx.vin) |
|
|
|
for (const CTxIn& txin : tx.vin) |
|
|
|
coinControl.Select(txin.prevout); |
|
|
|
coinControl.Select(txin.prevout); |
|
|
|
|
|
|
|
|
|
|
|
CReserveKey reservekey(this); |
|
|
|
CReserveKey reservekey(this); |
|
|
@ -2449,7 +2449,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov |
|
|
|
tx.vout[idx].nValue = wtx.tx->vout[idx].nValue; |
|
|
|
tx.vout[idx].nValue = wtx.tx->vout[idx].nValue; |
|
|
|
|
|
|
|
|
|
|
|
// Add new txins (keeping original txin scriptSig/order)
|
|
|
|
// Add new txins (keeping original txin scriptSig/order)
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) |
|
|
|
for (const CTxIn& txin : wtx.tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!coinControl.IsSelected(txin.prevout)) |
|
|
|
if (!coinControl.IsSelected(txin.prevout)) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -2832,7 +2832,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey, CCon |
|
|
|
AddToWallet(wtxNew); |
|
|
|
AddToWallet(wtxNew); |
|
|
|
|
|
|
|
|
|
|
|
// Notify that old coins are spent
|
|
|
|
// Notify that old coins are spent
|
|
|
|
BOOST_FOREACH(const CTxIn& txin, wtxNew.tx->vin) |
|
|
|
for (const CTxIn& txin : wtxNew.tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletTx &coin = mapWallet[txin.prevout.hash]; |
|
|
|
CWalletTx &coin = mapWallet[txin.prevout.hash]; |
|
|
|
coin.BindWallet(this); |
|
|
|
coin.BindWallet(this); |
|
|
@ -3010,7 +3010,7 @@ bool CWallet::DelAddressBook(const CTxDestination& address) |
|
|
|
|
|
|
|
|
|
|
|
// Delete destdata tuples associated with address
|
|
|
|
// Delete destdata tuples associated with address
|
|
|
|
std::string strAddress = CBitcoinAddress(address).ToString(); |
|
|
|
std::string strAddress = CBitcoinAddress(address).ToString(); |
|
|
|
BOOST_FOREACH(const PAIRTYPE(std::string, std::string) &item, mapAddressBook[address].destdata) |
|
|
|
for (const PAIRTYPE(std::string, std::string) &item : mapAddressBook[address].destdata) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletDB(*dbw).EraseDestData(strAddress, item.first); |
|
|
|
CWalletDB(*dbw).EraseDestData(strAddress, item.first); |
|
|
|
} |
|
|
|
} |
|
|
@ -3055,7 +3055,7 @@ bool CWallet::NewKeyPool() |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
CWalletDB walletdb(*dbw); |
|
|
|
CWalletDB walletdb(*dbw); |
|
|
|
BOOST_FOREACH(int64_t nIndex, setKeyPool) |
|
|
|
for (int64_t nIndex : setKeyPool) |
|
|
|
walletdb.ErasePool(nIndex); |
|
|
|
walletdb.ErasePool(nIndex); |
|
|
|
setKeyPool.clear(); |
|
|
|
setKeyPool.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -3305,7 +3305,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool any_mine = false; |
|
|
|
bool any_mine = false; |
|
|
|
// group all input addresses with each other
|
|
|
|
// group all input addresses with each other
|
|
|
|
BOOST_FOREACH(CTxIn txin, pcoin->tx->vin) |
|
|
|
for (CTxIn txin : pcoin->tx->vin) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CTxDestination address; |
|
|
|
CTxDestination address; |
|
|
|
if(!IsMine(txin)) /* If this input isn't mine, ignore it */ |
|
|
|
if(!IsMine(txin)) /* If this input isn't mine, ignore it */ |
|
|
@ -3319,7 +3319,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() |
|
|
|
// group change with input addresses
|
|
|
|
// group change with input addresses
|
|
|
|
if (any_mine) |
|
|
|
if (any_mine) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BOOST_FOREACH(CTxOut txout, pcoin->tx->vout) |
|
|
|
for (CTxOut txout : pcoin->tx->vout) |
|
|
|
if (IsChange(txout)) |
|
|
|
if (IsChange(txout)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CTxDestination txoutAddr; |
|
|
|
CTxDestination txoutAddr; |
|
|
@ -3350,18 +3350,18 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() |
|
|
|
|
|
|
|
|
|
|
|
std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
|
|
|
|
std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
|
|
|
|
std::map< CTxDestination, std::set<CTxDestination>* > setmap; // map addresses to the unique group containing it
|
|
|
|
std::map< CTxDestination, std::set<CTxDestination>* > setmap; // map addresses to the unique group containing it
|
|
|
|
BOOST_FOREACH(std::set<CTxDestination> _grouping, groupings) |
|
|
|
for (std::set<CTxDestination> _grouping : groupings) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// make a set of all the groups hit by this new group
|
|
|
|
// make a set of all the groups hit by this new group
|
|
|
|
std::set< std::set<CTxDestination>* > hits; |
|
|
|
std::set< std::set<CTxDestination>* > hits; |
|
|
|
std::map< CTxDestination, std::set<CTxDestination>* >::iterator it; |
|
|
|
std::map< CTxDestination, std::set<CTxDestination>* >::iterator it; |
|
|
|
BOOST_FOREACH(CTxDestination address, _grouping) |
|
|
|
for (CTxDestination address : _grouping) |
|
|
|
if ((it = setmap.find(address)) != setmap.end()) |
|
|
|
if ((it = setmap.find(address)) != setmap.end()) |
|
|
|
hits.insert((*it).second); |
|
|
|
hits.insert((*it).second); |
|
|
|
|
|
|
|
|
|
|
|
// merge all hit groups into a new single group and delete old groups
|
|
|
|
// merge all hit groups into a new single group and delete old groups
|
|
|
|
std::set<CTxDestination>* merged = new std::set<CTxDestination>(_grouping); |
|
|
|
std::set<CTxDestination>* merged = new std::set<CTxDestination>(_grouping); |
|
|
|
BOOST_FOREACH(std::set<CTxDestination>* hit, hits) |
|
|
|
for (std::set<CTxDestination>* hit : hits) |
|
|
|
{ |
|
|
|
{ |
|
|
|
merged->insert(hit->begin(), hit->end()); |
|
|
|
merged->insert(hit->begin(), hit->end()); |
|
|
|
uniqueGroupings.erase(hit); |
|
|
|
uniqueGroupings.erase(hit); |
|
|
@ -3370,12 +3370,12 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() |
|
|
|
uniqueGroupings.insert(merged); |
|
|
|
uniqueGroupings.insert(merged); |
|
|
|
|
|
|
|
|
|
|
|
// update setmap
|
|
|
|
// update setmap
|
|
|
|
BOOST_FOREACH(CTxDestination element, *merged) |
|
|
|
for (CTxDestination element : *merged) |
|
|
|
setmap[element] = merged; |
|
|
|
setmap[element] = merged; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::set< std::set<CTxDestination> > ret; |
|
|
|
std::set< std::set<CTxDestination> > ret; |
|
|
|
BOOST_FOREACH(std::set<CTxDestination>* uniqueGrouping, uniqueGroupings) |
|
|
|
for (std::set<CTxDestination>* uniqueGrouping : uniqueGroupings) |
|
|
|
{ |
|
|
|
{ |
|
|
|
ret.insert(*uniqueGrouping); |
|
|
|
ret.insert(*uniqueGrouping); |
|
|
|
delete uniqueGrouping; |
|
|
|
delete uniqueGrouping; |
|
|
@ -3388,7 +3388,7 @@ std::set<CTxDestination> CWallet::GetAccountAddresses(const std::string& strAcco |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_wallet); |
|
|
|
LOCK(cs_wallet); |
|
|
|
std::set<CTxDestination> result; |
|
|
|
std::set<CTxDestination> result; |
|
|
|
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, mapAddressBook) |
|
|
|
for (const PAIRTYPE(CTxDestination, CAddressBookData)& item : mapAddressBook) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const CTxDestination& address = item.first; |
|
|
|
const CTxDestination& address = item.first; |
|
|
|
const std::string& strName = item.second.name; |
|
|
|
const std::string& strName = item.second.name; |
|
|
@ -3438,7 +3438,7 @@ void CWallet::GetAllReserveKeys(std::set<CKeyID>& setAddress) const |
|
|
|
CWalletDB walletdb(*dbw); |
|
|
|
CWalletDB walletdb(*dbw); |
|
|
|
|
|
|
|
|
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
LOCK2(cs_main, cs_wallet); |
|
|
|
BOOST_FOREACH(const int64_t& id, setKeyPool) |
|
|
|
for (const int64_t& id : setKeyPool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CKeyPool keypool; |
|
|
|
CKeyPool keypool; |
|
|
|
if (!walletdb.ReadPool(id, keypool)) |
|
|
|
if (!walletdb.ReadPool(id, keypool)) |
|
|
@ -3513,7 +3513,7 @@ public: |
|
|
|
std::vector<CTxDestination> vDest; |
|
|
|
std::vector<CTxDestination> vDest; |
|
|
|
int nRequired; |
|
|
|
int nRequired; |
|
|
|
if (ExtractDestinations(script, type, vDest, nRequired)) { |
|
|
|
if (ExtractDestinations(script, type, vDest, nRequired)) { |
|
|
|
BOOST_FOREACH(const CTxDestination &dest, vDest) |
|
|
|
for (const CTxDestination &dest : vDest) |
|
|
|
boost::apply_visitor(*this, dest); |
|
|
|
boost::apply_visitor(*this, dest); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -3548,7 +3548,7 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c |
|
|
|
std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock; |
|
|
|
std::map<CKeyID, CBlockIndex*> mapKeyFirstBlock; |
|
|
|
std::set<CKeyID> setKeys; |
|
|
|
std::set<CKeyID> setKeys; |
|
|
|
GetKeys(setKeys); |
|
|
|
GetKeys(setKeys); |
|
|
|
BOOST_FOREACH(const CKeyID &keyid, setKeys) { |
|
|
|
for (const CKeyID &keyid : setKeys) { |
|
|
|
if (mapKeyBirth.count(keyid) == 0) |
|
|
|
if (mapKeyBirth.count(keyid) == 0) |
|
|
|
mapKeyFirstBlock[keyid] = pindexMax; |
|
|
|
mapKeyFirstBlock[keyid] = pindexMax; |
|
|
|
} |
|
|
|
} |
|
|
@ -3567,10 +3567,10 @@ void CWallet::GetKeyBirthTimes(std::map<CTxDestination, int64_t> &mapKeyBirth) c |
|
|
|
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { |
|
|
|
if (blit != mapBlockIndex.end() && chainActive.Contains(blit->second)) { |
|
|
|
// ... which are already in a block
|
|
|
|
// ... which are already in a block
|
|
|
|
int nHeight = blit->second->nHeight; |
|
|
|
int nHeight = blit->second->nHeight; |
|
|
|
BOOST_FOREACH(const CTxOut &txout, wtx.tx->vout) { |
|
|
|
for (const CTxOut &txout : wtx.tx->vout) { |
|
|
|
// iterate over all their outputs
|
|
|
|
// iterate over all their outputs
|
|
|
|
CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); |
|
|
|
CAffectedKeysVisitor(*this, vAffected).Process(txout.scriptPubKey); |
|
|
|
BOOST_FOREACH(const CKeyID &keyid, vAffected) { |
|
|
|
for (const CKeyID &keyid : vAffected) { |
|
|
|
// ... and all their affected keys
|
|
|
|
// ... and all their affected keys
|
|
|
|
std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid); |
|
|
|
std::map<CKeyID, CBlockIndex*>::iterator rit = mapKeyFirstBlock.find(keyid); |
|
|
|
if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight) |
|
|
|
if (rit != mapKeyFirstBlock.end() && nHeight < rit->second->nHeight) |
|
|
@ -3891,7 +3891,7 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CWalletDB walletdb(*walletInstance->dbw); |
|
|
|
CWalletDB walletdb(*walletInstance->dbw); |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(const CWalletTx& wtxOld, vWtx) |
|
|
|
for (const CWalletTx& wtxOld : vWtx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint256 hash = wtxOld.GetHash(); |
|
|
|
uint256 hash = wtxOld.GetHash(); |
|
|
|
std::map<uint256, CWalletTx>::iterator mi = walletInstance->mapWallet.find(hash); |
|
|
|
std::map<uint256, CWalletTx>::iterator mi = walletInstance->mapWallet.find(hash); |
|
|
|