Help us shape the future of Go! Take the 2026 Go Developer Survey

pkcmd

package
v0.0.31 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PushKeyRegCmd = &cobra.Command{
	Use:   "register [flags] <publicKey|keyId>",
	Short: "Register a public key on the network",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return fmt.Errorf("account ID or public key is required")
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		target := args[0]
		targetPass, _ := cmd.Flags().GetString("pass")
		fee, _ := cmd.Flags().GetFloat64("fee")
		signingKey, _ := cmd.Flags().GetString("signing-key")
		signingKeyPass, _ := cmd.Flags().GetString("signing-key-pass")
		nonce, _ := cmd.Flags().GetUint64("nonce")
		scopes, _ := cmd.Flags().GetStringSlice("scopes")
		feeCap, _ := cmd.Flags().GetFloat64("feeCap")

		_, client := common.GetRepoAndClient(cmd, cfg, "")
		if err := RegisterCmd(cfg, &RegisterArgs{
			Target:              target,
			TargetPass:          targetPass,
			Fee:                 fee,
			SigningKey:          signingKey,
			SigningKeyPass:      signingKeyPass,
			Nonce:               nonce,
			RPCClient:           client,
			Scopes:              scopes,
			FeeCap:              feeCap,
			KeyUnlocker:         common.UnlockKey,
			GetNextNonce:        api.GetNextNonceOfAccount,
			RegisterPushKey:     api.RegisterPushKey,
			ShowTxStatusTracker: common.ShowTxStatusTracker,
			Stdout:              os.Stdout,
		}); err != nil {
			log.Fatal(err.Error())
		}
	},
}

PushKeyRegCmd represents a sub-command to register a public key as a push key

Functions

func RegisterCmd

func RegisterCmd(cfg *config.AppConfig, args *RegisterArgs) error

RegisterCmd creates a transaction to register a public key as a push key

Types

type RegisterArgs

type RegisterArgs struct {

	// PublicKeyOrAddressID refers the the key to be registered. It may contain a base58
	// public key or an address/index of a local account
	Target string

	// TargetPass contains the passphrase for unlocking the target if it refers to a local account
	TargetPass string

	// Nonce is the next nonce of the signing key's account
	Nonce uint64

	// Fee is the transaction fee to be paid by the signing key
	Fee float64

	// Scopes are the namespaces and repo the contributor
	Scopes []string

	// FeeCap is the hard limit of how much fees spendable by the push key
	FeeCap float64

	// Account is the account whose key will be used to sign the transaction.
	SigningKey string

	// AccountPass is the passphrase for unlocking the signing key.
	SigningKeyPass string

	// RpcClient is the RPC client
	RPCClient types.Client

	// KeyUnlocker is a function for getting and unlocking a push key from keystore.
	KeyUnlocker common.UnlockKeyFunc

	// GetNextNonce is a function for getting the next nonce of an account
	GetNextNonce api.NextNonceGetter

	// CreatRegisterPushKey is a function for creating a transaction for registering a push key
	RegisterPushKey api.PushKeyRegister

	// ShowTxStatusTracker is a function tracking and displaying tx status
	ShowTxStatusTracker common.TxStatusTrackerFunc

	Stdout io.Writer
}

RegisterArgs contains arguments for RegisterCmd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL