Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,151 Lines • ▼ Show 20 Lines | bool CWalletTx::IsTrusted() const { | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool CWalletTx::IsEquivalentTo(const CWalletTx &_tx) const { | bool CWalletTx::IsEquivalentTo(const CWalletTx &_tx) const { | ||||
CMutableTransaction tx1{*this->tx}; | CMutableTransaction tx1{*this->tx}; | ||||
CMutableTransaction tx2{*_tx.tx}; | CMutableTransaction tx2{*_tx.tx}; | ||||
for (CTxIn &in : tx1.vin) { | for (auto &txin : tx1.vin) { | ||||
in.scriptSig = CScript(); | txin.scriptSig = CScript(); | ||||
} | } | ||||
for (CTxIn &in : tx2.vin) { | for (auto &txin : tx2.vin) { | ||||
in.scriptSig = CScript(); | txin.scriptSig = CScript(); | ||||
} | } | ||||
return CTransaction(tx1) == CTransaction(tx2); | return CTransaction(tx1) == CTransaction(tx2); | ||||
} | } | ||||
std::vector<uint256> | std::vector<uint256> | ||||
CWallet::ResendWalletTransactionsBefore(int64_t nTime, CConnman *connman) { | CWallet::ResendWalletTransactionsBefore(int64_t nTime, CConnman *connman) { | ||||
std::vector<uint256> result; | std::vector<uint256> result; | ||||
▲ Show 20 Lines • Show All 608 Lines • ▼ Show 20 Lines | bool CWallet::SelectCoins(const std::vector<COutput> &vAvailableCoins, | ||||
return res; | return res; | ||||
} | } | ||||
bool CWallet::SignTransaction(CMutableTransaction &tx) { | bool CWallet::SignTransaction(CMutableTransaction &tx) { | ||||
// sign the new tx | // sign the new tx | ||||
CTransaction txNewConst(tx); | CTransaction txNewConst(tx); | ||||
int nIn = 0; | int nIn = 0; | ||||
for (auto &input : tx.vin) { | for (const auto &input : tx.vin) { | ||||
auto mi = mapWallet.find(input.prevout.GetTxId()); | auto mi = mapWallet.find(input.prevout.GetTxId()); | ||||
if (mi == mapWallet.end() || | if (mi == mapWallet.end() || | ||||
input.prevout.GetN() >= mi->second.tx->vout.size()) { | input.prevout.GetN() >= mi->second.tx->vout.size()) { | ||||
return false; | return false; | ||||
} | } | ||||
const CScript &scriptPubKey = | const CScript &scriptPubKey = | ||||
mi->second.tx->vout[input.prevout.GetN()].scriptPubKey; | mi->second.tx->vout[input.prevout.GetN()].scriptPubKey; | ||||
const Amount amount = mi->second.tx->vout[input.prevout.GetN()].nValue; | const Amount amount = mi->second.tx->vout[input.prevout.GetN()].nValue; | ||||
▲ Show 20 Lines • Show All 1,005 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 (CTxIn 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 (CTxOut 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); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (grouping.size() > 0) { | if (grouping.size() > 0) { | ||||
groupings.insert(grouping); | groupings.insert(grouping); | ||||
grouping.clear(); | grouping.clear(); | ||||
} | } | ||||
} | } | ||||
// Group lone addrs by themselves. | // Group lone addrs by themselves. | ||||
for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++) | for (const auto &txout : pcoin->tx->vout) { | ||||
if (IsMine(pcoin->tx->vout[i])) { | if (IsMine(txout)) { | ||||
CTxDestination address; | CTxDestination address; | ||||
if (!ExtractDestination(pcoin->tx->vout[i].scriptPubKey, | if (!ExtractDestination(txout.scriptPubKey, address)) { | ||||
address)) { | |||||
continue; | continue; | ||||
} | } | ||||
grouping.insert(address); | grouping.insert(address); | ||||
groupings.insert(grouping); | groupings.insert(grouping); | ||||
grouping.clear(); | grouping.clear(); | ||||
} | } | ||||
} | } | ||||
} | |||||
// A set of pointers to groups of addresses. | // A set of pointers to groups of addresses. | ||||
std::set<std::set<CTxDestination> *> uniqueGroupings; | std::set<std::set<CTxDestination> *> uniqueGroupings; | ||||
// Map addresses to the unique group containing it. | // Map addresses to the unique group containing it. | ||||
std::map<CTxDestination, std::set<CTxDestination> *> setmap; | std::map<CTxDestination, std::set<CTxDestination> *> setmap; | ||||
for (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; | ||||
▲ Show 20 Lines • Show All 821 Lines • Show Last 20 Lines |