Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 3,830 Lines • ▼ Show 20 Lines | std::set<std::set<CTxDestination>> CWallet::GetAddressGroupings() { | ||||
std::set<CTxDestination> grouping; | std::set<CTxDestination> grouping; | ||||
for (const auto &walletEntry : mapWallet) { | for (const auto &walletEntry : mapWallet) { | ||||
const CWalletTx *pcoin = &walletEntry.second; | const CWalletTx *pcoin = &walletEntry.second; | ||||
if (pcoin->tx->vin.size() > 0) { | if (pcoin->tx->vin.size() > 0) { | ||||
bool any_mine = false; | bool any_mine = false; | ||||
// Group all input addresses with each other. | // Group all input addresses with each other. | ||||
for (const auto txin : pcoin->tx->vin) { | for (const auto &txin : pcoin->tx->vin) { | ||||
CTxDestination address; | CTxDestination address; | ||||
// If this input isn't mine, ignore it. | // If this input isn't mine, ignore it. | ||||
if (!IsMine(txin)) { | if (!IsMine(txin)) { | ||||
continue; | continue; | ||||
} | } | ||||
if (!ExtractDestination(mapWallet.at(txin.prevout.GetTxId()) | if (!ExtractDestination(mapWallet.at(txin.prevout.GetTxId()) | ||||
.tx->vout[txin.prevout.GetN()] | .tx->vout[txin.prevout.GetN()] | ||||
.scriptPubKey, | .scriptPubKey, | ||||
address)) { | address)) { | ||||
continue; | continue; | ||||
} | } | ||||
grouping.insert(address); | grouping.insert(address); | ||||
any_mine = true; | any_mine = true; | ||||
} | } | ||||
// Group change with input addresses. | // Group change with input addresses. | ||||
if (any_mine) { | if (any_mine) { | ||||
for (const auto txout : pcoin->tx->vout) { | for (const auto &txout : pcoin->tx->vout) { | ||||
if (IsChange(txout)) { | if (IsChange(txout)) { | ||||
CTxDestination txoutAddr; | CTxDestination txoutAddr; | ||||
if (!ExtractDestination(txout.scriptPubKey, | if (!ExtractDestination(txout.scriptPubKey, | ||||
txoutAddr)) { | txoutAddr)) { | ||||
continue; | continue; | ||||
} | } | ||||
grouping.insert(txoutAddr); | grouping.insert(txoutAddr); | ||||
▲ Show 20 Lines • Show All 907 Lines • Show Last 20 Lines |