@ -15,6 +15,8 @@
# include "util.h"
# include "util.h"
# include "utilmoneystr.h"
# include "utilmoneystr.h"
# include <assert.h>
# include <boost/algorithm/string/replace.hpp>
# include <boost/algorithm/string/replace.hpp>
# include <boost/thread.hpp>
# include <boost/thread.hpp>
@ -426,17 +428,25 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
mapMasterKeys [ + + nMasterKeyMaxID ] = kMasterKey ;
mapMasterKeys [ + + nMasterKeyMaxID ] = kMasterKey ;
if ( fFileBacked )
if ( fFileBacked )
{
{
assert ( ! pwalletdbEncryption ) ;
pwalletdbEncryption = new CWalletDB ( strWalletFile ) ;
pwalletdbEncryption = new CWalletDB ( strWalletFile ) ;
if ( ! pwalletdbEncryption - > TxnBegin ( ) )
if ( ! pwalletdbEncryption - > TxnBegin ( ) ) {
delete pwalletdbEncryption ;
pwalletdbEncryption = NULL ;
return false ;
return false ;
}
pwalletdbEncryption - > WriteMasterKey ( nMasterKeyMaxID , kMasterKey ) ;
pwalletdbEncryption - > WriteMasterKey ( nMasterKeyMaxID , kMasterKey ) ;
}
}
if ( ! EncryptKeys ( vMasterKey ) )
if ( ! EncryptKeys ( vMasterKey ) )
{
{
if ( fFileBacked )
if ( fFileBacked ) {
pwalletdbEncryption - > TxnAbort ( ) ;
pwalletdbEncryption - > TxnAbort ( ) ;
exit ( 1 ) ; //We now probably have half of our keys encrypted in memory, and half not...die and let the user reload their unencrypted wallet.
delete pwalletdbEncryption ;
}
// We now probably have half of our keys encrypted in memory, and half not...
// die and let the user reload their unencrypted wallet.
assert ( false ) ;
}
}
// Encryption was introduced in version 0.4.0
// Encryption was introduced in version 0.4.0
@ -444,8 +454,12 @@ bool CWallet::EncryptWallet(const SecureString& strWalletPassphrase)
if ( fFileBacked )
if ( fFileBacked )
{
{
if ( ! pwalletdbEncryption - > TxnCommit ( ) )
if ( ! pwalletdbEncryption - > TxnCommit ( ) ) {
exit ( 1 ) ; //We now have keys encrypted in memory, but no on disk...die to avoid confusion and let the user reload their unencrypted wallet.
delete pwalletdbEncryption ;
// We now have keys encrypted in memory, but no on disk...
// die to avoid confusion and let the user reload their unencrypted wallet.
assert ( false ) ;
}
delete pwalletdbEncryption ;
delete pwalletdbEncryption ;
pwalletdbEncryption = NULL ;
pwalletdbEncryption = NULL ;
@ -1068,7 +1082,7 @@ CAmount CWallet::GetWatchOnlyBalance() const
nTotal + = pcoin - > GetAvailableWatchOnlyCredit ( ) ;
nTotal + = pcoin - > GetAvailableWatchOnlyCredit ( ) ;
}
}
}
}
return nTotal ;
return nTotal ;
}
}