client

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 24 Imported by: 26

Documentation

Index

Constants

View Source
const (
	// AuditContractExitCodeInvalidContract is returned as exit code,
	// in case the contract was found, but failed to validate against the given validation flags.
	AuditContractExitCodeInvalidContract = 128
)

Variables

This section is empty.

Functions

func ParsePeriod

func ParsePeriod(period string) (string, error)

ParsePeriod converts a number of weeks to a number of blocks.

func PeriodUnits

func PeriodUnits(blocks types.BlockHeight) string

PeriodUnits turns a period in terms of blocks to a number of weeks.

func Wrap

func Wrap(fn interface{}) func(*cobra.Command, []string)

Wrap wraps a generic command with a check that the command has been passed the correct number of arguments. The command must take only strings as arguments.

func WrapWithConfig added in v1.2.0

func WrapWithConfig(config *Config, fn interface{}) func(*cobra.Command, []string)

WrapWithConfig wraps a generic command with a check that the command has been passed the correct number of arguments, including one extra *Config argument at the front. The command must take only strings as arguments, starting from the second position.

func YesNo

func YesNo(b bool) string

YesNo returns "Yes" if b is true, and "No" if b is false.

Types

type AtomicSwapOutputAudit added in v1.0.7

type AtomicSwapOutputAudit struct {
	Coins    types.Currency            `json:"coins"`
	Contract types.AtomicSwapCondition `json:"contract"`
}

AtomicSwapOutputAudit represents the formatted output of the atomic swap audit command

type AtomicSwapOutputCreation added in v1.0.6

type AtomicSwapOutputCreation struct {
	Coins         types.Currency            `json:"coins"`
	Contract      types.AtomicSwapCondition `json:"contract"`
	ContractID    types.UnlockHash          `json:"contractid"`
	Secret        *types.AtomicSwapSecret   `json:"secret,omitempty"`
	OutputID      types.CoinOutputID        `json:"outputid"`
	TransactionID types.TransactionID       `json:"transactionid"`
}

AtomicSwapOutputCreation represents the formatted output of the atomic swap creation commands (initiate and participate).

type AtomicSwapOutputExtractSecret added in v1.0.6

type AtomicSwapOutputExtractSecret struct {
	Secret types.AtomicSwapSecret `json:"secret"`
}

AtomicSwapOutputExtractSecret represents the formatted output of the atomic swap extract secret command

type AtomicSwapOutputSpendContract added in v1.0.6

type AtomicSwapOutputSpendContract struct {
	TransactionID types.TransactionID `json:"transactionid"`
}

AtomicSwapOutputSpendContract represents the formatted output of the atomic swap spend commands (redeem and refund)

type BaseClient added in v1.3.1

type BaseClient interface {
	Config() (*Config, error)
	HTTP() HTTPClient
	NewCurrencyConvertor() (CurrencyConvertor, error)
}

func NewBaseClient added in v1.3.1

func NewBaseClient(httpClient HTTPClient, config *Config) (BaseClient, error)

func NewBaseClientFromCommandLineClient added in v1.3.1

func NewBaseClientFromCommandLineClient(cli *CommandLineClient) (BaseClient, error)

type CommandLineClient added in v1.2.0

type CommandLineClient struct {
	*api.HTTPClient

	Config *Config

	PreRunE func(*Config) (*Config, error)

	RootCmd       *cobra.Command
	WalletCmd     *WalletCommand
	ConsensusCmd  *cobra.Command
	AtomicSwapCmd *cobra.Command
	GatewayCmd    *cobra.Command
	ExploreCmd    *cobra.Command
	MergeCmd      *cobra.Command
}

CommandLineClient represents the Rivine Reference CLI Client implementation, which can be run as it is, or be extended/modified to fit your needs.

If a config is not loaded automatically, it will be tried to be loaded from the daemon automatically, this might however fail, in which case a DefaultConfigFunc can be registered as callback to fallback to.

func NewCommandLineClient added in v1.2.0

func NewCommandLineClient(address, name, userAgent string, opts *OptionalCommandLineClientCommands) (*CommandLineClient, error)

NewCommandLineClient creates a new CLI client, which can be run as it is, or be extended/modified to fit your needs. If a config is not loaded automatically, it will be tried to be loaded from the daemon automatically, this might however fail.

func (*CommandLineClient) CreateCurrencyConvertor added in v1.2.0

func (cli *CommandLineClient) CreateCurrencyConvertor() CurrencyConvertor

CreateCurrencyConvertor creates a currency convertor using the internally stored Config.

func (*CommandLineClient) Run added in v1.2.0

func (cli *CommandLineClient) Run() error

Run the CLI, logic dependend upon the command the user used.

type Config

type Config struct {
	ChainName    string
	NetworkName  string
	ChainVersion build.ProtocolVersion

	CurrencyUnits             types.CurrencyUnits
	CurrencyCoinUnit          string
	MinimumTransactionFee     types.Currency
	DefaultTransactionVersion types.TransactionVersion

	// These values aren't used for validation,
	// but only in order to estimate progress with the syncing of your consensus.
	BlockFrequencyInSeconds int64
	GenesisBlockTimestamp   types.Timestamp
}

Config defines the configuration for the default (CLI) client.

func ConfigFromDaemonConstants added in v1.0.7

func ConfigFromDaemonConstants(constants modules.DaemonConstants) Config

ConfigFromDaemonConstants returns CLI constants using a daemon's constants as input.

func FetchConfigFromDaemon added in v1.2.0

func FetchConfigFromDaemon(httpClient HTTPClient) (*Config, error)

FetchConfigFromDaemon fetches constants and creates a config, by fetching the constants from the daemon. Returns an error in case the fetching wasn't possible.

type CurrencyConvertor

type CurrencyConvertor struct {
	// contains filtered or unexported fields
}

CurrencyConvertor is used to parse a currency in it's default unit, and turn it into its in-memory smallest unit. Simiarly it allow you to turn the in-memory smallest unit into a string version of the default init.

func NewCurrencyConvertor

func NewCurrencyConvertor(units types.CurrencyUnits, coinUnit string) CurrencyConvertor

NewCurrencyConvertor creates a new currency convertor using the given currency units.

See CurrencyConvertor for more information.

func (CurrencyConvertor) CoinArgDescription

func (cc CurrencyConvertor) CoinArgDescription(argName string) string

CoinArgDescription is used to print a helpful arg description message, for this convertor.

func (CurrencyConvertor) ParseCoinString

func (cc CurrencyConvertor) ParseCoinString(str string) (types.Currency, error)

ParseCoinString parses the given string assumed to be in the default unit, and parses it into an in-memory currency unit of the smallest unit. It will fail if the given string is invalid or too precise.

func (CurrencyConvertor) ToCoinString

func (cc CurrencyConvertor) ToCoinString(c types.Currency) string

ToCoinString turns the in-memory currency unit, into a string version of the default currency unit. This can never fail, as the only thing it can do is make a number smaller.

func (CurrencyConvertor) ToCoinStringWithUnit

func (cc CurrencyConvertor) ToCoinStringWithUnit(c types.Currency) string

ToCoinStringWithUnit turns the in-memory currency unit, into a string version of the default currency unit. This can never fail, as the only thing it can do is make a number smaller. It also adds the unit of the coin behind the coin.

type HTTPClient

type HTTPClient interface {
	Get(call string) error
	GetWithResponse(call string, obj interface{}) error

	Post(call, data string) error
	PostWithResponse(call, data string, obj interface{}) error
}

type LazyBaseClient added in v1.3.1

type LazyBaseClient struct {
	// contains filtered or unexported fields
}

func NewLazyBaseClient added in v1.3.1

func NewLazyBaseClient(once func() (BaseClient, error)) (*LazyBaseClient, error)

func NewLazyBaseClientFromCommandLineClient added in v1.3.1

func NewLazyBaseClientFromCommandLineClient(cli *CommandLineClient) (*LazyBaseClient, error)

func (*LazyBaseClient) Config added in v1.3.1

func (lbc *LazyBaseClient) Config() (*Config, error)

func (*LazyBaseClient) HTTP added in v1.3.1

func (lbc *LazyBaseClient) HTTP() HTTPClient

func (*LazyBaseClient) NewCurrencyConvertor added in v1.3.1

func (lbc *LazyBaseClient) NewCurrencyConvertor() (CurrencyConvertor, error)

type OptionalCommandLineClientCommands added in v1.3.1

type OptionalCommandLineClientCommands struct {
	CommandLineClient *CommandLineClient

	WalletCmd     *WalletCommand
	AtomicSwapCmd *cobra.Command
	GatewayCmd    *cobra.Command
	ExploreCmd    *cobra.Command
	MergeCmd      *cobra.Command
}

OptionalCommandLineClientCommands allows the creator of a command line client to pass commands that the callee created already, as an overwrite.

type StdBaseClient added in v1.3.1

type StdBaseClient struct {
	// contains filtered or unexported fields
}

func (*StdBaseClient) Config added in v1.3.1

func (bc *StdBaseClient) Config() (*Config, error)

func (*StdBaseClient) HTTP added in v1.3.1

func (bc *StdBaseClient) HTTP() HTTPClient

func (*StdBaseClient) NewCurrencyConvertor added in v1.3.1

func (bc *StdBaseClient) NewCurrencyConvertor() (CurrencyConvertor, error)

NewCurrencyConvertor creates a currency convertor using the internally stored Config.

type TransactionPoolClient added in v1.2.0

type TransactionPoolClient struct {
	// contains filtered or unexported fields
}

TransactionPoolClient is used to easily interact with the transaction pool through the HTTP REST API.

func NewTransactionPoolClient added in v1.2.0

func NewTransactionPoolClient(bc BaseClient) *TransactionPoolClient

NewTransactionPoolClient creates a new TransactionPoolClient, that can be used for easy interaction with the TransactionPool API exposed via the HTTP REST API.

func (*TransactionPoolClient) AddTransactiom added in v1.2.0

func (tpool *TransactionPoolClient) AddTransactiom(t types.Transaction) (types.TransactionID, error)

AddTransactiom adds the given transaction to the transaction pool, if valid.

type WalletClient added in v1.2.0

type WalletClient struct {
	// contains filtered or unexported fields
}

WalletClient is used to easily interact with the wallet through the HTTP REST API.

func NewWalletClient added in v1.2.0

func NewWalletClient(bc BaseClient) *WalletClient

NewWalletClient creates a new WalletClient, that can be used for easy interaction with the Wallet API exposed via the HTTP REST API.

func (*WalletClient) FundCoins added in v1.2.0

func (wallet *WalletClient) FundCoins(amount types.Currency, refundAddress *types.UnlockHash, newRefundAddress bool) ([]types.CoinInput, *types.CoinOutput, error)

FundCoins collects coin inputs owned by this daemon's wallet, that are sufficient to fund the given amount, optionally returning a refund coin output as well.

func (*WalletClient) GreedySignTx added in v1.2.0

func (wallet *WalletClient) GreedySignTx(t *types.Transaction) error

GreedySignTx signs the given transactions greedy, meaning that all fulfillments that can be signed, will be signed.

func (*WalletClient) NewPublicKey added in v1.2.0

func (wallet *WalletClient) NewPublicKey() (types.PublicKey, error)

NewPublicKey creates a new public key (from an index and the wallet's primary seed), and returns it.

type WalletCommand added in v1.2.0

type WalletCommand struct {
	*cobra.Command

	RootCmdSend   *cobra.Command
	RootCmdLoad   *cobra.Command
	RootCmdList   *cobra.Command
	RootCmdCreate *cobra.Command
}

WalletCommand returns the Wallet Command as an extended cobra command, exposing its sub command groups directly as public properties.

Jump to

Keyboard shortcuts

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