xrp

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: MIT Imports: 6 Imported by: 0

README

go-xrp

Travis Go Report Card GoDoc codecov GitHub version

The missing XRP Ledger API for Golang.

Installation

$ go get github.com/yuexcom/go-xrp

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

TODO

  • Realtime fetching ledgers and validated transactions
  • Submit transaction
  • Scan block with filters
  • Socket error handling
  • Generic command
  • [ ]

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//TestNetURL todo..
	TestNetURL = "s.altnet.rippletest.net:51233"
	//MainNetURL todo..
	MainNetURL = "s2.ripple.com:443"
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Options
	Response chan *Response
	Ledger   chan *Ledger
	// contains filtered or unexported fields
}

Client main node client

func Dial

func Dial(host string, tls bool) (c Client, err error)

Dial Dial WSS protocol

func (*Client) GetClosedLedger

func (c *Client) GetClosedLedger() (ledger *Ledger, err error)

GetClosedLedger returns get last closed ledger

func (*Client) GetLedger

func (c *Client) GetLedger(cmdLedger *CommandLedger) (ledger *Ledger, err error)

GetLedger returns ledger by hash

func (*Client) GetLedgers

func (c *Client) GetLedgers(cls *CommandLedgerStream) (ledger <-chan *Ledger, err error)

GetLedgers get validated ledgers from network

func (*Client) GetTransaction

func (c *Client) GetTransaction(hash string) (ledger *Ledger, err error)

GetTransaction returns tx by hash

func (*Client) Ping

func (c *Client) Ping() (err error)

Ping ping XRP server

func (*Client) SendCommand

func (c *Client) SendCommand(cmd []byte) (err error)

SendCommand send ws command

func (*Client) SubmitTransaction

func (c *Client) SubmitTransaction(tx *TxOptions) (rsp *TxResult, err error)

CreateTransaction todo..

type Command

type Command struct {
	Command string `json:"command,omitempty"`
	ID      int    `json:"id,omitempty"`

	*CommandTX
	*CommandGetTX
	*CommandLedger
	*CommandLedgerStream
}

Command ..

type CommandGetTX

type CommandGetTX struct {
	Hash   string `json:"transaction,omitempty"`
	Binary bool   `json:"binary,omitempty"`
}

type CommandLedger

type CommandLedger struct {
	LedgerHash  string `json:"ledger_hash,omitempty"`
	LedgerIndex string `json:"ledger_index,omitempty"`
	Full        bool   `json:"full,omitempty"`
	Accounts    bool   `json:"accounts,omitempty"`
	Expand      bool   `json:"expand,omitempty"`
	OwnerFunds  bool   `json:"owner_funds,omitempty"`
	Queue       bool   `json:"queue,omitempty"`
	Binary      bool   `json:"binary,omitempty"`
}

type CommandLedgerStream

type CommandLedgerStream struct {
	Streams      []string `json:"streams,omitempty"`
	LedgerIndex  string   `json:"ledger_index,omitempty"`
	Full         bool     `json:"full,omitempty"`
	Accounts     bool     `json:"accounts,omitempty"`
	Transactions bool     `json:"transactions,omitempty"`
	Expand       bool     `json:"expand,omitempty"`
	OwnerFunds   bool     `json:"owner_funds,omitempty"`
}

type CommandTX

type CommandTX struct {
	Seed       string     `json:"seed,omitempty"`
	SeedHex    string     `json:"seed_hex,omitempty"`
	Passphrase string     `json:"passphrase,omitempty"`
	TxJSON     *TxOptions `json:"tx_json"`
	Secret     string     `json:"secret,omitempty"`
	Offline    bool       `json:"offline,omitempty"`
	FeeMultMax int32      `json:"fee_mult_max,omitempty"`
}

type Error

type Error struct {
	Error        string `json:"error,omitempty"`
	ErrorCode    int    `json:"error_code,omitempty"`
	ErrorMessage string `json:"error_message,omitempty"`
}

type Info

type Info struct {
	BuildVersion string `json:"build_version"`
	HostID       string
	Peers        int
}

Info todo..

type Ledger

type Ledger struct {
	FeeBase          int    `json:"fee_base,omitempty"`
	FeeRef           int    `json:"fee_ref,omitempty"`
	LedgerHash       string `json:"ledger_hash,omitempty"`
	LedgerIndex      uint64 `json:"ledger_index,omitempty"`
	LedgerTime       int    `json:"ledger_time,omitempty"`
	ReserveBase      int    `json:"reserve_base,omitempty"`
	ReserveInc       int    `json:"reserve_inc,omitempty"`
	TxnCount         int    `json:"txn_count,omitempty"`
	Type             string `json:"type,omitempty"`
	ValidatedLedgers string `json:"validated_ledgers,omitempty"`
	Transactions     []Transaction
}

Ledger todo..

type Options

type Options struct {
	URL string
}

Options todo..

type Request

type Request struct {
	Account     string `json:"account,omitempty"`
	Command     string `json:"command,omitempty"`
	ID          int    `json:"id,omitempty"`
	LedgerIndex string `json:"ledger_index,omitempty"`
	Strict      bool   `json:"strict,omitempty"`
}

Request todo..

type Response

type Response struct {
	ID     int    `json:"id,omitempty"`
	Status string `json:"status,omitempty"`
	Type   string `json:"type,omitempty"`

	*Error
	*Request `json:"request,omitempty"`
	*Result  `json:"result,omitempty"`

	// pure tx subs
	EngineResult        string `json:"engine_result,omitempty"`
	EngineResultCode    int    `json:"engine_result_code,omitempty"`
	LedgerCurrentIndex  uint64 `json:"ledger_current_index,omitempty"`
	EngineResultMessage string `json:"engine_result_message,omitempty"`
	LedgerHash          string `json:"ledger_hash,omitempty"`
	LedgerIndex         uint64 `json:"ledger_index,omitempty"`

	Transaction Transaction `json:"transaction,omitempty"`
	Validated   bool        `json:"validated,omitempty"`
	Ledger
}

Response todo..

type Result

type Result struct {
	*Ledger
	*Info
	*TxResult
}

Result todo..

type Transaction

type Transaction struct {
	Account            string `json:"Account"`
	Expiration         int64  `json:"Expiration"`
	Fee                string `json:"Fee"`
	Flags              int64  `json:"Flags"`
	LastLedgerSequence int64  `json:"LastLedgerSequence"`
	OfferSequence      int64  `json:"OfferSequence"`
	Sequence           int64  `json:"Sequence"`
	SigningPubKey      string `json:"SigningPubKey"`
	DestinationTag     uint32 `json:"DestinationTag"`
	TransactionType    string `json:"TransactionType"`
	TxnSignature       string `json:"TxnSignature"`
	Date               int64  `json:"date"`
	Hash               string `json:"hash"`
	OwnerFunds         string `json:"owner_funds"`
}

Transaction todo..

type TxJSON

type TxJSON struct {
	Account         string `json:"Account,omitempty"`
	Amount          string `json:"Amount,omitempty"`
	Destination     string `json:"Destination,omitempty"`
	DestinationTag  int    `json:"DestinationTag,omitempty"`
	Fee             string `json:"Fee,omitempty"`
	Flags           int64  `json:"Flags,omitempty"`
	Sequence        int    `json:"Sequence,omitempty"`
	SigningPubKey   string `json:"SigningPubKey,omitempty"`
	TransactionType string `json:"TransactionType,omitempty"`
	TxnSignature    string `json:"TxnSignature,omitempty"`
	Hash            string `json:"hash,omitempty"`
}

type TxOptions

type TxOptions struct {
	TransactionType string `json:"TransactionType"`
	Account         string `json:"Account"`
	Destination     string `json:"Destination"`
	DestinationTag  uint32 `json:"DestinationTag"`
	Amount          string `json:"Amount"`
	Secret          string `json:"-"`
	Offline         bool   `json:"-"`
	FeeMultMax      int32  `json:"-"`
}

type TxResult

type TxResult struct {
	EngineResult        string `json:"engine_result,omitempty"`
	EngineResultCode    int    `json:"engine_result_code,omitempty"`
	EngineResultMessage string `json:"engine_result_message,omitempty"`

	TxBlob  string `json:"tx_blob,omitempty"`
	*TxJSON `json:"tx_json,omitempty"`
}

Jump to

Keyboard shortcuts

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