src/wallet/wallet.cpp
// Add spending key to keystore and persist to disk
Add spending key to keystore and persist to disk
Add spending key to keystore and persist to disk
bool CWallet::AddSproutZKey(const libzelcash::SproutSpendingKey &key)
{
    AssertLockHeld(cs_wallet); 
    auto addr = key.address();
    if (!CCryptoKeyStore::AddSproutSpendingKey(key))
        return false;
    if (HaveSproutViewingKey(addr))
        RemoveSproutViewingKey(key.viewing_key());
    if (!fFileBacked)
        return true;
    if (!IsCrypted()) {
        return CWalletDB(strWalletFile).WriteZKey(addr,
                                                  key,
                                                  mapSproutZKeyMetadata[addr]);
    }
    return true;
}
bool CWallet :: AddSproutZKey ( const libzelcash :: SproutSpendingKey & key ) { AssertLockHeld ( cs_wallet ) ; auto addr = key . address ( ) ; if ( ! CCryptoKeyStore :: AddSproutSpendingKey ( key ) ) return false ; if ( HaveSproutViewingKey ( addr ) ) RemoveSproutViewingKey ( key . viewing_key ( ) ) ; if ( ! fFileBacked ) return true ; if ( ! IsCrypted ( ) ) { return CWalletDB ( strWalletFile ) . WriteZKey ( addr , key , mapSproutZKeyMetadata [ addr ] ) ; } return true ; }
Add spending key to keystore and persist to disk
Add spending key to keystore and persist to disk
// mapSproutZKeyMetadata // check if we need to remove from viewing keys