txs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagName    = "name"
	FlagNoSign  = "no-sign"
	FlagIn      = "in"
	FlagPrepare = "prepare"
)

nolint

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "tx",
	Short: "Post tx from json input",
	RunE:  doRawTx,
}

RootCmd represents the base command when called without any subcommands

Functions

func DoTx

func DoTx(tx sdk.Tx) (err error)

DoTx is a helper function for the lazy :)

It uses only public functions and goes through the standard sequence of wrapping the tx with middleware layers, signing it, either preparing it, or posting it and displaying the result.

If you want a non-standard flow, just call the various functions directly. eg. if you already set the middleware layers in your code, or want to output in another format.

func GetSigner

func GetSigner() crypto.PubKey

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

func GetSignerAct

func GetSignerAct() (res sdk.Actor)

GetSignerAct returns the address of the signer of the tx (as we still only support single sig)

func OutputTx

func OutputTx(res *ctypes.ResultBroadcastTxCommit) error

OutputTx validates if success and prints the tx result to stdout

func PostTx

func PostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error)

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

func PrepareOrPostTx

func PrepareOrPostTx(tx sdk.Tx) (*ctypes.ResultBroadcastTxCommit, error)

PrepareOrPostTx checks the flags to decide to prepare the tx for future multisig, or to post it to the node. Returns error on any failure. If no error and the result is nil, it means it already wrote to file, no post, no need to do more.

func PrepareTx

func PrepareTx(tx sdk.Tx) (bool, error)

PrepareTx checks for FlagPrepare and if set, write the tx as json to the specified location for later multi-sig. Returns true if it handled the tx (no futher work required), false if it did nothing (and we should post the tx)

func SignTx

func SignTx(tx sdk.Tx) error

SignTx will validate the tx, and signs it if it is wrapping a Signable. Modifies tx in place, and returns an error if it should sign but couldn't

Types

type Validatable

type Validatable interface {
	ValidateBasic() error
}

Validatable represents anything that can be Validated

type Wrapper

type Wrapper interface {
	Wrap(sdk.Tx) (sdk.Tx, error)
	Register(*pflag.FlagSet)
}

Wrapper defines the information needed for each middleware package that wraps the data. They should read all configuration out of bounds via viper.

var (
	// Middleware must be set in main.go to defined the wrappers we should apply
	Middleware Wrapper
)

type Wrappers

type Wrappers []Wrapper

Wrappers combines a list of wrapper middlewares. The first one is the inner-most layer, eg. Fee, Nonce, Chain, Auth

func (Wrappers) Register

func (ws Wrappers) Register(fs *pflag.FlagSet)

Register adds any needed flags to the command

func (Wrappers) Wrap

func (ws Wrappers) Wrap(tx sdk.Tx) (sdk.Tx, error)

Wrap applies the wrappers to the passed in tx in order, aborting on the first error

Jump to

Keyboard shortcuts

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