2023-11-08 13:36:55 +00:00
|
|
|
package morph
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2024-01-12 10:54:00 +00:00
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
2023-11-08 13:36:55 +00:00
|
|
|
"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"
|
2024-01-12 10:54:00 +00:00
|
|
|
"github.com/spf13/cobra"
|
2023-11-08 13:36:55 +00:00
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
2023-12-04 13:12:59 +00:00
|
|
|
func getFrostfsIDAdmin(v *viper.Viper) (util.Uint160, bool, error) {
|
|
|
|
admin := v.GetString(frostfsIDAdminConfigKey)
|
|
|
|
if admin == "" {
|
|
|
|
return util.Uint160{}, false, nil
|
|
|
|
}
|
2023-11-08 13:36:55 +00:00
|
|
|
|
2023-12-04 13:12:59 +00:00
|
|
|
h, err := address.StringToUint160(admin)
|
|
|
|
if err == nil {
|
|
|
|
return h, true, nil
|
|
|
|
}
|
2023-11-08 13:36:55 +00:00
|
|
|
|
2023-12-04 13:12:59 +00:00
|
|
|
h, err = util.Uint160DecodeStringLE(admin)
|
|
|
|
if err == nil {
|
|
|
|
return h, true, nil
|
|
|
|
}
|
2023-11-08 13:36:55 +00:00
|
|
|
|
2023-12-04 13:12:59 +00:00
|
|
|
pk, err := keys.NewPublicKeyFromString(admin)
|
|
|
|
if err == nil {
|
|
|
|
return pk.GetScriptHash(), true, nil
|
2023-11-08 13:36:55 +00:00
|
|
|
}
|
2023-12-04 13:12:59 +00:00
|
|
|
return util.Uint160{}, true, fmt.Errorf("frostfsid: admin is invalid: '%s'", admin)
|
2023-11-08 13:36:55 +00:00
|
|
|
}
|
2024-01-12 10:54:00 +00:00
|
|
|
|
|
|
|
func getFrostfsIDSubjectKey(cmd *cobra.Command) *keys.PublicKey {
|
|
|
|
subjKeyHex, _ := cmd.Flags().GetString(subjectKeyFlag)
|
|
|
|
subjKey, err := keys.NewPublicKeyFromString(subjKeyHex)
|
|
|
|
commonCmd.ExitOnErr(cmd, "invalid subject key: %w", err)
|
|
|
|
return subjKey
|
|
|
|
}
|
|
|
|
|
|
|
|
//func decodeFrostfsIDNamespaces(resStack []stackitem.Item) ([]string, error) {
|
|
|
|
// var res []string
|
|
|
|
//
|
|
|
|
// if len(resStack) == 0 {
|
|
|
|
// return res, nil
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if len(resStack) > 0 {
|
|
|
|
// nodes, err := decodeNodeList(resStack[0])
|
|
|
|
// if err != nil {
|
|
|
|
// return nil, err
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// nm.SetNodes(nodes)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
//}
|