cli

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AppHelpTemplate = `` /* 651-byte string literal not displayed */

	AddressCommand = &cli.Command{
		Name:     "address",
		Usage:    "Manage addresses",
		Category: "Addresss",
		Description: `
					Manage addresses, create, delete load etc.`,
		Subcommands: []*cli.Command{
			{
				Name:   "create",
				Usage:  "create <passphrase>",
				Action: CreateAddress,
				Flags:  []cli.Flag{},
				Description: `
				Creates a new address from passphrase`,
			},
			{
				Name:   "info",
				Usage:  "info <keypath> <passphrase>",
				Action: GetAddressInfo,
				Flags:  []cli.Flag{},
				Description: `
				Get key information`,
			},
			{
				Name:   "create_node_key",
				Usage:  "create_node_key <passphrase>",
				Action: CreateNodeIDKey,
				Flags:  []cli.Flag{},
				Description: `
				Creates a new node identity key`,
			},
			{
				Name:   "list",
				Usage:  "list",
				Action: ListAddresses,
				Flags:  []cli.Flag{},
				Description: `
				Lists all available addresses`,
			},
		},
	}

	StorageCommand = &cli.Command{
		Name:     "storage",
		Usage:    "Manage file storage",
		Category: "Storage",
		Description: `
					Manage storage, add or remove files to local storage`,
		Subcommands: []*cli.Command{
			{
				Name:   "add",
				Usage:  "add <filepath>",
				Action: AddFile,
				Flags:  []cli.Flag{},
				Description: `
				Add a new file to storage given its full path`,
			},
			{
				Name:   "get",
				Usage:  "get <filehash>",
				Action: GetFile,
				Flags:  []cli.Flag{},
				Description: `
				Get file's metadata from file hash`,
			},
		},
	}
)
View Source
var ClientCommand = &cli.Command{
	Name:     "client",
	Usage:    "JSONRPC Client commands",
	Category: "Client",
	Description: `
	Interact with node using JSONRPC client`,
	Subcommands: []*cli.Command{
		{
			Name:   "endpoint",
			Usage:  "endpoint http://localhost:8090/rpc",
			Action: SetEndpoint,
			Flags:  []cli.Flag{},
			Description: `
			Sets the jsonrpc endpoint address`,
		},
		{
			Name:   "upload",
			Usage:  "upload <filepath> <storage_access_token> <node_hash>",
			Action: UploadFile,
			Flags:  []cli.Flag{},
			Description: `
			Uploads a file to a node. The node_hash is optional, you can omit it if you dont want to reference a channel node item on the blockchain`,
		},
		{
			Name:   "get_storage_token",
			Usage:  "get_storage_token <admin_token>",
			Action: GetStorageAccessToken,
			Flags:  []cli.Flag{},
			Description: `
			Gets a storage access token derived from the admin token`,
		},
		{
			Name:   "balance",
			Usage:  "balance <address>",
			Action: GetBalance,
			Flags:  []cli.Flag{},
			Description: `
			Get the balance of address`,
		},
		{
			Name:   "send_transaction",
			Usage:  "send_transaction <access_token> <nounce> <data> <from_address> <to_address> <tx_value> <tx_fees>",
			Action: SendTransaction,
			Flags:  []cli.Flag{},
			Description: `
			Sends a transaction given the access token, nouce, data, from and to with the value and fees`,
		},
		{
			Name:   "unlock_address",
			Usage:  "unlock_address <address> <passphrase>",
			Action: UnlockAddress,
			Flags:  []cli.Flag{},
			Description: `
			Unlock an address with the given passphrase and returns a jwt token`,
		},
		{
			Name:   "query",
			Usage:  "query filehash1,filehash2,filehash3",
			Action: SendDataQuery,
			Flags:  []cli.Flag{},
			Description: `
			Sends a data query request by a comma separate list of file hashes`,
		},
		{
			Name:   "responses",
			Usage:  "responses <data_query_request_hash>",
			Action: CheckDataQueryResponses,
			Flags:  []cli.Flag{},
			Description: `
			Checks for data query responses given the data query request hash`,
		},
		{
			Name:   "create_contracts",
			Usage:  "create_contracts <data_query_request_hash>",
			Action: CreateContractsFromDataQueryResponses,
			Flags:  []cli.Flag{},
			Description: `
			Creates a list of download contracts and prints their hashes`,
		},
		{
			Name:   "create_send_tx_with_contracts",
			Usage:  "create_send_tx_with_contracts <contract_hash1,contract_hash2> <jwt_access_token> <current_nounce> <each_tx_fee>",
			Action: CreateSendTXContracts,
			Flags:  []cli.Flag{},
			Description: `
			Prepares a tx with all the contracts`,
		},
		{
			Name:   "download",
			Usage:  "download <contract_hash1> <file_hash> <file_size>",
			Action: DownloadFile,
			Flags:  []cli.Flag{},
			Description: `
			Downloads a file given the contract hash and file hash`,
		},
		{
			Name:   "send_file_signature_to_verifier",
			Usage:  "send_file_signature_to_verifier <contract_hash1> <file_hash>",
			Action: SendFileMerkleTreeNodesToVerifier,
			Flags:  []cli.Flag{},
			Description: `
			Creates a merkle tree nodes of downloaded file and sends to verifier`,
		},
		{
			Name:   "decrypt_files",
			Usage:  "decrypt_files <contract_hash> <file_hash1,file_hash2> <file1_merkle_root_hash,file2_merkle_root_hash> <restore_full_path_file1,restore_full_path_file2>",
			Action: DecryptAllFiles,
			Flags:  []cli.Flag{},
			Description: `
			Decrypts and restores the given files to the supplied destinations`,
		},
		{
			Name:   "host_info",
			Usage:  "host_info",
			Action: GetHostInfo,
			Flags:  []cli.Flag{},
			Description: `
			Gets the host information including addresses, peerID and peer count`,
		},
	},
}

ClientCommand is exposes the client functionality to the cli

Functions

func AddFile

func AddFile(ctx *cli.Context) error

AddFile adds a file to local storage.

func CheckDataQueryResponses

func CheckDataQueryResponses(ctx *cli.Context) error

CheckDataQueryResponses checks for data query responses.

func CreateAddress

func CreateAddress(ctx *cli.Context) error

CreateAddress creates a new keystore file.

func CreateContractsFromDataQueryResponses

func CreateContractsFromDataQueryResponses(ctx *cli.Context) error

CreateContractsFromDataQueryResponses creates a list of contracts given the data query request hash.

func CreateNodeIDKey

func CreateNodeIDKey(ctx *cli.Context) error

CreateNodeIDKey creates a node key identity file.

func CreateSendTXContracts

func CreateSendTXContracts(ctx *cli.Context) error

CreateSendTXContracts creates transactions with download contracts.

func DecryptAllFiles

func DecryptAllFiles(ctx *cli.Context) error

func DownloadFile

func DownloadFile(ctx *cli.Context) error

func GetAddressInfo

func GetAddressInfo(ctx *cli.Context) error

GetAddressInfo gets the address info.

func GetBalance

func GetBalance(ctx *cli.Context) error

GetBalance returns the balance of an address

func GetFile

func GetFile(ctx *cli.Context) error

GetFile gets file's metadata from hash

func GetHostInfo

func GetHostInfo(ctx *cli.Context) error

GetHostInfo gets host's info

func GetStorageAccessToken

func GetStorageAccessToken(ctx *cli.Context) error

func ListAddresses

func ListAddresses(ctx *cli.Context) error

ListAddresses list the addresses on this node.

func SendDataQuery

func SendDataQuery(ctx *cli.Context) error

SendDataQuery sends a data query.

func SendFileMerkleTreeNodesToVerifier

func SendFileMerkleTreeNodesToVerifier(ctx *cli.Context) error

func SendTransaction

func SendTransaction(ctx *cli.Context) error

SendTransaction sends a transaction.

func SetEndpoint

func SetEndpoint(ctx *cli.Context) error

SetEndpoint sets the endpoint to be used across the client commands.

func UnlockAddress added in v1.1.5

func UnlockAddress(ctx *cli.Context) error

func UploadFile

func UploadFile(ctx *cli.Context) error

UploadFile uploads a file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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