util

package
v0.0.0-...-3ef0e5c Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Primary = "primary"
	Issuer  = "issuer"
	Trader  = "trader"
)
View Source
const (
	DropsPerXRP = 1000000
)
View Source
const (
	RecommendedLedgerInterval uint32 = 5
)

Variables

This section is empty.

Functions

func AskForConfirmation

func AskForConfirmation() bool

askForConfirmation uses Scanln to parse user input. A user must type in "yes" or "no" and then press enter. It has fuzzy matching, so "y", "Y", "yes", "YES", and "Yes" all count as confirmations. If the input is not recognized, it will ask again. The function does not return until it gets a valid response from the user. Typically, you should use fmt to print out a question before calling askForConfirmation. E.g. fmt.Println("WARNING: Are you sure? (yes/no)")

func FormatTransactionWithMetaDataHeader

func FormatTransactionWithMetaDataHeader() string

func FormatTransactionWithMetaDataRow

func FormatTransactionWithMetaDataRow(tx *data.TransactionWithMetaData) string

func FormatValue

func FormatValue(v data.Value) string

Print a numeric value, avoiding scientific notation.

func GetPrimaryAccount

func GetPrimaryAccount() (*data.Account, error)

func GetRippledUrl

func GetRippledUrl() (string, error)

Deprecating RPC in favor of websockets...

func GetRippledWSS

func GetRippledWSS() (string, error)

func LintTransaction

func LintTransaction(txm *data.TransactionWithMetaData) []string

Analyze transaction for possible flaws. Format as human readable strings.

func ParseCompleteLedgers

func ParseCompleteLedgers(v string) (uint32, uint32, error)

Function ParseCompleteLedgers accepts a complete_ledgers string and returns the min and max ledgers of the most recent continuous chunk of ledger history available.

func SetAddress

func SetAddress(address string) func(*Wallet) error

func SetSecret

func SetSecret(secret string) func(*Wallet) error

func Sign

func Sign(t data.Transaction, keypair Keypair) (hash, tx_blob string, err error)

Function Sign adds signature to transaction and returns tx_blob suitable for submitting to network.

Types

type AccountTxIterator

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

func NewAccountTxIterator

func NewAccountTxIterator(client rpc.Client, address string, forward bool, min, max uint32) *AccountTxIterator

func (*AccountTxIterator) Advance

func (iter *AccountTxIterator) Advance(index uint32) error

func (*AccountTxIterator) Bounds

func (iter *AccountTxIterator) Bounds() (uint32, uint32)

func (*AccountTxIterator) Close

func (iter *AccountTxIterator) Close()

func (*AccountTxIterator) Error

func (iter *AccountTxIterator) Error() error

func (*AccountTxIterator) Get

func (iter *AccountTxIterator) Get() (rpc.TxMeta, error)

func (*AccountTxIterator) Next

func (iter *AccountTxIterator) Next() bool

type Keypair

type Keypair struct {
	Address string

	KeyType data.KeyType
	// contains filtered or unexported fields
}

func GetPrimaryKeypair

func GetPrimaryKeypair() (Keypair, error)

func NewEcdsaFromSecret

func NewEcdsaFromSecret(secret string) (Keypair, error)

func (Keypair) PublicKey

func (kp Keypair) PublicKey() data.PublicKey

Returns public key in hexidecimal.

func (Keypair) Sign

func (pair Keypair) Sign(tx data.Transaction) error

type ServerInfo

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

func NewServerInfoUpdater

func NewServerInfoUpdater(client rpc.Client) (*ServerInfo, error)

func (*ServerInfo) Fee

func (server *ServerInfo) Fee() int

func (*ServerInfo) LedgerIndexBounds

func (info *ServerInfo) LedgerIndexBounds() (uint32, uint32)

func (*ServerInfo) LedgerIndexMax

func (info *ServerInfo) LedgerIndexMax() uint32

func (*ServerInfo) LedgerIndexMin

func (info *ServerInfo) LedgerIndexMin() uint32

func (*ServerInfo) Result

func (info *ServerInfo) Result() *rpc.ServerInfoResult

func (*ServerInfo) SignSubmitRetry

func (server *ServerInfo) SignSubmitRetry(t data.Transaction, keypair Keypair) (rpc.TxResult, error)

This is part of *ServerInfo because ledger history is known, checked vs LastLedgerSequence

func (*ServerInfo) SignSubmitWait

func (server *ServerInfo) SignSubmitWait(t data.Transaction, keypair Keypair) (rpc.TxResult, error)

This is part of *ServerInfo because ledger history is known, checked vs LastLedgerSequence

type Subscription

type Subscription struct {

	// Make "Remote" public so that calls can made to it directly.
	Remote *websockets.Remote
	// contains filtered or unexported fields
}

func NewSubscription

func NewSubscription(wss string) (*Subscription, error)

func (*Subscription) AfterSequence

func (sub *Subscription) AfterSequence(until uint32) <-chan uint32

Modelled on time.After(), this function provides a convenient way to wait for a specific ledger instance to pass.

func (*Subscription) AfterTime

func (sub *Subscription) AfterTime(when interface{}) <-chan data.RippleTime

Modelled on time.After(), this function provides a convenient way to wait for a specific ledger instance to pass.

func (*Subscription) AfterTx

func (sub *Subscription) AfterTx(hash data.Hash256, min, max uint32) <-chan *websockets.TxResult

func (*Subscription) Ledgers

func (sub *Subscription) Ledgers() (uint32, uint32, error)

func (*Subscription) Loop

func (sub *Subscription) Loop()

func (*Subscription) SignAndSubmitFunc

func (sub *Subscription) SignAndSubmitFunc(wallet *Wallet, t data.Transaction) func() error

Helper to sign and submit a transaction. Returns a func with errgroup.Group compatible signature.

func (*Subscription) SubmitWait

func (sub *Subscription) SubmitWait(t data.Transaction) (*websockets.TxResult, error)

func (*Subscription) SuggestLastLedger

func (sub *Subscription) SuggestLastLedger(delta uint32) uint32

type Wallet

type Wallet struct {
	Address        string // deprecated, delete once replace with account.
	Account        *data.Account
	Sequence       uint32      // if unknown will be 0
	LedgerSequence uint32      // 0 if unknown, otherwise when account_info returned data.
	Balance        *data.Value // XRP Balance as of LastLedger
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(options ...func(*Wallet) error) (*Wallet, error)

func (*Wallet) GetAccountInfo

func (wallet *Wallet) GetAccountInfo(remote *websockets.Remote) error

func (*Wallet) GetAccountInfoRPC

func (wallet *Wallet) GetAccountInfoRPC(client rpc.Client, ledgerIndex *uint32) error

Deprecated in favor of websockets.

func (*Wallet) Sign

func (wallet *Wallet) Sign(t data.Transaction) (hash, tx_blob string, err error)

TODO: this modifies the transaction (?) probably no need to return hash and blob.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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