Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletmodel.cpp
Show First 20 Lines • Show All 541 Lines • ▼ Show 20 Lines | |||||
// returns a list of COutputs from COutPoints | // returns a list of COutputs from COutPoints | ||||
void WalletModel::getOutputs(const std::vector<COutPoint> &vOutpoints, | void WalletModel::getOutputs(const std::vector<COutPoint> &vOutpoints, | ||||
std::vector<COutput> &vOutputs) { | std::vector<COutput> &vOutputs) { | ||||
LOCK2(cs_main, wallet->cs_wallet); | LOCK2(cs_main, wallet->cs_wallet); | ||||
for (const COutPoint &outpoint : vOutpoints) { | for (const COutPoint &outpoint : vOutpoints) { | ||||
if (!wallet->mapWallet.count(outpoint.hash)) continue; | if (!wallet->mapWallet.count(outpoint.hash)) continue; | ||||
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); | int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); | ||||
if (nDepth < 0) continue; | if (nDepth < 0) continue; | ||||
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true, | COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, | ||||
true); | true /* spendable */, true /* solvable */, true /* safe */); | ||||
vOutputs.push_back(out); | vOutputs.push_back(out); | ||||
} | } | ||||
} | } | ||||
bool WalletModel::isSpent(const COutPoint &outpoint) const { | bool WalletModel::isSpent(const COutPoint &outpoint) const { | ||||
LOCK2(cs_main, wallet->cs_wallet); | LOCK2(cs_main, wallet->cs_wallet); | ||||
return wallet->IsSpent(outpoint.hash, outpoint.n); | return wallet->IsSpent(outpoint.hash, outpoint.n); | ||||
} | } | ||||
Show All 10 Lines | void WalletModel::listCoins( | ||||
std::vector<COutPoint> vLockedCoins; | std::vector<COutPoint> vLockedCoins; | ||||
wallet->ListLockedCoins(vLockedCoins); | wallet->ListLockedCoins(vLockedCoins); | ||||
// add locked coins | // add locked coins | ||||
for (const COutPoint &outpoint : vLockedCoins) { | for (const COutPoint &outpoint : vLockedCoins) { | ||||
if (!wallet->mapWallet.count(outpoint.hash)) continue; | if (!wallet->mapWallet.count(outpoint.hash)) continue; | ||||
int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); | int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain(); | ||||
if (nDepth < 0) continue; | if (nDepth < 0) continue; | ||||
COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true, | COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, | ||||
true); | true /* spendable */, true /* solvable */, true /* safe */); | ||||
if (outpoint.n < out.tx->tx->vout.size() && | if (outpoint.n < out.tx->tx->vout.size() && | ||||
wallet->IsMine(out.tx->tx->vout[outpoint.n]) == ISMINE_SPENDABLE) | wallet->IsMine(out.tx->tx->vout[outpoint.n]) == ISMINE_SPENDABLE) { | ||||
vCoins.push_back(out); | vCoins.push_back(out); | ||||
} | } | ||||
} | |||||
for (const COutput &out : vCoins) { | for (const COutput &out : vCoins) { | ||||
COutput cout = out; | COutput cout = out; | ||||
while (wallet->IsChange(cout.tx->tx->vout[cout.i]) && | while (wallet->IsChange(cout.tx->tx->vout[cout.i]) && | ||||
cout.tx->tx->vin.size() > 0 && | cout.tx->tx->vin.size() > 0 && | ||||
wallet->IsMine(cout.tx->tx->vin[0])) { | wallet->IsMine(cout.tx->tx->vin[0])) { | ||||
if (!wallet->mapWallet.count(cout.tx->tx->vin[0].prevout.hash)) | if (!wallet->mapWallet.count(cout.tx->tx->vin[0].prevout.hash)) | ||||
break; | break; | ||||
cout = COutput(&wallet->mapWallet[cout.tx->tx->vin[0].prevout.hash], | cout = COutput(&wallet->mapWallet[cout.tx->tx->vin[0].prevout.hash], | ||||
cout.tx->tx->vin[0].prevout.n, 0, true, true); | cout.tx->tx->vin[0].prevout.n, 0 /* depth */, | ||||
true /* spendable */, true /* solvable */, | |||||
true /* safe */); | |||||
} | } | ||||
CTxDestination address; | CTxDestination address; | ||||
if (!out.fSpendable || | if (!out.fSpendable || | ||||
!ExtractDestination(cout.tx->tx->vout[cout.i].scriptPubKey, | !ExtractDestination(cout.tx->tx->vout[cout.i].scriptPubKey, | ||||
address)) | address)) | ||||
continue; | continue; | ||||
mapCoins[QString::fromStdString(EncodeDestination(address))].push_back( | mapCoins[QString::fromStdString(EncodeDestination(address))].push_back( | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |