@ -180,8 +180,6 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
@@ -180,8 +180,6 @@ bool CWallet::AddKeyPubKey(const CKey& secret, const CPubKey &pubkey)
if ( HaveWatchOnly ( script ) )
RemoveWatchOnly ( script ) ;
if ( ! fFileBacked )
return true ;
if ( ! IsCrypted ( ) ) {
return CWalletDB ( * dbw ) . WriteKey ( pubkey ,
secret . GetPrivKey ( ) ,
@ -195,8 +193,6 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
@@ -195,8 +193,6 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey,
{
if ( ! CCryptoKeyStore : : AddCryptedKey ( vchPubKey , vchCryptedSecret ) )
return false ;
if ( ! fFileBacked )
return true ;
{
LOCK ( cs_wallet ) ;
if ( pwalletdbEncryption )
@ -240,8 +236,6 @@ bool CWallet::AddCScript(const CScript& redeemScript)
@@ -240,8 +236,6 @@ bool CWallet::AddCScript(const CScript& redeemScript)
{
if ( ! CCryptoKeyStore : : AddCScript ( redeemScript ) )
return false ;
if ( ! fFileBacked )
return true ;
return CWalletDB ( * dbw ) . WriteCScript ( Hash160 ( redeemScript ) , redeemScript ) ;
}
@ -268,8 +262,6 @@ bool CWallet::AddWatchOnly(const CScript& dest)
@@ -268,8 +262,6 @@ bool CWallet::AddWatchOnly(const CScript& dest)
const CKeyMetadata & meta = mapKeyMetadata [ CScriptID ( dest ) ] ;
UpdateTimeFirstKey ( meta . nCreateTime ) ;
NotifyWatchonlyChanged ( true ) ;
if ( ! fFileBacked )
return true ;
return CWalletDB ( * dbw ) . WriteWatchOnly ( dest , meta ) ;
}
@ -286,7 +278,6 @@ bool CWallet::RemoveWatchOnly(const CScript &dest)
@@ -286,7 +278,6 @@ bool CWallet::RemoveWatchOnly(const CScript &dest)
return false ;
if ( ! HaveWatchOnly ( ) )
NotifyWatchonlyChanged ( false ) ;
if ( fFileBacked )
if ( ! CWalletDB ( * dbw ) . EraseWatchOnly ( dest ) )
return false ;
@ -385,7 +376,6 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn,
@@ -385,7 +376,6 @@ bool CWallet::SetMinVersion(enum WalletFeature nVersion, CWalletDB* pwalletdbIn,
if ( nVersion > nWalletMaxVersion )
nWalletMaxVersion = nVersion ;
if ( fFileBacked )
{
CWalletDB * pwalletdb = pwalletdbIn ? pwalletdbIn : new CWalletDB ( * dbw ) ;
if ( nWalletVersion > 40000 )
@ -594,8 +584,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
@@ -594,8 +584,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
{
LOCK ( cs_wallet ) ;
mapMasterKeys [ + + nMasterKeyMaxID ] = kMasterKey ;
if ( fFileBacked )
{
assert ( ! pwalletdbEncryption ) ;
pwalletdbEncryption = new CWalletDB ( * dbw ) ;
if ( ! pwalletdbEncryption - > TxnBegin ( ) ) {
@ -604,14 +592,11 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
@@ -604,14 +592,11 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
return false ;
}
pwalletdbEncryption - > WriteMasterKey ( nMasterKeyMaxID , kMasterKey ) ;
}
if ( ! EncryptKeys ( _vMasterKey ) )
{
if ( fFileBacked ) {
pwalletdbEncryption - > TxnAbort ( ) ;
delete pwalletdbEncryption ;
}
// We now probably have half of our keys encrypted in memory, and half not...
// die and let the user reload the unencrypted wallet.
assert ( false ) ;
@ -620,8 +605,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
@@ -620,8 +605,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
// Encryption was introduced in version 0.4.0
SetMinVersion ( FEATURE_WALLETCRYPT , pwalletdbEncryption , true ) ;
if ( fFileBacked )
{
if ( ! pwalletdbEncryption - > TxnCommit ( ) ) {
delete pwalletdbEncryption ;
// We now have keys encrypted in memory, but not on disk...
@ -631,7 +614,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
@@ -631,7 +614,6 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
delete pwalletdbEncryption ;
pwalletdbEncryption = NULL ;
}
Lock ( ) ;
Unlock ( strWalletPassphrase ) ;
@ -2816,8 +2798,6 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
@@ -2816,8 +2798,6 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
DBErrors CWallet : : LoadWallet ( bool & fFirstRunRet )
{
if ( ! fFileBacked )
return DB_LOAD_OK ;
fFirstRunRet = false ;
DBErrors nLoadWalletRet = CWalletDB ( * dbw , " cr+ " ) . LoadWallet ( this ) ;
if ( nLoadWalletRet = = DB_NEED_REWRITE )
@ -2843,8 +2823,6 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
@@ -2843,8 +2823,6 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
DBErrors CWallet : : ZapSelectTx ( std : : vector < uint256 > & vHashIn , std : : vector < uint256 > & vHashOut )
{
if ( ! fFileBacked )
return DB_LOAD_OK ;
AssertLockHeld ( cs_wallet ) ; // mapWallet
vchDefaultKey = CPubKey ( ) ;
DBErrors nZapSelectTxRet = CWalletDB ( * dbw , " cr+ " ) . ZapSelectTx ( vHashIn , vHashOut ) ;
@ -2873,8 +2851,6 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
@@ -2873,8 +2851,6 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
DBErrors CWallet : : ZapWalletTx ( std : : vector < CWalletTx > & vWtx )
{
if ( ! fFileBacked )
return DB_LOAD_OK ;
vchDefaultKey = CPubKey ( ) ;
DBErrors nZapWalletTxRet = CWalletDB ( * dbw , " cr+ " ) . ZapWalletTx ( vWtx ) ;
if ( nZapWalletTxRet = = DB_NEED_REWRITE )
@ -2909,8 +2885,6 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
@@ -2909,8 +2885,6 @@ bool CWallet::SetAddressBook(const CTxDestination& address, const std::string& s
}
NotifyAddressBookChanged ( this , address , strName , : : IsMine ( * this , address ) ! = ISMINE_NO ,
strPurpose , ( fUpdated ? CT_UPDATED : CT_NEW ) ) ;
if ( ! fFileBacked )
return false ;
if ( ! strPurpose . empty ( ) & & ! CWalletDB ( * dbw ) . WritePurpose ( CBitcoinAddress ( address ) . ToString ( ) , strPurpose ) )
return false ;
return CWalletDB ( * dbw ) . WriteName ( CBitcoinAddress ( address ) . ToString ( ) , strName ) ;
@ -2921,33 +2895,25 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
@@ -2921,33 +2895,25 @@ bool CWallet::DelAddressBook(const CTxDestination& address)
{
LOCK ( cs_wallet ) ; // mapAddressBook
if ( fFileBacked )
{
// Delete destdata tuples associated with address
std : : string strAddress = CBitcoinAddress ( address ) . ToString ( ) ;
BOOST_FOREACH ( const PAIRTYPE ( std : : string , std : : string ) & item , mapAddressBook [ address ] . destdata )
{
CWalletDB ( * dbw ) . EraseDestData ( strAddress , item . first ) ;
}
}
mapAddressBook . erase ( address ) ;
}
NotifyAddressBookChanged ( this , address , " " , : : IsMine ( * this , address ) ! = ISMINE_NO , " " , CT_DELETED ) ;
if ( ! fFileBacked )
return false ;
CWalletDB ( * dbw ) . ErasePurpose ( CBitcoinAddress ( address ) . ToString ( ) ) ;
return CWalletDB ( * dbw ) . EraseName ( CBitcoinAddress ( address ) . ToString ( ) ) ;
}
bool CWallet : : SetDefaultKey ( const CPubKey & vchPubKey )
{
if ( fFileBacked )
{
if ( ! CWalletDB ( * dbw ) . WriteDefaultKey ( vchPubKey ) )
return false ;
}
vchDefaultKey = vchPubKey ;
return true ;
}
@ -3081,11 +3047,8 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool int
@@ -3081,11 +3047,8 @@ void CWallet::ReserveKeyFromKeyPool(int64_t& nIndex, CKeyPool& keypool, bool int
void CWallet : : KeepKey ( int64_t nIndex )
{
// Remove from key pool
if ( fFileBacked )
{
CWalletDB walletdb ( * dbw ) ;
walletdb . ErasePool ( nIndex ) ;
}
LogPrintf ( " keypool keep %d \n " , nIndex ) ;
}
@ -3597,8 +3560,6 @@ bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, co
@@ -3597,8 +3560,6 @@ bool CWallet::AddDestData(const CTxDestination &dest, const std::string &key, co
return false ;
mapAddressBook [ dest ] . destdata . insert ( std : : make_pair ( key , value ) ) ;
if ( ! fFileBacked )
return true ;
return CWalletDB ( * dbw ) . WriteDestData ( CBitcoinAddress ( dest ) . ToString ( ) , key , value ) ;
}
@ -3606,8 +3567,6 @@ bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key)
@@ -3606,8 +3567,6 @@ bool CWallet::EraseDestData(const CTxDestination &dest, const std::string &key)
{
if ( ! mapAddressBook [ dest ] . destdata . erase ( key ) )
return false ;
if ( ! fFileBacked )
return true ;
return CWalletDB ( * dbw ) . EraseDestData ( CBitcoinAddress ( dest ) . ToString ( ) , key ) ;
}
@ -3979,8 +3938,6 @@ bool CWallet::ParameterInteraction()
@@ -3979,8 +3938,6 @@ bool CWallet::ParameterInteraction()
bool CWallet : : BackupWallet ( const std : : string & strDest )
{
if ( ! fFileBacked )
return false ;
return dbw - > Backup ( strDest ) ;
}