rippleapi

package
v0.0.0-...-485d38d Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const AsfAccountTxnID = 5
View Source
const AsfDefaultRipple = 8
View Source
const AsfDisableMaster = 4
View Source
const AsfDisallowXRP = 3
View Source
const AsfGlobalFreeze = 7
View Source
const AsfNoFreeze = 6
View Source
const AsfRequireAuth = 2
View Source
const AsfRequireDest = 1

Account set flags

View Source
const LsfDefaultRipple = 8388608

AccountRoot Flags

View Source
const TfClearFreeze = 2097152
View Source
const TfClearNoRipple = 262144
View Source
const TfSetFreeze = 1048576
View Source
const TfSetNoRipple = 131072
View Source
const TfSetfAuth = 65536

Trust set flags (on the transaction)

Variables

View Source
var BaseReserve = 20000000
View Source
var DefaultAmountToTrust uint64 = 100000000000000000
View Source
var DefaultFee = "10000"
View Source
var DefaultFeeI uint64 = 10000
View Source
var OwnerReserve = 5000000
View Source
var RippleWallets []MasterWallet

Functions

func AccountSetFlag

func AccountSetFlag(c context.Context, account string, flag uint32, secret string) (string, int64, error)

Sets a specific flag on an account

func AmountToUint64

func AmountToUint64(amount string) (uint64, error)

Converts a Ripple amount which is stored in a string into a Uint64 whose factor is in satoshis Uses big.Float and big.Int to stop overflows and maintain precision

func CalculateFeeAmount

func CalculateFeeAmount(c context.Context, amount uint64) (uint64, string, error)

Returns the total XRP that is required for the given number of transactions

func CalculateNumberOfTransactions

func CalculateNumberOfTransactions(c context.Context, amount uint64) (uint64, error)

Returns the number of transactions that can be performed with the given amount of XRP

func CalculateReserve

func CalculateReserve(c context.Context, accountLines uint64) uint64

Calculates the reserve based upon the current reserve and number of account lines Returns in 'drops' the amount of XRP required

func CreatePayment

func CreatePayment(c context.Context, account string, destination string, quantity string, currency string, issuer string, secret string) (string, int64, error)

Creates and signs the payment for the custom currency that is specified. If XRP is specified, then the amount MUST be specifed in droplets Returns the tx string if successful

func FromCurrency

func FromCurrency(currency string) (string, error)

Converts a ripple currency to a normal string Where the currency is 3 characters, it is returned as is Where the currency is a 160 bit hex encoded string, it is converted to the ascii representation

func Init

func Init()

func InitWithConfigPath

func InitWithConfigPath(configFilePath string)

func ServerInfo

func ServerInfo(c context.Context) ([]byte, int64, error)

func Sign

func Sign(c context.Context, tx interface{}, secret string) (string, int64, error)

Signs a tx with the given secret. The tx should be a struct containing the tx to be marshalled into JSON and then signed

func Submit

func Submit(c context.Context, txHexString string) (string, int64, error)

Submits a transaction to the Ripple network

func ToCurrency

func ToCurrency(asset string) (string, error)

Truncate to 19 characters and convert to a hex string equivalent. Prepend hex 80 to indicate a custom currency

func TrustSet

func TrustSet(c context.Context, account string, currency string, value string, issuerAccount string, flag uint32, secret string) (string, int64, error)

Modifies a trust line between two accounts The trust line is directional - the given account trusts the issuer account for value amount of currency A trust line occupies space in the Ripple ledger and therefore requires a fee to be paid and consequently the secret of the source account

func Uint64ToAmount

func Uint64ToAmount(amount uint64) (string, error)

Converts a Uint64 into a Ripple amount which is stored in a string

func ValidCurrencyName

func ValidCurrencyName(currency string) (bool, error)

We allow currency names up to 19 characters long

Types

type AccountInfo

type AccountInfo struct {
	Account         string `json:",omitempty"`
	Balance         string `json:",omitempty"`
	Flags           uint32 `json:",omitempty"`
	LedgerEntryType string `json:",omitempty"`
	OwnerCount      int    `json:",omitempty"`
	PreviousTxnID   string `json:",omitempty"`
	Sequence        int    `json:",omitempty"`
	Index           string `json:"index,omitempty"`
}

func GetAccountInfo

func GetAccountInfo(c context.Context, account string) (AccountInfo, int64, error)

type AccountSet

type AccountSet struct {
	// Common fields
	Account            string `json:",omitempty"`
	AccountTxnID       string `json:",omitempty"`
	Fee                string `json:",omitempty"`
	Flags              uint32 `json:",omitempty"`
	LastLedgerSequence uint32 `json:",omitempty"`
	Memos              []Memo
	Sequence           uint32 `json:",omitempty"`
	SigningPubKey      string `json:",omitempty"`
	SourceTag          uint32 `json:",omitempty"`
	TransactionType    string `json:",omitempty"`
	TxnSignature       string `json:",omitempty"`

	ClearFlag    uint32 `json:",omitempty"`
	Domain       string `json:",omitempty"`
	EmailHash    string `json:",omitempty"`
	MessageKey   string `json:",omitempty"`
	SetFlag      uint32 `json:",omitempty"`
	TransferRate uint32 `json:",omitempty"`
}

type Amount

type Amount struct {
	Value    string `json:"value,omitempty"`
	Currency string `json:"currency,omitempty"`
	Issuer   string `json:"issuer,omitempty"`
}

type ApiResult

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

type Balance

type Balance struct {
	Value        string `json:"value"`
	Currency     string `json:"currency"`
	Counterparty string `json:"counterparty"`
}

func GetAccountBalances

func GetAccountBalances(c context.Context, account string) ([]Balance, int64, error)

Returns the balances, including xrp held by the account Assumes that all custom currencies ripple via a central issuing address. ie it doesn't sum balances of the same currency against different trust lines

type CcyByAccountResult

type CcyByAccountResult struct {
	Ledger_hash       string   `json:"ledger_hash"`
	Ledger_index      int64    `json:"ledger_index"`
	ReceiveCurrencies []string `json:"receive_currencies"`
	SendCurrencies    []string `json:"send_currencies"`
	Status            string   `json:"status"`
	Validated         bool     `json:"validated"`
}

type CurrenciesByAccount

type CurrenciesByAccount struct {
	Result CcyByAccountResult `json:"result"`
}

func GetCurrenciesByAccount

func GetCurrenciesByAccount(c context.Context, account string) (CurrenciesByAccount, int64, error)

type Currency

type Currency struct {
	Currency string `json:"currency"`
}

type Ledger

type Ledger struct {
	Ledger LedgerValue `json:"ledger,omitempty"`
}

type LedgerResult

type LedgerResult struct {
	Closed Ledger `json:"closed,omitempty"`
	Open   Ledger `json:"open,omitempty"`
}

type LedgerValue

type LedgerValue struct {
	Accepted bool `json:"accepted,omitempty"`
	//Accepted2	string
	AccountHash         string `json:"account_hash,omitempty"`
	CloseFlags          uint32 `json:"close_flags,omitempty"`
	CloseTime           uint32 `json:"close_time,omitempty"`
	CloseTimeHuman      string `json:"close_time_human,omitempty"`
	CloseTimeResolution uint32 `json:"close_time_resolution,omitempty"`
	Closed              bool   `json:"closed,omitempty"`
	LedgerHash          string `json:"ledger_hash,omitempty"`
	LedgerIndex         string `json:"ledger_index,omitempty"`
	ParentCloseTime     uint32 `json:"parent_close_time,omitempty"`
	ParentHash          string `json:"parent_hash,omitempty"`
	SeqNum              string `json:"seqNum,omitempty"`
	TotalCoins1         string `json:"totalCoins,omitempty"`
	TotalCoins2         string `json:"total_coins,omitempty"`
	TransactionHash     string `json:"transaction_hash,omitempty"`
}

func GetLatestValidatedLedger

func GetLatestValidatedLedger(c context.Context) (LedgerValue, int64, error)

type LimitAmount

type LimitAmount struct {
	Value    string `json:"value,omitempty"`
	Currency string `json:"currency,omitempty"`
	Issuer   string `json:"issuer,omitempty"`
}

type Line

type Line struct {
	Account      string `json:"account,omitempty"`
	Balance      string `json:"balance,omitempty"`
	Currency     string `json:"currency,omitempty"`
	Limit        string `json:"limit,omitempty"`
	LimitPeer    string `json:"limit_peer,omitempty"`
	NoRipple     bool   `json:"no_ripple,omitempty"`
	NoRipplePeer bool   `json:"no_ripple_peer,omitempty"`
	QualityIn    uint   `json:"quality_in,omitempty"`
	QualityOut   uint   `json:"quality_out,omitempty"`
}

type Lines

type Lines []Line

func GetAccountLines

func GetAccountLines(c context.Context, account string) (Lines, int64, error)

Gets the trust lines for a given account

func (Lines) Contains

func (s Lines) Contains(account string, currency string) bool

func (Lines) Len

func (s Lines) Len() int

type MasterWallet

type MasterWallet struct {
	Address    string `json:"address"`
	Passphrase string `json:"passphrase"`
}

Used to store the internal wallets

type Memo

type Memo struct {
	MemoData   string `json:",omitempty"`
	MemoFormat string `json:",omitempty"`
	MemoType   string `json:",omitempty"`
}

type PayloadGetCcyByAcct

type PayloadGetCcyByAcct struct {
	Account       string `json:"account"`
	Account_index int64  `json:"account_index"`
	Ledger_index  string `json:"ledger_index"`
	Strict        bool   `json:"strict"`
}

type PaymentAssetTx

type PaymentAssetTx struct {
	// Common fields
	Account            string `json:",omitempty"`
	AccountTxnID       string `json:",omitempty"`
	Fee                string `json:",omitempty"`
	Flags              uint32 `json:",omitempty"`
	LastLedgerSequence uint64 `json:",omitempty"`
	Memos              []Memo
	Sequence           uint32 `json:",omitempty"`
	SigningPubKey      string `json:",omitempty"`
	SourceTag          uint32 `json:",omitempty"`
	TransactionType    string `json:",omitempty"`
	TxnSignature       string `json:",omitempty"`

	// Payment specific fields
	Amount         Amount // Note the Amount field is different between sending XRP or a custom currency
	SendMax        Amount
	Destination    string
	DestinationTag uint32
	InvoiceID      string
}

Structure for payment transactions for custom currencies

type PaymentXrpTx

type PaymentXrpTx struct {
	// Common fields
	Account            string `json:",omitempty"`
	AccountTxnID       string `json:",omitempty"`
	Fee                string `json:",omitempty"`
	Flags              uint32 `json:",omitempty"`
	LastLedgerSequence uint64 `json:",omitempty"`
	Memos              []Memo
	Sequence           uint32 `json:",omitempty"`
	SigningPubKey      string `json:",omitempty"`
	SourceTag          uint32 `json:",omitempty"`
	TransactionType    string `json:",omitempty"`
	TxnSignature       string `json:",omitempty"`

	// Payment specific fields
	Amount         string `json:",omitempty"`
	Destination    string `json:",omitempty"`
	DestinationTag uint32 `json:",omitempty"`
	InvoiceID      string `json:",omitempty"`
}

Structure for payment transactions for xrp

type Transaction

type Transaction struct {
	Account     string `json:",omitempty"`
	Hash        string `json:"hash,omitempty"`
	LedgerIndex uint64 `json:"ledger_index,omitempty"`
	Validated   bool   `json:"validated,omitempty"`
}

func GetTx

func GetTx(c context.Context, txhash string) (Transaction, int64, error)

GetTx gets the status of a TX in the RCL. Note this doesn't seem to return anything useful if the TX was just submitted but not yet accepted

type TrustSetStruct

type TrustSetStruct struct {
	// Common fields
	Account            string `json:",omitempty"`
	AccountTxnID       string `json:",omitempty"`
	Fee                string `json:",omitempty"`
	Flags              uint32 `json:",omitempty"`
	LastLedgerSequence uint32 `json:",omitempty"`
	Memos              []Memo `json:",omitempty"`
	Sequence           uint32 `json:",omitempty"`
	SigningPubKey      string `json:",omitempty"`
	SourceTag          uint32 `json:",omitempty"`
	TransactionType    string `json:",omitempty"`
	TxnSignature       string `json:",omitempty"`

	LimitAmount LimitAmount `json:",omitempty"`
	QualityIn   uint32      `json:",omitempty"`
	QualityOut  uint32      `json:",omitempty"`
}

type Wallet

type Wallet struct {
	AccountId     string `json:"account_id"`
	KeyType       string `json:"key_type"`
	MasterKey     string `json:"master_key"`
	MasterSeed    string `json:"master_seed"`
	MasterSeedHex string `json:"master_seed_hex"`
	PublicKey     string `json:"public_key"`
	PublicKeyHex  string `json:"public_key_hex"`
	Status        string `json:"status"`
}

func CreateWallet

func CreateWallet(c context.Context) (Wallet, int64, error)

Creates a Ripple account offline. ie doesn't use the REST or RPC

Jump to

Keyboard shortcuts

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