diff --git a/pkg/util/config/crypto.go b/pkg/util/config/crypto.go index 33fd245c3..a8974a56b 100644 --- a/pkg/util/config/crypto.go +++ b/pkg/util/config/crypto.go @@ -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,9 +18,17 @@ func LoadAccount(path, addr, password string) (*wallet.Account, error) { defer w.Close() - h, err := address.StringToUint160(addr) - if err != nil { - return nil, err + 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)