MCPcopy Create free account
hub / github.com/DNAProject/DNA / addAccountData

Method addAccountData

account/client.go:176–206  ·  view source on GitHub ↗
(accData *AccountData)

Source from the content-addressed store, hash-verified

174}
175
176func (this *ClientImpl) addAccountData(accData *AccountData) error {
177 if !this.checkSigScheme(accData.Alg, accData.SigSch) {
178 return fmt.Errorf("sigScheme: %s does not match KeyType: %s", accData.SigSch, accData.Alg)
179 }
180 this.lock.Lock()
181 defer this.lock.Unlock()
182 label := accData.Label
183 if label != "" {
184 _, ok := this.accLabels[label]
185 if ok {
186 return fmt.Errorf("duplicate label")
187 }
188 }
189 if len(this.walletData.Accounts) == 0 {
190 accData.IsDefault = true
191 }
192 this.walletData.AddAccount(accData)
193 err := this.save()
194 if err != nil {
195 this.walletData.DelAccount(accData.Address)
196 return fmt.Errorf("save error: %s", err)
197 }
198 this.accAddrs[accData.Address] = accData
199 if accData.IsDefault {
200 this.defaultAcc = accData
201 }
202 if label != "" {
203 this.accLabels[label] = accData
204 }
205 return nil
206}
207
208func (this *ClientImpl) ImportAccount(accMeta *AccountMetadata) error {
209 accData := &AccountData{}

Callers 2

NewAccountMethod · 0.95
ImportAccountMethod · 0.95

Calls 5

checkSigSchemeMethod · 0.95
saveMethod · 0.95
ErrorfMethod · 0.80
AddAccountMethod · 0.80
DelAccountMethod · 0.80

Tested by

no test coverage detected