rippledata

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccountData

type AccountData struct {
	Account        data.Account
	Parent         data.Account
	InitialBalance data.NonNativeValue `json:"initial_balance,string"` // TODO what type to use here?? (data.Value interprets "200" as drops, not XRP)
	LedgerIndex    uint32              `json:"ledger_index"`
	Inception      time.Time
	TxHash         data.Hash256 `json:"tx_hash"`
}

{"result":"success","account_data":{"account":"rDCh8v8g2g7eGEkXWLMz2gRPe2TLbwoocB","parent":"rDsbeomae4FXwgQTJp9Rs64Qg9vDiTCdBv","initial_balance":"200","inception":"2018-04-03T17:52:20Z","ledger_index":37698948,"tx_hash":"410EFBD059677888DBF87C73253B9F97A4CD47C64A535249FA782D0CD6F603B6"}}

type AccountExchangesResponse

type AccountExchangesResponse struct {
	Response
	Count     int    `json:"count"`
	Marker    string `json:"marker"`
	Exchanges []Exchange
}

type AccountPaymentsResponse

type AccountPaymentsResponse struct {
	Response
	Count    int    `json:"count"`
	Marker   string `json:"marker"`
	Payments []Payment
}

type AccountResponse

type AccountResponse struct {
	Response
	AccountData AccountData `json:"account_data"`
}

type BalanceChangeDescriptor

type BalanceChangeDescriptor struct {
	TransactionResponse

	AmountChange data.NonNativeValue `json:"amount_change"`
	FinalBalance data.NonNativeValue `json:"final_balance"`
	ChangeType   string              `json:"change_type"`
	Currency     string              `json:"currency"`
	Counterparty data.Account        `json:"counterparty"`

	TxIndex uint32 `json:"tx_index"`
}

https://ripple.com/build/data-api-v2/#balance-change-descriptors

func (BalanceChangeDescriptor) GetChangeAmount

func (change BalanceChangeDescriptor) GetChangeAmount() *data.Amount

func (BalanceChangeDescriptor) GetFinalAmount

func (change BalanceChangeDescriptor) GetFinalAmount() *data.Amount

func (BalanceChangeDescriptor) GetTransactionIndex

func (change BalanceChangeDescriptor) GetTransactionIndex() uint32

type BalanceChangeObject

type BalanceChangeObject struct {
	Counterparty string              `json:"counterparty"` // string not data.Account, because data api will return "counterparty": "" when "currency": "XRP"
	Currency     string              `json:"currency"`
	Value        data.NonNativeValue `json:"value"`
}

https://ripple.com/build/data-api-v2/#balance-objects-and-balance-change-objects

func (BalanceChangeObject) GetAmount

func (this BalanceChangeObject) GetAmount() *data.Amount

type BalanceChangesResponse

type BalanceChangesResponse struct {
	Response
	Count          int                       `json:"count"`
	Marker         string                    `json:"marker"`
	BalanceChanges []BalanceChangeDescriptor `json:"balance_changes"`
}

type Client

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

func NewClient

func NewClient(base string) (Client, error)

func (Client) AccountData

func (this Client) AccountData(account data.Account) (response *AccountResponse, err error)

func (Client) Close

func (client Client) Close()

func (Client) Endpoint

func (this Client) Endpoint(segment ...string) *url.URL

Produces a url for an endpoint. panics on error in order to allow inline calling.

func (Client) Get

func (this Client) Get(response DataResponse, endpoint *url.URL, values *url.Values) error

Get method submits a query to the Ripple Data API and returns response. If a request fails, Get retries, possibly several times.

func (Client) GetAccountExchanges

func (this Client) GetAccountExchanges(account data.Account, marker string) (response *AccountExchangesResponse, err error)

func (Client) GetAccountExchangesAsync

func (this Client) GetAccountExchangesAsync(account data.Account) chan Exchange

func (Client) GetAccountPayments

func (this Client) GetAccountPayments(account data.Account, marker string) (response *AccountPaymentsResponse, err error)

func (Client) GetAccountPaymentsAsync

func (this Client) GetAccountPaymentsAsync(account data.Account) chan Payment

func (Client) GetBalanceChanges

func (this Client) GetBalanceChanges(account data.Account, marker string) (response *BalanceChangesResponse, err error)

func (Client) GetBalanceChangesAsync

func (this Client) GetBalanceChangesAsync(account data.Account) chan BalanceChangeDescriptor

func (Client) Normalize

func (this Client) Normalize(amount data.Amount, normalizeTo data.Asset, when time.Time) (*NormalizeResponse, error)

func (Client) Transaction

func (this Client) Transaction(hash data.Hash256) (*GetTransactionResponse, error)

type DataResponse

type DataResponse interface {
	GetResult() string
	GetMessage() string
	// contains filtered or unexported methods
}

type Exchange

type Exchange struct {
	TransactionResponse

	BaseAmount      data.NonNativeValue `json:"base_amount"`
	BaseCurrency    string              `json:"base_currency"`
	BaseIssuer      string              `json:"base_issuer"`
	CounterAmount   data.NonNativeValue `json:"counter_amount"`
	CounterCurrency string              `json:"counter_currency"`
	CounterIssuer   string              `json:"counter_issuer"`
	Rate            data.NonNativeValue `json:"rate"`

	Buyer         data.Account `json:"buyer"`
	Seller        data.Account `json:"seller"`
	Provider      data.Account `json:"provider"`
	Taker         data.Account `json:"taker"`
	OfferSequence uint32       `json:"offer_sequence"`
}

https://ripple.com/build/data-api-v2/#exchange-objects

func (Exchange) GetBaseAmount

func (this Exchange) GetBaseAmount() *data.Amount

func (Exchange) GetCounterAmount

func (this Exchange) GetCounterAmount() *data.Amount

type GetTransactionResponse

type GetTransactionResponse struct {
	Response
	Transaction struct {
		LedgerIndex uint32       `json:"ledger_index"`
		Date        time.Time    `json:"date"`
		Hash        data.Hash256 `json:"hash"`

		// Tx field is data.TransactionWithMetaData (instead of
		// data.TxBase) because TransactionWithMetaData knows how to
		// unmarshal many types of transaction from JSON.
		Tx   data.TransactionWithMetaData `json:"tx"`   // json from Data API actually doesn't have metadata :(
		Meta data.MetaData                `json:"meta"` // see postop(), we copy this into Tx

	} `json:"transaction"`
}

type NormalizeResponse

type NormalizeResponse struct {
	Response
	Amount    data.NonNativeValue `json:"amount"`
	Converted data.NonNativeValue `json:"converted"`
	Rate      data.NonNativeValue `json:"rate"`
}
 {
  "result": "success",
  "amount": "100",
  "converted": "0.4267798022744489",
  "rate": "0.0042677980"
}

type Payment

type Payment struct {
	TransactionResponse

	DeliveredAmount           data.NonNativeValue   `json:"delivered_amount"`
	Destination               data.Account          `json:"destination"`
	DestinationTag            *int                  `json:"destination_tag,omitempty"`
	DestinationCurrency       string                `json:"currency"`
	DestinationBalanceChanges []BalanceChangeObject `json:"destination_balance_changes"`
	Source                    data.Account          `json:"source"`
	SourceTag                 *int                  `json:"source_tag,omitempty"`
	SourceCurrency            string                `json:"source_currency"`
	SourceBalanceChanges      []BalanceChangeObject `json:"source_balance_changes"`
}

https://ripple.com/build/data-api-v2/#payment-objects

type Response

type Response struct {
	Result  string `json:"result"`            // "success" expected
	Message string `json:"message,omitempty"` // present when  "result": "error"
	// contains filtered or unexported fields
}

Response is a generic response to a Data API request.

func (*Response) GetMessage

func (this *Response) GetMessage() string

func (*Response) GetResult

func (this *Response) GetResult() string

type Transaction

type Transaction interface {
	GetHash() data.Hash256
	GetLedgerIndex() uint32
	GetTransactionIndex() uint32 // balance_changes returns this, but exchanges and payments do not!
	GetExecutedTime() time.Time
}

type TransactionFIFO

type TransactionFIFO transactionHeap

func NewTransactionFIFO

func NewTransactionFIFO() *TransactionFIFO

func (TransactionFIFO) Len

func (this TransactionFIFO) Len() int

func (TransactionFIFO) Less

func (this TransactionFIFO) Less(i, j int) bool

Less determines whether heap is LIFO or FIFO. Pay attention to less than.

func (*TransactionFIFO) Pop

func (this *TransactionFIFO) Pop() interface{}

func (*TransactionFIFO) Push

func (this *TransactionFIFO) Push(x interface{})

Push and Pop use pointer receivers because they modify slice's length

func (TransactionFIFO) Swap

func (this TransactionFIFO) Swap(i, j int)

type TransactionLIFO

type TransactionLIFO transactionHeap

func NewTransactionLIFO

func NewTransactionLIFO() *TransactionLIFO

func (TransactionLIFO) Len

func (this TransactionLIFO) Len() int

func (TransactionLIFO) Less

func (this TransactionLIFO) Less(i, j int) bool

Less determines whether heap is LIFO or FIFO

func (*TransactionLIFO) Pop

func (this *TransactionLIFO) Pop() interface{}

func (*TransactionLIFO) Push

func (this *TransactionLIFO) Push(x interface{})

Push and Pop use pointer receivers because they modify slice's length

func (TransactionLIFO) Swap

func (this TransactionLIFO) Swap(i, j int)

type TransactionResponse

type TransactionResponse struct {
	TxHash       data.Hash256 `json:"tx_hash"`
	LedgerIndex  uint32       `json:"ledger_index"`
	ExecutedTime time.Time    `json:"executed_time"`
}

Common fields in data responses that identify transactions. I.e. payments, exchanges and balance changes

func (TransactionResponse) GetExecutedTime

func (this TransactionResponse) GetExecutedTime() time.Time

func (TransactionResponse) GetHash

func (this TransactionResponse) GetHash() data.Hash256

func (TransactionResponse) GetLedgerIndex

func (this TransactionResponse) GetLedgerIndex() uint32

func (TransactionResponse) GetTransactionIndex

func (this TransactionResponse) GetTransactionIndex() uint32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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