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

Function GetAccountMulti

cmd/common/common.go:64–99  ·  view source on GitHub ↗
(wallet account.Client, passwd []byte, accAddr string)

Source from the content-addressed store, hash-verified

62}
63
64func GetAccountMulti(wallet account.Client, passwd []byte, accAddr string) (*account.Account, error) {
65 //Address maybe address in base58, label or index
66 if accAddr == "" {
67 defAcc, err := wallet.GetDefaultAccount(passwd)
68 if err != nil {
69 return nil, err
70 }
71 return defAcc, nil
72 }
73 acc, err := wallet.GetAccountByAddress(accAddr, passwd)
74 if err != nil {
75 return nil, fmt.Errorf("getAccountByAddress %s error: %s", accAddr, err)
76 }
77 if acc != nil {
78 return acc, nil
79 }
80 acc, err = wallet.GetAccountByLabel(accAddr, passwd)
81 if err != nil {
82 return nil, fmt.Errorf("getAccountByLabel %s error: %s", accAddr, err)
83 }
84 if acc != nil {
85 return acc, nil
86 }
87 index, err := strconv.ParseInt(accAddr, 10, 32)
88 if err != nil {
89 return nil, fmt.Errorf("cannot get account by address: %s", accAddr)
90 }
91 acc, err = wallet.GetAccountByIndex(int(index), passwd)
92 if err != nil {
93 return nil, fmt.Errorf("getAccountByIndex %d error: %s", index, err)
94 }
95 if acc != nil {
96 return acc, nil
97 }
98 return nil, fmt.Errorf("cannot get account by address: %s", accAddr)
99}
100
101func GetAccountMetadataMulti(wallet account.Client, accAddr string) *account.AccountMetadata {
102 //Address maybe address in base58, label or index

Callers 1

GetAccountFunction · 0.85

Calls 5

ErrorfMethod · 0.80
GetDefaultAccountMethod · 0.65
GetAccountByAddressMethod · 0.65
GetAccountByLabelMethod · 0.65
GetAccountByIndexMethod · 0.65

Tested by

no test coverage detected