forked from TrueCloudLab/frostfs-node
[#1467] pkg/util: Allow to load default account from a wallet
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
2da8396a9f
commit
d84d52924a
1 changed files with 12 additions and 3 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
)
|
||||
|
||||
|
@ -17,10 +18,18 @@ func LoadAccount(path, addr, password string) (*wallet.Account, error) {
|
|||
|
||||
defer w.Close()
|
||||
|
||||
h, err := address.StringToUint160(addr)
|
||||
var h util.Uint160
|
||||
if addr == "" {
|
||||
h = w.GetChangeAddress()
|
||||
if h.Equals(util.Uint160{}) {
|
||||
return nil, errors.New("can't find a suitable account in the wallet")
|
||||
}
|
||||
} else {
|
||||
h, err = address.StringToUint160(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
acc := w.GetAccount(h)
|
||||
if acc == nil {
|
||||
|
|
Loading…
Reference in a new issue