From 8b65e651cdfb3edfcd140fdac146a01c5a998b77 Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Thu, 23 Jan 2014 09:51:31 -0500 Subject: [PATCH] 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. --- accountstore.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/accountstore.go b/accountstore.go index bd488e5..4937535 100644 --- a/accountstore.go +++ b/accountstore.go @@ -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