@@ -156,38 +156,38 @@ func (w *Wallet) Remove(name string) error {
156156}
157157
158158// Rename renames an existing account.
159- func (w * Wallet ) Rename (old , new string ) error {
160- cfg , exists := w .All [old ]
159+ func (w * Wallet ) Rename (oldName , newName string ) error {
160+ cfg , exists := w .All [oldName ]
161161 if ! exists {
162- return fmt .Errorf ("account '%s' does not exist in the wallet" , old )
162+ return fmt .Errorf ("account '%s' does not exist in the wallet" , oldName )
163163 }
164164
165- if _ , exists = w .All [new ]; exists {
166- return fmt .Errorf ("account '%s' already exists in the wallet" , new )
165+ if _ , exists = w .All [newName ]; exists {
166+ return fmt .Errorf ("account '%s' already exists in the wallet" , newName )
167167 }
168168
169- if err := config .ValidateIdentifier (old ); err != nil {
170- return fmt .Errorf ("malformed old account name '%s': %w" , old , err )
169+ if err := config .ValidateIdentifier (oldName ); err != nil {
170+ return fmt .Errorf ("malformed old account name '%s': %w" , oldName , err )
171171 }
172- if err := config .ValidateIdentifier (new ); err != nil {
173- return fmt .Errorf ("malformed new account name '%s': %w" , new , err )
172+ if err := config .ValidateIdentifier (newName ); err != nil {
173+ return fmt .Errorf ("malformed new account name '%s': %w" , newName , err )
174174 }
175175
176176 af , err := wallet .Load (cfg .Kind )
177177 if err != nil {
178178 return err
179179 }
180180
181- if err := af .Rename (old , new , cfg .Config ); err != nil {
181+ if err := af .Rename (oldName , newName , cfg .Config ); err != nil {
182182 return err
183183 }
184184
185- w .All [new ] = cfg
186- delete (w .All , old )
185+ w .All [newName ] = cfg
186+ delete (w .All , oldName )
187187
188188 // Update default if set to this wallet.
189- if w .Default == old {
190- w .Default = new
189+ if w .Default == oldName {
190+ w .Default = newName
191191 }
192192
193193 return nil
0 commit comments