@ -3114,9 +3114,11 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
}
}
// This wallet is in its first run if all of these are empty
fFirstRunRet = mapKeys . empty ( ) & & mapCryptedKeys . empty ( ) & & mapWatchKeys . empty ( ) & & setWatchOnly . empty ( ) & & mapScripts . empty ( ) ;
if ( nLoadWalletRet ! = DB_LOAD_OK )
return nLoadWalletRet ;
fFirstRunRet = ! vchDefaultKey . IsValid ( ) ;
uiInterface . LoadWallet ( this ) ;
@ -3126,7 +3128,6 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
DBErrors CWallet : : ZapSelectTx ( std : : vector < uint256 > & vHashIn , std : : vector < uint256 > & vHashOut )
{
AssertLockHeld ( cs_wallet ) ; // mapWallet
vchDefaultKey = CPubKey ( ) ;
DBErrors nZapSelectTxRet = CWalletDB ( * dbw , " cr+ " ) . ZapSelectTx ( vHashIn , vHashOut ) ;
for ( uint256 hash : vHashOut )
mapWallet . erase ( hash ) ;
@ -3155,7 +3156,6 @@ DBErrors CWallet::ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256
DBErrors CWallet : : ZapWalletTx ( std : : vector < CWalletTx > & vWtx )
{
vchDefaultKey = CPubKey ( ) ;
DBErrors nZapWalletTxRet = CWalletDB ( * dbw , " cr+ " ) . ZapWalletTx ( vWtx ) ;
if ( nZapWalletTxRet = = DB_NEED_REWRITE )
{
@ -3231,14 +3231,6 @@ const std::string& CWallet::GetAccountName(const CScript& scriptPubKey) const
return DEFAULT_ACCOUNT_NAME ;
}
bool CWallet : : SetDefaultKey ( const CPubKey & vchPubKey )
{
if ( ! CWalletDB ( * dbw ) . WriteDefaultKey ( vchPubKey ) )
return false ;
vchDefaultKey = vchPubKey ;
return true ;
}
/**
* Mark old keypool keys as used ,
* and generate all new keys
@ -4014,13 +4006,11 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile)
if ( ! walletInstance - > SetHDMasterKey ( masterPubKey ) )
throw std : : runtime_error ( std : : string ( __func__ ) + " : Storing master key failed " ) ;
}
CPubKey newDefaultKey ;
if ( walletInstance - > GetKeyFromPool ( newDefaultKey , false ) ) {
walletInstance - > SetDefaultKey ( newDefaultKey ) ;
if ( ! walletInstance - > SetAddressBook ( walletInstance - > vchDefaultKey . GetID ( ) , " " , " receive " ) ) {
InitError ( _ ( " Cannot write default address " ) + = " \n " ) ;
return nullptr ;
}
// Top up the keypool
if ( ! walletInstance - > TopUpKeyPool ( ) ) {
InitError ( _ ( " Unable to generate initial keys " ) + = " \n " ) ;
return NULL ;
}
walletInstance - > SetBestChain ( chainActive . GetLocator ( ) ) ;