|
|
@ -299,7 +299,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) |
|
|
|
// Add a transaction to the wallet, or update it.
|
|
|
|
// Add a transaction to the wallet, or update it.
|
|
|
|
// pblock is optional, but should be provided if the transaction is known to be in a block.
|
|
|
|
// pblock is optional, but should be provided if the transaction is known to be in a block.
|
|
|
|
// If fUpdate is true, existing transactions will be updated.
|
|
|
|
// If fUpdate is true, existing transactions will be updated.
|
|
|
|
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) |
|
|
|
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate, bool fFindBlock) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint256 hash = tx.GetHash(); |
|
|
|
uint256 hash = tx.GetHash(); |
|
|
|
CRITICAL_BLOCK(cs_wallet) |
|
|
|
CRITICAL_BLOCK(cs_wallet) |
|
|
@ -586,6 +586,15 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int CWallet::ScanForWalletTransaction(const uint256& hashTx) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CTransaction tx; |
|
|
|
|
|
|
|
tx.ReadFromDisk(COutPoint(hashTx, 0)); |
|
|
|
|
|
|
|
if (AddToWalletIfInvolvingMe(tx, NULL, true, true)) |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CWallet::ReacceptWalletTransactions() |
|
|
|
void CWallet::ReacceptWalletTransactions() |
|
|
|
{ |
|
|
|
{ |
|
|
|
CTxDB txdb("r"); |
|
|
|
CTxDB txdb("r"); |
|
|
@ -1325,6 +1334,22 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int64 CWallet::AddReserveKey(const CKeyPool& keypool) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CRITICAL_BLOCK(cs_main) |
|
|
|
|
|
|
|
CRITICAL_BLOCK(cs_wallet) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CWalletDB walletdb(strWalletFile); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int64 nIndex = 1 + *(--setKeyPool.end()); |
|
|
|
|
|
|
|
if (!walletdb.WritePool(nIndex, keypool)) |
|
|
|
|
|
|
|
throw runtime_error("AddReserveKey() : writing added key failed"); |
|
|
|
|
|
|
|
setKeyPool.insert(nIndex); |
|
|
|
|
|
|
|
return nIndex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CWallet::KeepKey(int64 nIndex) |
|
|
|
void CWallet::KeepKey(int64 nIndex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Remove from key pool
|
|
|
|
// Remove from key pool
|
|
|
@ -1413,3 +1438,22 @@ void CReserveKey::ReturnKey() |
|
|
|
vchPubKey.clear(); |
|
|
|
vchPubKey.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CWallet::GetAllReserveAddresses(set<CBitcoinAddress>& setAddress) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
setAddress.clear(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CWalletDB walletdb(strWalletFile); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CRITICAL_BLOCK(cs_main) |
|
|
|
|
|
|
|
BOOST_FOREACH(const int64& id, setKeyPool) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CKeyPool keypool; |
|
|
|
|
|
|
|
if (!walletdb.ReadPool(id, keypool)) |
|
|
|
|
|
|
|
throw runtime_error("GetAllReserveKeyHashes() : read failed"); |
|
|
|
|
|
|
|
CBitcoinAddress address(keypool.vchPubKey); |
|
|
|
|
|
|
|
assert(!keypool.vchPubKey.empty()); |
|
|
|
|
|
|
|
if (!HaveKey(address)) |
|
|
|
|
|
|
|
throw runtime_error("GetAllReserveKeyHashes() : unknown key in key pool"); |
|
|
|
|
|
|
|
setAddress.insert(address); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|