Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,546 Lines • ▼ Show 20 Lines | for (const auto &output : lockedCoins) { | ||||
} | } | ||||
} | } | ||||
return result; | return result; | ||||
} | } | ||||
const CTxOut &CWallet::FindNonChangeParentOutput(const CTransaction &tx, | const CTxOut &CWallet::FindNonChangeParentOutput(const CTransaction &tx, | ||||
int output) const { | int output) const { | ||||
AssertLockHeld(cs_wallet); | |||||
const CTransaction *ptx = &tx; | const CTransaction *ptx = &tx; | ||||
int n = output; | int n = output; | ||||
while (IsChange(ptx->vout[n]) && ptx->vin.size() > 0) { | while (IsChange(ptx->vout[n]) && ptx->vin.size() > 0) { | ||||
const COutPoint &prevout = ptx->vin[0].prevout; | const COutPoint &prevout = ptx->vin[0].prevout; | ||||
auto it = mapWallet.find(prevout.GetTxId()); | auto it = mapWallet.find(prevout.GetTxId()); | ||||
if (it == mapWallet.end() || | if (it == mapWallet.end() || | ||||
it->second.tx->vout.size() <= prevout.GetN() || | it->second.tx->vout.size() <= prevout.GetN() || | ||||
!IsMine(it->second.tx->vout[prevout.GetN()])) { | !IsMine(it->second.tx->vout[prevout.GetN()])) { | ||||
▲ Show 20 Lines • Show All 1,008 Lines • ▼ Show 20 Lines | bool CWallet::SetAddressBook(const CTxDestination &address, | ||||
const std::string &strName, | const std::string &strName, | ||||
const std::string &strPurpose) { | const std::string &strPurpose) { | ||||
WalletBatch batch(*database); | WalletBatch batch(*database); | ||||
return SetAddressBookWithDB(batch, address, strName, strPurpose); | return SetAddressBookWithDB(batch, address, strName, strPurpose); | ||||
} | } | ||||
bool CWallet::DelAddressBook(const CTxDestination &address) { | bool CWallet::DelAddressBook(const CTxDestination &address) { | ||||
bool is_mine; | bool is_mine; | ||||
WalletBatch batch(*database); | |||||
{ | { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
// If we want to delete receiving addresses, we need to take care that | // If we want to delete receiving addresses, we need to take care that | ||||
// DestData "used" (and possibly newer DestData) gets preserved (and the | // DestData "used" (and possibly newer DestData) gets preserved (and the | ||||
// "deleted" address transformed into a change entry instead of actually | // "deleted" address transformed into a change entry instead of actually | ||||
// being deleted) | // being deleted) | ||||
// NOTE: This isn't a problem for sending addresses because they never | // NOTE: This isn't a problem for sending addresses because they never | ||||
// have any DestData yet! When adding new DestData, it should be | // have any DestData yet! When adding new DestData, it should be | ||||
// considered here whether to retain or delete it (or move it?). | // considered here whether to retain or delete it (or move it?). | ||||
if (IsMine(address)) { | if (IsMine(address)) { | ||||
WalletLogPrintf( | WalletLogPrintf( | ||||
"%s called with IsMine address, NOT SUPPORTED. Please " | "%s called with IsMine address, NOT SUPPORTED. Please " | ||||
"report this bug! %s\n", | "report this bug! %s\n", | ||||
__func__, PACKAGE_BUGREPORT); | __func__, PACKAGE_BUGREPORT); | ||||
return false; | return false; | ||||
} | } | ||||
// Delete destdata tuples associated with address | // Delete destdata tuples associated with address | ||||
for (const std::pair<const std::string, std::string> &item : | for (const std::pair<const std::string, std::string> &item : | ||||
m_address_book[address].destdata) { | m_address_book[address].destdata) { | ||||
WalletBatch(*database).EraseDestData(address, item.first); | batch.EraseDestData(address, item.first); | ||||
} | } | ||||
m_address_book.erase(address); | m_address_book.erase(address); | ||||
is_mine = IsMine(address) != ISMINE_NO; | is_mine = IsMine(address) != ISMINE_NO; | ||||
} | } | ||||
NotifyAddressBookChanged(this, address, "", is_mine, "", CT_DELETED); | NotifyAddressBookChanged(this, address, "", is_mine, "", CT_DELETED); | ||||
WalletBatch(*database).ErasePurpose(address); | batch.ErasePurpose(address); | ||||
return WalletBatch(*database).EraseName(address); | return batch.EraseName(address); | ||||
} | } | ||||
size_t CWallet::KeypoolCountExternalKeys() const { | size_t CWallet::KeypoolCountExternalKeys() const { | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
unsigned int count = 0; | unsigned int count = 0; | ||||
for (auto spk_man : GetActiveScriptPubKeyMans()) { | for (auto spk_man : GetActiveScriptPubKeyMans()) { | ||||
count += spk_man->KeypoolCountExternalKeys(); | count += spk_man->KeypoolCountExternalKeys(); | ||||
▲ Show 20 Lines • Show All 1,406 Lines • Show Last 20 Lines |