txs

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2017 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Index

Constants

View Source
const (
	UserFlag = "user"
	AgeFlag  = "age"
)
View Source
const (
	NameFlag  = "name"
	InputFlag = "input"
)

Variables

View Source
var DemoCmd = &cobra.Command{
	Use:   "demo",
	Short: "Demo tx creation",
	RunE:  commands.RequireInit(runDemo),
}
View Source
var RootCmd = &cobra.Command{
	Use:   "tx",
	Short: "Create and post transactions to the node",
}

RootCmd represents the base command when called without any subcommands

Functions

func GetSigner added in v0.10.1

func GetSigner() crypto.PubKey

GetSigner returns the pub key that will sign the tx returns empty key if no name provided

func LoadJSON added in v0.10.1

func LoadJSON(template interface{}) (bool, error)

LoadJSON will read a json file from disk if --input is passed in template is a pointer to a struct that can hold the expected data (&MyTx{})

If not data is provided, returns (false, nil) If data is provided and passes, returns (true, nil) If data is provided but not parsable, returns (true, err)

func OutputTx added in v0.10.1

func OutputTx(res *ctypes.ResultBroadcastTxCommit) error

OutputTx prints the tx result to stdout TODO: something other than raw json?

func Sign added in v0.10.1

func Sign(tx interface{}) (packet []byte, err error)

Sign if it is Signable, otherwise, just convert it to bytes

func SignAndPostTx added in v0.10.1

func SignAndPostTx(tx Validatable) (*ctypes.ResultBroadcastTxCommit, error)

SignAndPostTx does all work once we construct a proper struct it validates the data, signs if needed, transforms to bytes, and posts to the node.

Types

type DemoTx added in v0.10.1

type DemoTx struct {
	User string `json:"user"`
	Age  int    `json:"age"`
}

func (DemoTx) Bytes added in v0.10.1

func (d DemoTx) Bytes() []byte

func (DemoTx) ValidateBasic added in v0.10.1

func (d DemoTx) ValidateBasic() error

type Validatable added in v0.10.1

type Validatable interface {
	ValidateBasic() error
}

Jump to

Keyboard shortcuts

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