rpc

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: 12 Imported by: 0

Documentation

Overview

Helpers to make JSON-RPC calls to rippled.

Index

Constants

View Source
const (
	DropsPerXRP = 1000000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Account              string
	Balance              uint64 `json:",string"`
	Flags                uint32
	LedgerEntryType      string
	OwnerCount           uint32
	PreviousTxnId        string
	PrevioutTxnLedgerSeq uint32 // correct type?
	Sequence             uint32
	Index                string
}

type AccountInfoParams

type AccountInfoParams struct {
	Account      string `json:"account"`
	Ledger_index *int32 `json:"ledger_index,omitempty"` // TODO: support "current", "closed", "validated"
}

type AccountInfoResult

type AccountInfoResult struct {
	Result
	Account_data AccountInfo
}

account_info {"account_data":{"Account":"rs2GgdxJx34DwwAUsz1wse3yUCnggQpCCg","Balance":"10000000000","Flags":0,"LedgerEntryType":"AccountRoot","OwnerCount":0,"PreviousTxnID":"F295A38531D6808917F6B42A5E583F89D0613C0153096F497648C771EADE183A","PreviousTxnLgrSeq":1918860,"Sequence":1,"index":"3066338D048B57636FA27F4027619FD8910AF9C1E2F2148AECA288B1B85D8E9F"},"ledger_current_index":1974161,"status":"success","validated":false}

type AccountLine

type AccountLine struct {
	Account        string     `json:"account"`
	Balance        data.Value `json:"balance"`
	Currency       string     `json:"currency"`
	Limit          data.Value `json:"limit"`
	Limit_peer     data.Value `json:"limit_peer"`
	No_ripple      bool       `json:"no_ripple"`
	No_ripple_peer bool       `json:"no_ripple_peer"`
	Quality_in     uint32     `json:"quality_in"`
	Quality_out    uint32     `json:"quality_out"`
	Freeze         bool       `json:"freeze"`
	Freeze_peer    bool       `json:"freeze_peer"`
}

type AccountLinesParams

type AccountLinesParams struct {
	Account string `json:"account"`
}

type AccountLinesResult

type AccountLinesResult struct {
	Result
	Account string        `json:"account"`
	Lines   []AccountLine `json:"lines"`
}

type AccountOffersParams

type AccountOffersParams struct {
	Account string `json:"account"`
}

type AccountOffersResult

type AccountOffersResult struct {
	Result
	Account              string              `json:"account"`
	Ledger_current_index uint32              `json:"ledger_current_index"`
	Offers               []data.AccountOffer `json:"offers"`
}

type AccountTxParams

type AccountTxParams struct {
	Account          string          `json:"account"`
	Ledger_index_min uint32          `json:"ledger_index_min"`
	Ledger_index_max uint32          `json:"ledger_index_max"`
	Limit            int             `json:"limit"`
	Forward          bool            `json:"forward"`
	Marker           json.RawMessage `json:"marker"`
}

type AccountTxResult

type AccountTxResult struct {
	Result
	Account string `json:"account"`

	Transactions []TxMeta        `json:"transactions"`
	Marker       json.RawMessage `json:"marker, omitempty"`
}

type Client

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

func NewClient

func NewClient(url string, insecure bool) (Client, error)

func (Client) Close

func (client Client) Close()

func (Client) Do

func (client Client) Do(method string, params interface{}, target interface{}) (int, error)

TODO: re-order params to Do() and allow any number of ...params Do() is being deprecated, use Request() below.

func (Client) Request

func (client Client) Request(method string, params ...interface{}) (*Response, error)

func (Client) String

func (c Client) String() string

func (Client) Submit

func (client Client) Submit(blob string) (ResultSubmit, error)

Submit a signed transaction blob. TODO: should this be moved to rpc package?

type LedgerInfo

type LedgerInfo struct {
	Ledger_index string // yes, string
	Ledger_hash  string
	Account_hash string

	// TODO Transactions can be just hashes, if expand == false
	Transactions []TxResult // Is this right?
}

type LedgerParams

type LedgerParams struct {
	Ledger_index *int32 `json:"ledger_index,omitempty"` // TODO: support "current", "closed", "validated"
	Accounts     bool   `json:"accounts"`
	Full         bool   `json:"full"`
	Transactions bool   `json:"transactions"`
	Expand       bool   `json:"expand"`
}

type LedgerResult

type LedgerResult struct {
	Result
	Ledger LedgerInfo
}

type MetaData

type MetaData struct {
	AffectedNodes     data.NodeEffects
	TransactionIndex  uint32
	TransactionResult data.TransactionResult
	DeliveredAmount   *data.Amount `json:"delivered_amount,omitempty"`
}

type PathFind

type PathFind struct {
	Destination_account string      `json:"destination_account"`
	Destination_amount  data.Amount `json:"destination_amount"`
}

type PaymentResultXXX

type PaymentResultXXX struct {
	TxResultNoRaw

	Amount         data.Amount
	Address        string
	Destination    string
	InvoiceID      *string
	DestinationTag *uint32
}

Payments are a transaction type that we want to inspect more fields than TxResult provides.

type PaymentResultXXXX

type PaymentResultXXXX struct {
	Result
	data.Payment

	Ledger_index uint32 `json:"ledger_index,omitempty"` // account_tx returns this

	Meta      *MetaData // "tx" returns this.
	Validated *bool     // "tx" returns this.

}

type Request

type Request struct {
	Method string        `json:"method"`
	Params []interface{} `json:"params"`
}

type Response

type Response struct {
	Result    json.RawMessage `json:"result"`
	Validated *bool           `json:"validated"` // Appears in response to "tx"
	// contains filtered or unexported fields
}

JSON-RPC response {"result":{..., "status": "..."}}

func (Response) IsValidated

func (r Response) IsValidated() bool

func (Response) ResultString

func (res Response) ResultString() string

func (Response) StatusCode

func (res Response) StatusCode() int

func (Response) String

func (res Response) String() string

func (Response) UnmarshalResult

func (res Response) UnmarshalResult(v interface{}) error

type Result

type Result struct {
	// Always present:
	Status string

	// Present only when error:
	Error         string `json:"error,omitempty"`
	Error_code    int
	Error_message string
	Request       json.RawMessage

	// Other errors
	Error_exception string `json:"error_exception"`

	// Present sometimes:
	Ledger_current_index int // type ???
	Validated            bool
}

Examples of potential errors: {"result":{"error":"unknownCmd","error_code":31,"error_message":"Unknown method.","request":{"command":"server_infoX"},"status":"error"}} {"error":"invalidTransaction","error_exception":"Unknown field","request":{"command":"submit","tx_blob":"12000024000000012021000000026880000000000000007321026C80D7F11B33BE4E2794E489295346ACC31F0719DB2FA6C378E6E7BF325873A074473045022100F9123F923267F3E91539397C8353DD1BE55C531DD9F9D18B662A7B3035E0BA5502200F2F2B18DD3277B7575E2792A0FD9A08FC2C3888F0ACE14598AC5F67F05F208C81141C3B11F542BBA14819B579D59FBA1EB17457B2BB"},"status":"error"}

type ResultSubmit

type ResultSubmit struct {
	Result
	Engine_result         string   `json:"engine_result"`
	Engine_result_message string   `json:"engine_result_message"`
	Tx_json               TxResult `json:"tx_json"` // Needed for hash and possibly more
	Tx_blob               string   `json:"tx_blob"`
}

func (ResultSubmit) String

func (result ResultSubmit) String() string

type ServerInfo

type ServerInfo struct {
	Result
	Build_version    string
	Complete_ledgers string
	Hostid           string
	Load_factor      float64 // Not integer!
	Peers            int
	Pubkey_node      string
	Server_state     string
	Uptime           int
	Validated_ledger *ValidatedLedger
}

func (*ServerInfo) Fee

func (server *ServerInfo) Fee() int

Estimates the current transaction fee, in drops. Computed as described in https://ripple.com/build/transaction-cost/#server-info

type ServerInfoResult

type ServerInfoResult struct {
	Result
	Info ServerInfo
}

"{\"info\":{\"build_version\":\"0.70.0-b8\",\"complete_ledgers\":\"1955521-1967811\",\"hostid\":\"HI\",\"io_latency_ms\":1,\"last_close\":{\"converge_time_s\":1.999,\"proposers\":4},\"load_factor\":1,\"peers\":5,\"pubkey_node\":\"n9KMmZw85d5erkaTv62Vz6SbDJSyeihAEB3jwnb3Bqnr2AydRVep\",\"server_state\":\"proposing\",\"state_accounting\":{\"connected\":{\"duration_us\":\"4999978\",\"transitions\":1},\"disconnected\":{\"duration_us\":\"1262060\",\"transitions\":1},\"full\":{\"duration_us\":\"410736965528\",\"transitions\":1},\"syncing\":{\"duration_us\":\"5002153\",\"transitions\":1},\"tracking\":{\"duration_us\":\"2\",\"transitions\":1}},\"uptime\":410748,\"validated_ledger\":{\"base_fee_xrp\":1e-05,\"hash\":\"77147A57D2351EB97F6F6C709B94364E6B9C47525D0D02E7958575F4AB525BF4\",\"reserve_base_xrp\":20,\"reserve_inc_xrp\":5,\"seq\":1967811},\"validation_quorum\":4},\"status\":\"success\"}",

func (*ServerInfoResult) String

func (info *ServerInfoResult) String() string

type SubmitParams

type SubmitParams struct {
	Tx_blob   string `json:"tx_blob"`
	Fail_hard bool   `json:"fail_hard"`
}

type TxMeta

type TxMeta struct {
	Tx TxResult `json:"tx"` // Note this will not have "validated" or "status"
	//Tx        data.Transaction `json:"tx"` // rubblelabs (better?)
	Meta      TxMetaData `json:"meta"`
	Validated *bool      `json:"validated"`
}

func (*TxMeta) After

func (a *TxMeta) After(b *TxMeta) bool

func (*TxMeta) Before

func (a *TxMeta) Before(b *TxMeta) bool

func (*TxMeta) IsValidated

func (tm *TxMeta) IsValidated() bool

func (*TxMeta) String

func (tm *TxMeta) String() string

type TxMetaData

type TxMetaData struct {
	AffectedNodes     data.NodeEffects
	TransactionIndex  uint32
	TransactionResult data.TransactionResult
	DeliveredAmount   *data.Amount `json:"delivered_amount,omitempty"`
}

Not sure whether rubblelabs metadata.go needs a fix for delivered amount. Should this be deprecated in favor of Metadata in tx.go?

type TxMetaRaw

type TxMetaRaw struct {
	Tx        json.RawMessage `json:"tx"`
	Meta      json.RawMessage `json:"meta"`
	Validated *bool           `json:"validated"`
}

type TxParams

type TxParams struct {
	// hash
	Transaction string `json:"transaction"`
}

type TxResult

type TxResult struct {
	Result
	data.TxBase

	Ledger_index uint32 `json:"ledger_index,omitempty"` // account_tx returns this

	Meta      *MetaData // "tx" returns this.
	Validated *bool     // "tx" returns this.
	// contains filtered or unexported fields
}

func (*TxResult) IsValidated

func (tx *TxResult) IsValidated() bool

func (*TxResult) Json

func (tx *TxResult) Json() string

For verbose debug

func (*TxResult) Memo

func (tx *TxResult) Memo(i int) (string, bool)

Decodes a hex memo to string. Index i specificies which memo, starting with zero. Returns ok == false if there is no such memo.

func (TxResult) Payment

func (tx TxResult) Payment() (data.Payment, error)

func (*TxResult) Raw

func (tx *TxResult) Raw() []byte

func (*TxResult) String

func (result *TxResult) String() string

func (*TxResult) Succeeded

func (tx *TxResult) Succeeded() bool

func (*TxResult) UnmarshalJSON

func (tx *TxResult) UnmarshalJSON(data []byte) error

type TxResultNoRaw

type TxResultNoRaw TxResult // Same fields, without methods.  Use this when you don't want custom json unmarshalling.

type TxResultXXX

type TxResultXXX struct {
	Result
	Account         string
	Fee             uint64 `json:",string"`
	Sequence        uint32
	TransactionType string
	Hash            string `json:"hash"`
	Flags           *data.TransactionFlag

	Ledger_index uint32 `json:"ledger_index,omitempty"` // account_tx returns this

	Meta      *MetaData // "tx" returns this.
	Validated *bool     // "tx" returns this.
	// contains filtered or unexported fields
}

type ValidatedLedger

type ValidatedLedger struct {
	Base_fee_xrp     float64 // ???
	Hash             string
	Reserve_base_xrp int
	Reserve_inc_xrp  int
	Seq              int
}

Jump to

Keyboard shortcuts

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