forked from TrueCloudLab/frostfs-node
[#710] cli: Make --address
flag optional
If `--address` was not presented use default wallet address and do not require it. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
62efa3f098
commit
9aa6ab4fc9
1 changed files with 14 additions and 8 deletions
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/cli/flags"
|
||||
"github.com/nspcc-dev/neo-go/cli/input"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg"
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/client"
|
||||
|
@ -220,16 +221,21 @@ func getKeyFromNEP2(encryptedWif string) (*ecdsa.PrivateKey, error) {
|
|||
}
|
||||
|
||||
func getKeyFromWallet(w *wallet.Wallet, addrStr string) (*ecdsa.PrivateKey, error) {
|
||||
if addrStr == "" {
|
||||
printVerbose("Address is empty")
|
||||
return nil, errInvalidAddress
|
||||
}
|
||||
var (
|
||||
addr util.Uint160
|
||||
err error
|
||||
)
|
||||
|
||||
addr, err := flags.ParseAddress(addrStr)
|
||||
if addrStr == "" {
|
||||
printVerbose("Using default wallet address")
|
||||
addr = w.GetChangeAddress()
|
||||
} else {
|
||||
addr, err = flags.ParseAddress(addrStr)
|
||||
if err != nil {
|
||||
printVerbose("Can't parse address: %s", addrStr)
|
||||
return nil, errInvalidAddress
|
||||
}
|
||||
}
|
||||
|
||||
acc := w.GetAccount(addr)
|
||||
if acc == nil {
|
||||
|
|
Loading…
Reference in a new issue