Mark new wallet addresses as belonging to account.

This adds some missing bookkeeping which broke rescans for the root
addresses of newly created wallets (not wallets read from disk) by
marking all active addresses (which would be just the root address) as
belonging to the account with a some particular name.

While here, return an error to the caller rather than just logging the
error if the newly-created wallet cannot be immediatelly written to
disk.
This commit is contained in:
Josh Rickmar 2014-01-23 09:51:31 -05:00
parent ce2decb275
commit 8b65e651cd

View file

@ -204,6 +204,11 @@ func (store *AccountStore) CreateEncryptedWallet(name, desc string, passphrase [
account.UtxoStore.dirty = true
account.TxStore.dirty = true
// Mark all active payment addresses as belonging to this account.
for addr := range account.ActivePaymentAddresses() {
MarkAddressForAccount(addr, name)
}
// Save the account in the global account map. The mutex is
// already held at this point, and will be unlocked when this
// func returns.
@ -218,8 +223,7 @@ func (store *AccountStore) CreateEncryptedWallet(name, desc string, passphrase [
// Write new wallet to disk.
if err := account.writeDirtyToDisk(); err != nil {
log.Errorf("cannot sync dirty wallet: %v", err)
return nil
return err
}
return nil