Documentation
¶
Overview ¶
Package data aims to provides all the data types that are needed to build tools, clients and servers for use on the Ripple network.
Ledger ¶
The ledger is a mixture of various data types, all persisted in the form of a key and value. The value contains a node, and some nodes refer to other nodes by their index. An index may or may not be equivalent to a node's key. A ledger consists of a LedgerHeader as the root of two trees, one for the transactions in that ledger and one for the state of all accounts at that point in time.
A ledger refers to its predecessor, which has a completely different tree for its transactions, but the account state tree will share most of its nodes with its successors and predecessors.
The full ledger consists of a sequence of such ledgers, each referring to, and dependent on its predecessor.
Important terms are key, value, index, hash and node. Keys, indexes and hashes are always 32 bytes in length and involve the use of the SHA512 cryptographic hash algorithm, discarding the last 32 bytes of the resulting hash. Sometimes they are the same thing, sometimes not.
LedgerHeader ¶
This is the root of the two trees for a single ledger. It contains information about the ledger and its predecessor. A ledger header node is never reused between ledgers.
Node: Simple big-endian binary encoding of LedgerHeader Index: SHA512Half of HP_LEDGER_MASTER:Node Hash: Same as Index Key: Index Value: LedgerSequence:LedgerSequence:NT_LEDGER:HP_LEDGER_MASTER:Node
Inner Node ¶
This is a node in either the transaction or account state tree which contains up to 16 hashes of other nodes. The position of the hash represents a 4 bit nibble of the index that is being searched for in the tree. An account state inner node may be reused between ledgers, a transaction inner node will never be reused.
Node: Simple big-endian binary encoding of 16 x 32 byte hashes Index: SHA512Half of HP_INNER_NODE:Node Hash: Same as Index Key: Index Value: LedgerSequence:LedgerSequence:NT_ACCOUNT_NODE or NT_TRANSACTION_NODE:HP_INNER_NODE:Node
TransactionWithMetadata Node ¶
This contains a Transaction with Metadata describing how the LedgerEntry nodes were altered. It has the most complex structure of all nodes. A TransactionWithMetadata node is never reused between ledgers. VL is a variable length marker.
Node: Complex encoding of Transaction Index: SHA512Half of HP_TRANSACTION_ID:Node Hash: SHA512Half of HP_TRANSACTION_NODE:VL:Node:VL:Metadata:Index Key: Hash Value: LedgerSequence:LedgerSequence:NT_TRANSACTION_NODE:HP_TRANSACTION_NODE:VL:Node:VL:Metadata:Index
LedgerEntry Node ¶
This contains the state of an account after a transaction has been applied. Ledger Entry nodes may be reused between ledgers.
Node: Complex encoding of LedgerEntry Index: SHA512Half of namespace and a type-specific rule Hash: SHA512Half of HP_LEAF_NODE:Node:Index Key: Hash Value: LedgerSequence:LedgerSequence:NT_ACCOUNT_NODE:HP_LEAF_NODE:Node:Index
Index ¶
- Constants
- Variables
- func CheckSignature(h Hashable) (bool, error)
- func GetLedgerEntryFactoryByType(leType string) func() LedgerEntry
- func GetTxFactoryByType(txType string) func() Transaction
- func Sign(key crypto.Key, tx Transaction) error
- func UnmarshalTransactionWithMetadata(b []byte, txm *TransactionWithMetaData) error
- type Account
- func (a *Account) Bytes() []byte
- func (a Account) Equals(b Account) bool
- func (a Account) Hash() (crypto.Hash, error)
- func (a Account) Hash256() Hash256
- func (a Account) IsZero() bool
- func (a Account) Less(b Account) bool
- func (a *Account) Marshal(w io.Writer) error
- func (a Account) MarshalText() ([]byte, error)
- func (a Account) String() string
- func (a *Account) Unmarshal(r Reader) error
- func (a *Account) UnmarshalText(b []byte) error
- type AccountRoot
- type AccountRootFields
- type AccountSet
- type AffectedNode
- type Amendment
- type Amendments
- type AmendmentsFields
- type Amount
- func (a Amount) Abs() *Amount
- func (a Amount) Add(b *Amount) (*Amount, error)
- func (a Amount) ApplyInterest() (*Amount, error)
- func (a *Amount) Bytes() []byte
- func (a Amount) Clone() *Amount
- func (a Amount) Divide(b *Amount) (*Amount, error)
- func (a Amount) Equals(b Amount) bool
- func (a Amount) IsPositive() bool
- func (a Amount) Machine() string
- func (a *Amount) Marshal(w io.Writer) error
- func (a Amount) MarshalJSON() ([]byte, error)
- func (a Amount) Multiply(b *Amount) (*Amount, error)
- func (a Amount) Negate() *Amount
- func (a Amount) SameValue(b *Amount) bool
- func (a Amount) String() string
- func (a Amount) Subtract(b *Amount) (*Amount, error)
- func (a *Amount) Unmarshal(r Reader) error
- func (a *Amount) UnmarshalJSON(b []byte) (err error)
- func (a Amount) ZeroClone() *Amount
- type Balance
- type BalanceSlice
- type CompressedNodeEntry
- type Currency
- func (c *Currency) Bytes() []byte
- func (c Currency) Clone() Currency
- func (c Currency) Equals(other Currency) bool
- func (c Currency) IsNative() bool
- func (a Currency) Less(b Currency) bool
- func (c Currency) Machine() string
- func (c *Currency) Marshal(w io.Writer) error
- func (c Currency) MarshalText() ([]byte, error)
- func (c Currency) Rate(seconds uint32) float64
- func (c Currency) String() string
- func (c Currency) Type() CurrencyType
- func (c *Currency) Unmarshal(r Reader) error
- func (c *Currency) UnmarshalText(text []byte) error
- type CurrencyType
- type Decoder
- func (dec *Decoder) CompressedInnerNode(typ NodeType) (*InnerNode, error)
- func (dec *Decoder) Hash() (*Hash256, error)
- func (dec *Decoder) HashPrefix() (HashPrefix, error)
- func (dec *Decoder) Header() (*NodeHeader, error)
- func (dec *Decoder) InnerNode(typ NodeType) (*InnerNode, error)
- func (dec *Decoder) Ledger() (*Ledger, error)
- func (dec *Decoder) LedgerEntry() (LedgerEntry, error)
- func (dec *Decoder) Prefix() (Hashable, error)
- func (dec *Decoder) Transaction() (Transaction, error)
- func (dec *Decoder) TransactionWithMetadata() (*TransactionWithMetaData, error)
- func (dec *Decoder) Validation() (*Validation, error)
- func (dec *Decoder) Wire(typ NodeType) (Hashable, error)
- type Directory
- type DirectoryFields
- type Encoder
- func (enc *Encoder) HashPrefix(w io.Writer, h Hashable) error
- func (enc *Encoder) Hex(w io.Writer, h Hashable) error
- func (enc *Encoder) Ledger(w io.Writer, h Hashable) error
- func (enc *Encoder) Node(h Hashable) error
- func (enc *Encoder) NodeType(w io.Writer, h Hashable) error
- func (enc *Encoder) SigningHash(tx Transaction) ([]byte, error)
- func (enc *Encoder) Transaction(tx Transaction, ignoreSigningFields bool) error
- func (enc *Encoder) Validation(v *Validation, ignoreSigningFields bool) error
- type FeeSetting
- type FeeSettingFields
- type Hash128
- type Hash160
- type Hash256
- func GetAccountRootIndex(account Account) (*Hash256, error)
- func GetAmendmentsIndex() (*Hash256, error)
- func GetBookIndex(paysCurrency, getsCurrency Hash160, paysIssuer, getsIssuer Hash160) (*Hash256, error)
- func GetDirectoryNodeIndex(root Hash256, index *NodeIndex) (*Hash256, error)
- func GetFeeIndex() (*Hash256, error)
- func GetLedgerHashIndex() (*Hash256, error)
- func GetOfferIndex(account Account, sequence uint32) (*Hash256, error)
- func GetOwnerDirectoryIndex(account Account) (*Hash256, error)
- func GetPreviousLedgerHashIndex(sequence uint32) (*Hash256, error)
- func GetRippleStateIndex(a, b Account, c Currency) (*Hash256, error)
- func LedgerIndex(le LedgerEntry) (*Hash256, error)
- func NewHash256(value interface{}) (*Hash256, error)
- func (h Hash256) Bytes() []byte
- func (h Hash256) Compare(x Hash256) int
- func (h Hash256) IsZero() bool
- func (h *Hash256) Marshal(w io.Writer) error
- func (h Hash256) MarshalText() ([]byte, error)
- func (h Hash256) String() string
- func (h Hash256) TruncatedString(length int) string
- func (h *Hash256) Unmarshal(r Reader) error
- func (h *Hash256) UnmarshalText(b []byte) error
- func (h Hash256) Xor(x Hash256) Hash256
- type HashPrefix
- type Hashable
- type InnerNode
- type InnerNodeFunc
- type Ledger
- type LedgerEntry
- type LedgerEntryFlag
- type LedgerEntrySlice
- type LedgerEntryType
- type LedgerHashes
- type LedgerHashesFields
- type LedgerHeader
- type LedgerNamespace
- type LedgerRange
- type LedgerSet
- func (l *LedgerSet) Count() uint32
- func (l *LedgerSet) Extend(i uint32)
- func (l *LedgerSet) Max() uint32
- func (l *LedgerSet) Set(i uint32) time.Duration
- func (l *LedgerSet) String() string
- func (l *LedgerSet) TakeBottom(n uint32) LedgerSlice
- func (l *LedgerSet) TakeMiddle(r *LedgerRange) LedgerSlice
- func (l *LedgerSet) TakeTop(n uint32) LedgerSlice
- func (l *LedgerSet) Taken() uint32
- type LedgerSlice
- type LimitByteReader
- type Memo
- type Memos
- type MetaData
- type NodeEffect
- type NodeEffects
- type NodeFormat
- type NodeHeader
- type NodeIndex
- type NodeType
- type Offer
- type OfferCancel
- type OfferCreate
- type OfferFields
- type Path
- type PathEntry
- type Paths
- type Payment
- type Proposal
- type PublicKey
- type Query
- type Reader
- type RegularKey
- func (r *RegularKey) Bytes() []byte
- func (r RegularKey) Hash() (crypto.Hash, error)
- func (k *RegularKey) Marshal(w io.Writer) error
- func (r RegularKey) MarshalText() ([]byte, error)
- func (r RegularKey) String() string
- func (k *RegularKey) Unmarshal(r Reader) error
- func (r *RegularKey) UnmarshalText(b []byte) error
- type RippleHumanTime
- type RippleState
- type RippleStateFields
- type RippleTime
- func (t *RippleTime) Human() *RippleHumanTime
- func (t RippleTime) MarshalJSON() ([]byte, error)
- func (t *RippleTime) SetString(s string) error
- func (t *RippleTime) SetUint32(n uint32)
- func (t *RippleTime) Short() string
- func (t *RippleTime) String() string
- func (t *RippleTime) Uint32() uint32
- func (t *RippleTime) UnmarshalJSON(b []byte) error
- type SetFee
- type SetRegularKey
- type Trade
- type TradeSlice
- type Transaction
- type TransactionFlag
- type TransactionResult
- type TransactionSlice
- type TransactionType
- type TransactionWithMetaData
- func (txm *TransactionWithMetaData) Balances() (BalanceSlice, error)
- func (t *TransactionWithMetaData) GetAffectedNodes() []NodeEffect
- func (t *TransactionWithMetaData) GetType() string
- func (txm TransactionWithMetaData) MarshalJSON() ([]byte, error)
- func (txm *TransactionWithMetaData) Trades() (TradeSlice, error)
- func (txm *TransactionWithMetaData) UnmarshalJSON(b []byte) error
- type TrustSet
- type TxBase
- type Validation
- type Value
- func (v Value) Abs() *Value
- func (a Value) Add(b Value) (*Value, error)
- func (v *Value) Bytes() []byte
- func (v Value) Clone() *Value
- func (a Value) Compare(b Value) int
- func (num Value) Divide(den Value) (*Value, error)
- func (a Value) Equals(b Value) bool
- func (v Value) IsScientific() bool
- func (v Value) IsZero() bool
- func (a Value) Less(b Value) bool
- func (v *Value) Marshal(w io.Writer) error
- func (v *Value) MarshalText() ([]byte, error)
- func (a Value) Multiply(b Value) (*Value, error)
- func (v Value) Negate() *Value
- func (v Value) String() string
- func (a Value) Subtract(b Value) (*Value, error)
- func (v *Value) Unmarshal(r Reader) error
- func (v *Value) UnmarshalText(b []byte) error
- func (v Value) ZeroClone() *Value
- type VariableLength
- type Vector256
- type Wire
- type Work
Examples ¶
Constants ¶
const ( ACCOUNT_ROOT LedgerEntryType = 0x61 // 'a' DIRECTORY LedgerEntryType = 0x64 // 'd' AMENDMENTS LedgerEntryType = 0x66 // 'f' LEDGER_HASHES LedgerEntryType = 0x68 // 'h' OFFER LedgerEntryType = 0x6f // 'o' RIPPLE_STATE LedgerEntryType = 0x72 // 'r' FEE_SETTING LedgerEntryType = 0x73 // 's' PAYMENT TransactionType = 0 ACCOUNT_SET TransactionType = 3 SET_REGULAR_KEY TransactionType = 5 OFFER_CREATE TransactionType = 7 OFFER_CANCEL TransactionType = 8 TRUST_SET TransactionType = 20 AMENDMENT TransactionType = 100 SET_FEE TransactionType = 101 )
const ( // Hash Prefixes HP_TRANSACTION_ID HashPrefix = 0x54584E00 // 'TXN' transaction HP_TRANSACTION_NODE HashPrefix = 0x534E4400 // 'SND' transaction plus metadata (probably should have been TND!) HP_LEAF_NODE HashPrefix = 0x4D4C4E00 // 'MLN' account state HP_INNER_NODE HashPrefix = 0x4D494E00 // 'MIN' inner node in tree HP_LEDGER_MASTER HashPrefix = 0x4C575200 // 'LWR' ledger master data for signing (probably should have been LGR!) HP_TRANSACTION_SIGN HashPrefix = 0x53545800 // 'STX' inner transaction to sign HP_VALIDATION HashPrefix = 0x56414C00 // 'VAL' validation for signing HP_PROPOSAL HashPrefix = 0x50525000 // 'PRP' proposal for signing // Node Types NT_UNKNOWN NodeType = 0 NT_LEDGER NodeType = 1 NT_TRANSACTION NodeType = 2 NT_ACCOUNT_NODE NodeType = 3 NT_TRANSACTION_NODE NodeType = 4 // Node Formats NF_PREFIX NodeFormat = 1 NF_HASH NodeFormat = 2 NF_WIRE NodeFormat = 3 // Ledger index NameSpaces NS_ACCOUNT LedgerNamespace = 'a' NS_DIRECTORY_NODE LedgerNamespace = 'd' NS_RIPPLE_STATE LedgerNamespace = 'r' NS_OFFER LedgerNamespace = 'o' // Entry for an offer NS_OWNER_DIRECTORY LedgerNamespace = 'O' // Directory of things owned by an account NS_BOOK_DIRECTORY LedgerNamespace = 'B' // Directory of order books NS_SKIP_LIST LedgerNamespace = 's' NS_AMENDMENT LedgerNamespace = 'f' NS_FEE LedgerNamespace = 'e' )
const ( ST_UINT16 uint8 = 1 ST_UINT32 uint8 = 2 ST_UINT64 uint8 = 3 ST_HASH128 uint8 = 4 ST_HASH256 uint8 = 5 ST_AMOUNT uint8 = 6 ST_VL uint8 = 7 ST_ACCOUNT uint8 = 8 ST_OBJECT uint8 = 14 ST_ARRAY uint8 = 15 ST_UINT8 uint8 = 16 ST_HASH160 uint8 = 17 ST_PATHSET uint8 = 18 ST_VECTOR256 uint8 = 19 )
const ( PATH_BOUNDARY uint8 = 0xFF PATH_END uint8 = 0x00 )
Variables ¶
var FieldsFactory = [...]func() interface{}{ ACCOUNT_ROOT: func() interface{} { return &AccountRootFields{} }, DIRECTORY: func() interface{} { return &DirectoryFields{} }, AMENDMENTS: func() interface{} { return &AmendmentsFields{} }, LEDGER_HASHES: func() interface{} { return &LedgerHashesFields{} }, OFFER: func() interface{} { return &OfferFields{} }, RIPPLE_STATE: func() interface{} { return &RippleStateFields{} }, FEE_SETTING: func() interface{} { return &FeeSettingFields{} }, }
var HashableTypes []string
var LedgerEntryFactory = [...]func() LedgerEntry{ ACCOUNT_ROOT: func() LedgerEntry { return &AccountRoot{leBase: leBase{LedgerEntryType: ACCOUNT_ROOT}} }, DIRECTORY: func() LedgerEntry { return &Directory{leBase: leBase{LedgerEntryType: DIRECTORY}} }, AMENDMENTS: func() LedgerEntry { return &Amendments{leBase: leBase{LedgerEntryType: AMENDMENTS}} }, LEDGER_HASHES: func() LedgerEntry { return &LedgerHashes{leBase: leBase{LedgerEntryType: LEDGER_HASHES}} }, OFFER: func() LedgerEntry { return &Offer{leBase: leBase{LedgerEntryType: OFFER}} }, RIPPLE_STATE: func() LedgerEntry { return &RippleState{leBase: leBase{LedgerEntryType: RIPPLE_STATE}} }, FEE_SETTING: func() LedgerEntry { return &FeeSetting{leBase: leBase{LedgerEntryType: FEE_SETTING}} }, }
var LedgerFactory = [...]func() Hashable{ func() Hashable { return &Ledger{} }, }
var TxFactory = [...]func() Transaction{ PAYMENT: func() Transaction { return &Payment{TxBase: TxBase{TransactionType: PAYMENT}} }, ACCOUNT_SET: func() Transaction { return &AccountSet{TxBase: TxBase{TransactionType: ACCOUNT_SET}} }, SET_REGULAR_KEY: func() Transaction { return &SetRegularKey{TxBase: TxBase{TransactionType: SET_REGULAR_KEY}} }, OFFER_CREATE: func() Transaction { return &OfferCreate{TxBase: TxBase{TransactionType: OFFER_CREATE}} }, OFFER_CANCEL: func() Transaction { return &OfferCancel{TxBase: TxBase{TransactionType: OFFER_CANCEL}} }, TRUST_SET: func() Transaction { return &TrustSet{TxBase: TxBase{TransactionType: TRUST_SET}} }, AMENDMENT: func() Transaction { return &Amendment{TxBase: TxBase{TransactionType: AMENDMENT}} }, SET_FEE: func() Transaction { return &SetFee{TxBase: TxBase{TransactionType: SET_FEE}} }, }
Functions ¶
func CheckSignature ¶
func GetLedgerEntryFactoryByType ¶
func GetLedgerEntryFactoryByType(leType string) func() LedgerEntry
func GetTxFactoryByType ¶
func GetTxFactoryByType(txType string) func() Transaction
func Sign ¶
func Sign(key crypto.Key, tx Transaction) error
Fills the raw field with a signed version of the encoding
func UnmarshalTransactionWithMetadata ¶
func UnmarshalTransactionWithMetadata(b []byte, txm *TransactionWithMetaData) error
Types ¶
type Account ¶
type Account [20]byte
func NewAccountFromAddress ¶
Expects address in base58 form
func (Account) MarshalText ¶
func (*Account) UnmarshalText ¶
Expects base58-encoded account id
type AccountRoot ¶
type AccountRoot struct {
AccountRootFields
// contains filtered or unexported fields
}
func (*AccountRoot) GetLedgerEntryType ¶
func (le *AccountRoot) GetLedgerEntryType() LedgerEntryType
func (*AccountRoot) String ¶
func (a *AccountRoot) String() string
type AccountRootFields ¶
type AccountRootFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
Sequence *uint32 `json:",omitempty"`
Balance *Value `json:",omitempty"`
OwnerCount *uint32 `json:",omitempty"`
PreviousTxnID *Hash256 `json:",omitempty"`
PreviousTxnLgrSeq *uint32 `json:",omitempty"`
AccountTxnID *Hash256 `json:",omitempty"`
RegularKey *RegularKey `json:",omitempty"`
EmailHash *Hash128 `json:",omitempty"`
WalletLocator *Hash256 `json:",omitempty"`
WalletSize *uint32 `json:",omitempty"`
MessageKey *PublicKey `json:",omitempty"`
TransferRate *uint32 `json:",omitempty"`
Domain *VariableLength `json:",omitempty"`
Signers *VariableLength `json:",omitempty"`
}
type AccountSet ¶
type AccountSet struct {
TxBase
EmailHash *Hash128 `json:",omitempty"`
WalletLocator *Hash256 `json:",omitempty"`
WalletSize *uint32 `json:",omitempty"`
MessageKey *PublicKey `json:",omitempty"`
Domain *VariableLength `json:",omitempty"`
TransferRate *uint32 `json:",string"`
SetFlag *uint32 `json:",omitempty"`
ClearFlag *uint32 `json:",omitempty"`
}
func (*AccountSet) String ¶
func (a *AccountSet) String() string
type AffectedNode ¶
type AffectedNode struct {
FinalFields interface{} `json:",omitempty"`
LedgerEntryType LedgerEntryType `json:",omitempty"`
LedgerIndex *Hash256 `json:",omitempty"`
PreviousFields interface{} `json:",omitempty"`
NewFields interface{} `json:",omitempty"`
PreviousTxnID *Hash256 `json:",omitempty"`
PreviousTxnLgrSeq *uint32 `json:",omitempty"`
}
func (*AffectedNode) UnmarshalJSON ¶
func (n *AffectedNode) UnmarshalJSON(b []byte) error
type Amendments ¶
type Amendments struct {
AmendmentsFields
// contains filtered or unexported fields
}
func (*Amendments) GetLedgerEntryType ¶
func (le *Amendments) GetLedgerEntryType() LedgerEntryType
func (*Amendments) String ¶
func (a *Amendments) String() string
type AmendmentsFields ¶
type AmendmentsFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
Amendments Hash256
}
type Amount ¶
func (Amount) ApplyInterest ¶
func (Amount) IsPositive ¶
func (Amount) MarshalJSON ¶
func (*Amount) UnmarshalJSON ¶
type BalanceSlice ¶
type BalanceSlice []Balance
func (*BalanceSlice) Add ¶
func (s *BalanceSlice) Add(account *Account, balance, change *Value, currency *Currency)
func (BalanceSlice) Len ¶
func (s BalanceSlice) Len() int
func (BalanceSlice) Less ¶
func (s BalanceSlice) Less(i, j int) bool
func (BalanceSlice) Swap ¶
func (s BalanceSlice) Swap(i, j int)
type CompressedNodeEntry ¶
type Currency ¶
type Currency [20]byte
func NewCurrency ¶
Accepts currency as either a 3 character code or a 40 character hex string
func (Currency) MarshalText ¶
func (Currency) String ¶
Currency in human parsable form Demurrage is formatted, for example, as XAU (0.50%pa)
func (Currency) Type ¶
func (c Currency) Type() CurrencyType
func (*Currency) UnmarshalText ¶
type CurrencyType ¶
type CurrencyType uint8
const ( CT_XRP CurrencyType = 0 CT_STANDARD CurrencyType = 1 CT_DEMURRAGE CurrencyType = 2 CT_HEX CurrencyType = 3 CT_UNKNOWN CurrencyType = 4 )
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func (*Decoder) CompressedInnerNode ¶
func (*Decoder) HashPrefix ¶
func (dec *Decoder) HashPrefix() (HashPrefix, error)
func (*Decoder) Header ¶
func (dec *Decoder) Header() (*NodeHeader, error)
func (*Decoder) LedgerEntry ¶
func (dec *Decoder) LedgerEntry() (LedgerEntry, error)
func (*Decoder) Transaction ¶
func (dec *Decoder) Transaction() (Transaction, error)
func (*Decoder) TransactionWithMetadata ¶
func (dec *Decoder) TransactionWithMetadata() (*TransactionWithMetaData, error)
func (*Decoder) Validation ¶
func (dec *Decoder) Validation() (*Validation, error)
type Directory ¶
type Directory struct {
DirectoryFields
// contains filtered or unexported fields
}
func (*Directory) GetLedgerEntryType ¶
func (le *Directory) GetLedgerEntryType() LedgerEntryType
type DirectoryFields ¶
type DirectoryFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
RootIndex *Hash256 `json:",omitempty"`
Indexes *Vector256 `json:",omitempty"`
Owner *Account `json:",omitempty"`
TakerPaysCurrency *Hash160 `json:",omitempty"`
TakerPaysIssuer *Hash160 `json:",omitempty"`
TakerGetsCurrency *Hash160 `json:",omitempty"`
TakerGetsIssuer *Hash160 `json:",omitempty"`
ExchangeRate *NodeIndex `json:",omitempty"`
IndexNext *NodeIndex `json:",omitempty"`
IndexPrevious *NodeIndex `json:",omitempty"`
}
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewEncoder ¶
func NewEncoder() *Encoder
func (*Encoder) SigningHash ¶
func (enc *Encoder) SigningHash(tx Transaction) ([]byte, error)
func (*Encoder) Transaction ¶
func (enc *Encoder) Transaction(tx Transaction, ignoreSigningFields bool) error
func (*Encoder) Validation ¶
func (enc *Encoder) Validation(v *Validation, ignoreSigningFields bool) error
type FeeSetting ¶
type FeeSetting struct {
FeeSettingFields
// contains filtered or unexported fields
}
func (*FeeSetting) GetLedgerEntryType ¶
func (le *FeeSetting) GetLedgerEntryType() LedgerEntryType
func (*FeeSetting) String ¶
func (s *FeeSetting) String() string
type FeeSettingFields ¶
type FeeSettingFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
BaseFee uint64
ReferenceFeeUnits uint32
ReserveBase uint32
ReserveIncrement uint32
}
type Hash256 ¶
type Hash256 [32]byte
func GetAccountRootIndex ¶
func GetAmendmentsIndex ¶
func GetBookIndex ¶
func GetDirectoryNodeIndex ¶
func GetFeeIndex ¶
func GetLedgerHashIndex ¶
func GetOwnerDirectoryIndex ¶
func LedgerIndex ¶
func LedgerIndex(le LedgerEntry) (*Hash256, error)
func NewHash256 ¶
Accepts either a hex string or a byte slice of length 32
func (Hash256) MarshalText ¶
func (Hash256) TruncatedString ¶
func (*Hash256) UnmarshalText ¶
type HashPrefix ¶
type HashPrefix uint32
func (HashPrefix) Bytes ¶
func (h HashPrefix) Bytes() []byte
func (HashPrefix) String ¶
func (h HashPrefix) String() string
type Hashable ¶
type InnerNode ¶
type InnerNode struct {
Type NodeType
Children [16]Hash256
// contains filtered or unexported fields
}
func (InnerNode) Each ¶
func (n InnerNode) Each(f InnerNodeFunc) error
type InnerNodeFunc ¶
type Ledger ¶
type Ledger struct {
LedgerHeader
Closed bool `json:"closed"`
Accepted bool `json:"accepted"`
Transactions TransactionSlice `json:"transactions"`
AccountState LedgerEntrySlice `json:"accountState"`
// contains filtered or unexported fields
}
func NewEmptyLedger ¶
func (Ledger) MarshalJSON ¶
func (*Ledger) UnmarshalJSON ¶
type LedgerEntry ¶
type LedgerEntry interface {
Hashable
GetLedgerEntryType() LedgerEntryType
}
type LedgerEntryFlag ¶
type LedgerEntryFlag uint32
const ( // AccountRoot flags LsPasswordSpent LedgerEntryFlag = 0x00010000 LsRequireDestTag LedgerEntryFlag = 0x00020000 LsRequireAuth LedgerEntryFlag = 0x00040000 LsDisallowXRP LedgerEntryFlag = 0x00080000 LsDisableMaster LedgerEntryFlag = 0x00100000 LsNoFreeze LedgerEntryFlag = 0x00200000 // Offer flags LsPassive LedgerEntryFlag = 0x00010000 LsSell LedgerEntryFlag = 0x00020000 // RippleState flags LsLowReserve LedgerEntryFlag = 0x00010000 LsHighReserve LedgerEntryFlag = 0x00020000 LsLowAuth LedgerEntryFlag = 0x00040000 LsHighAuth LedgerEntryFlag = 0x00080000 LsLowNoRipple LedgerEntryFlag = 0x00100000 LsHighNoRipple LedgerEntryFlag = 0x00200000 LsLowFreeze LedgerEntryFlag = 0x00400000 LsHighFreeze LedgerEntryFlag = 0x00800000 )
Ledger entry flags
type LedgerEntrySlice ¶
type LedgerEntrySlice []LedgerEntry
func (LedgerEntrySlice) MarshalJSON ¶
func (s LedgerEntrySlice) MarshalJSON() ([]byte, error)
func (*LedgerEntrySlice) UnmarshalJSON ¶
func (l *LedgerEntrySlice) UnmarshalJSON(b []byte) error
type LedgerEntryType ¶
type LedgerEntryType uint16
func (LedgerEntryType) MarshalText ¶
func (l LedgerEntryType) MarshalText() ([]byte, error)
func (LedgerEntryType) String ¶
func (le LedgerEntryType) String() string
func (*LedgerEntryType) UnmarshalText ¶
func (l *LedgerEntryType) UnmarshalText(b []byte) error
type LedgerHashes ¶
type LedgerHashes struct {
LedgerHashesFields
// contains filtered or unexported fields
}
func (*LedgerHashes) GetLedgerEntryType ¶
func (le *LedgerHashes) GetLedgerEntryType() LedgerEntryType
func (*LedgerHashes) String ¶
func (h *LedgerHashes) String() string
type LedgerHashesFields ¶
type LedgerHashesFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
FirstLedgerSequence uint32
LastLedgerSequence uint32
Hashes Vector256
}
type LedgerHeader ¶
type LedgerHeader struct {
LedgerSequence uint32 `json:"ledger_index,string"`
TotalXRP uint64 `json:"total_coins,string"`
PreviousLedger Hash256 `json:"parent_hash"`
TransactionHash Hash256 `json:"transaction_hash"`
StateHash Hash256 `json:"account_hash"`
ParentCloseTime RippleTime `json:"-"`
CloseTime RippleTime `json:"close_time"`
CloseResolution uint8 `json:"close_time_resolution"`
CloseFlags uint8 `json:"-"`
}
type LedgerNamespace ¶
type LedgerNamespace uint16
type LedgerRange ¶
type LedgerSet ¶
type LedgerSet struct {
// contains filtered or unexported fields
}
func NewLedgerSet ¶
func (*LedgerSet) TakeBottom ¶
func (l *LedgerSet) TakeBottom(n uint32) LedgerSlice
func (*LedgerSet) TakeMiddle ¶
func (l *LedgerSet) TakeMiddle(r *LedgerRange) LedgerSlice
func (*LedgerSet) TakeTop ¶
func (l *LedgerSet) TakeTop(n uint32) LedgerSlice
type LedgerSlice ¶
type LedgerSlice []uint32
func (LedgerSlice) Len ¶
func (s LedgerSlice) Len() int
func (LedgerSlice) Less ¶
func (s LedgerSlice) Less(i, j int) bool
func (LedgerSlice) Sorted ¶
func (s LedgerSlice) Sorted() LedgerSlice
func (LedgerSlice) Swap ¶
func (s LedgerSlice) Swap(i, j int)
type LimitByteReader ¶
func LimitedByteReader ¶
func LimitedByteReader(r Reader, n int64) *LimitByteReader
func (*LimitByteReader) Len ¶
func (l *LimitByteReader) Len() int
func (*LimitByteReader) ReadByte ¶
func (l *LimitByteReader) ReadByte() (c byte, err error)
type Memo ¶
type Memo struct {
Memo struct {
MemoType VariableLength
MemoData VariableLength
}
}
type MetaData ¶
type MetaData struct {
AffectedNodes NodeEffects
TransactionIndex uint32
TransactionResult TransactionResult
DeliveredAmount *Amount `json:",omitempty"`
}
type NodeEffect ¶
type NodeEffect struct {
ModifiedNode *AffectedNode `json:",omitempty"`
CreatedNode *AffectedNode `json:",omitempty"`
DeletedNode *AffectedNode `json:",omitempty"`
}
func (*NodeEffect) Action ¶
func (m *NodeEffect) Action() string
type NodeEffects ¶
type NodeEffects []NodeEffect
func (NodeEffects) Unmarshal ¶
func (e NodeEffects) Unmarshal(r Reader) error
type NodeFormat ¶
type NodeFormat uint8
type NodeHeader ¶
type NodeIndex ¶
type NodeIndex uint64
func (NodeIndex) MarshalText ¶
func (*NodeIndex) UnmarshalText ¶
type Offer ¶
type Offer struct {
OfferFields
// contains filtered or unexported fields
}
func (*Offer) GetLedgerEntryType ¶
func (le *Offer) GetLedgerEntryType() LedgerEntryType
type OfferCancel ¶
func (*OfferCancel) String ¶
func (o *OfferCancel) String() string
type OfferCreate ¶
type OfferCreate struct {
TxBase
OfferSequence *uint32 `json:",omitempty"`
TakerPays Amount
TakerGets Amount
Expiration *uint32 `json:",omitempty"`
}
func (*OfferCreate) String ¶
func (o *OfferCreate) String() string
type OfferFields ¶
type OfferFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
Account *Account `json:",omitempty"`
Sequence *uint32 `json:",omitempty"`
TakerPays *Amount `json:",omitempty"`
TakerGets *Amount `json:",omitempty"`
BookDirectory *Hash256 `json:",omitempty"`
BookNode *NodeIndex `json:",omitempty"`
OwnerNode *NodeIndex `json:",omitempty"`
PreviousTxnID *Hash256 `json:",omitempty"`
PreviousTxnLgrSeq *uint32 `json:",omitempty"`
Expiration *RippleTime `json:",omitempty"`
}
type Path ¶
func (Path) MarshalJSON ¶
type Payment ¶
type Proposal ¶
type PublicKey ¶
type PublicKey [33]byte
func (PublicKey) MarshalText ¶
func (*PublicKey) UnmarshalText ¶
Expects public key hex
type Reader ¶
type Reader interface {
io.ByteReader
io.Reader
Len() int
}
func NewVariableByteReader ¶
type RegularKey ¶
type RegularKey [20]byte
func NewRegularKeyFromAddress ¶
func NewRegularKeyFromAddress(s string) (*RegularKey, error)
Expects address in base58 form
func (*RegularKey) Bytes ¶
func (r *RegularKey) Bytes() []byte
func (RegularKey) MarshalText ¶
func (r RegularKey) MarshalText() ([]byte, error)
func (RegularKey) String ¶
func (r RegularKey) String() string
func (*RegularKey) Unmarshal ¶
func (k *RegularKey) Unmarshal(r Reader) error
func (*RegularKey) UnmarshalText ¶
func (r *RegularKey) UnmarshalText(b []byte) error
Expects base58-encoded account id
type RippleHumanTime ¶
type RippleHumanTime struct {
*RippleTime
}
func (RippleHumanTime) MarshalJSON ¶
func (t RippleHumanTime) MarshalJSON() ([]byte, error)
func (*RippleHumanTime) UnmarshalJSON ¶
func (t *RippleHumanTime) UnmarshalJSON(b []byte) error
type RippleState ¶
type RippleState struct {
RippleStateFields
// contains filtered or unexported fields
}
func (*RippleState) GetLedgerEntryType ¶
func (le *RippleState) GetLedgerEntryType() LedgerEntryType
func (*RippleState) String ¶
func (r *RippleState) String() string
type RippleStateFields ¶
type RippleStateFields struct {
Flags *LedgerEntryFlag `json:",omitempty"`
LowLimit *Amount `json:",omitempty"`
HighLimit *Amount `json:",omitempty"`
PreviousTxnID *Hash256 `json:",omitempty"`
PreviousTxnLgrSeq *uint32 `json:",omitempty"`
Balance *Amount `json:",omitempty"`
LowNode *NodeIndex `json:",omitempty"`
HighNode *NodeIndex `json:",omitempty"`
LowQualityIn *uint32 `json:",omitempty"`
LowQualityOut *uint32 `json:",omitempty"`
HighQualityIn *uint32 `json:",omitempty"`
HighQualityOut *uint32 `json:",omitempty"`
}
type RippleTime ¶
type RippleTime struct {
T uint32
}
func NewRippleTime ¶
func NewRippleTime(t uint32) *RippleTime
func Now ¶
func Now() *RippleTime
func (*RippleTime) Human ¶
func (t *RippleTime) Human() *RippleHumanTime
func (RippleTime) MarshalJSON ¶
func (t RippleTime) MarshalJSON() ([]byte, error)
func (*RippleTime) SetString ¶
func (t *RippleTime) SetString(s string) error
func (*RippleTime) SetUint32 ¶
func (t *RippleTime) SetUint32(n uint32)
func (*RippleTime) Short ¶
func (t *RippleTime) Short() string
func (*RippleTime) String ¶
func (t *RippleTime) String() string
func (*RippleTime) Uint32 ¶
func (t *RippleTime) Uint32() uint32
func (*RippleTime) UnmarshalJSON ¶
func (t *RippleTime) UnmarshalJSON(b []byte) error
type SetFee ¶
type SetRegularKey ¶
type SetRegularKey struct {
TxBase
RegularKey *RegularKey `json:",omitempty"`
}
func (*SetRegularKey) String ¶
func (s *SetRegularKey) String() string
type Trade ¶
type TradeSlice ¶
type TradeSlice []Trade
func (*TradeSlice) Add ¶
func (s *TradeSlice) Add(buyer, seller *Account, price, amount *Amount)
func (TradeSlice) Len ¶
func (s TradeSlice) Len() int
func (TradeSlice) Less ¶
func (s TradeSlice) Less(i, j int) bool
func (TradeSlice) Sum ¶
func (s TradeSlice) Sum() (*Amount, error)
func (TradeSlice) Swap ¶
func (s TradeSlice) Swap(i, j int)
type Transaction ¶
type Transaction interface {
Hashable
GetTransactionType() TransactionType
GetAccount() string
// GetAffectedNodes() []NodeEffect
GetBase() *TxBase
}
type TransactionFlag ¶
type TransactionFlag uint32
const ( //Universal flags TxCanonicalSignature TransactionFlag = 0x80000000 // Payment flags TxNoDirectRipple TransactionFlag = 0x00010000 TxPartialPayment TransactionFlag = 0x00020000 TxLimitQuality TransactionFlag = 0x00040000 TxCircle TransactionFlag = 0x00080000 // Not implemented // AccountSet flags TxSetRequireDest TransactionFlag = 0x00000001 TxSetRequireAuth TransactionFlag = 0x00000002 TxSetDisallowXRP TransactionFlag = 0x00000003 TxSetDisableMaster TransactionFlag = 0x00000004 TxNoFreeze TransactionFlag = 0x00000006 TxGlobalFreeze TransactionFlag = 0x00000007 TxRequireDestTag TransactionFlag = 0x00010000 TxOptionalDestTag TransactionFlag = 0x00020000 TxRequireAuth TransactionFlag = 0x00040000 TxDisallowXRP TransactionFlag = 0x00100000 TxAllowXRP TransactionFlag = 0x00200000 // OfferCreate flags TxPassive TransactionFlag = 0x00010000 TxImmediateOrCancel TransactionFlag = 0x00020000 TxFillOrKill TransactionFlag = 0x00040000 TxSell TransactionFlag = 0x00080000 // TrustSet flags TxSetAuth TransactionFlag = 0x00010000 TxSetNoRipple TransactionFlag = 0x00020000 TxClearNoRipple TransactionFlag = 0x00040000 TxSetFreeze TransactionFlag = 0x00100000 TxClearFreeze TransactionFlag = 0x00200000 )
Transaction Flags
type TransactionResult ¶
type TransactionResult uint8
func (TransactionResult) MarshalText ¶
func (r TransactionResult) MarshalText() ([]byte, error)
func (TransactionResult) String ¶
func (r TransactionResult) String() string
func (*TransactionResult) UnmarshalText ¶
func (r *TransactionResult) UnmarshalText(b []byte) error
type TransactionSlice ¶
type TransactionSlice []*TransactionWithMetaData
func (TransactionSlice) MarshalJSON ¶
func (s TransactionSlice) MarshalJSON() ([]byte, error)
type TransactionType ¶
type TransactionType uint16
func (TransactionType) MarshalText ¶
func (t TransactionType) MarshalText() ([]byte, error)
func (TransactionType) String ¶
func (t TransactionType) String() string
func (*TransactionType) UnmarshalText ¶
func (t *TransactionType) UnmarshalText(b []byte) error
type TransactionWithMetaData ¶
type TransactionWithMetaData struct {
Transaction
MetaData MetaData `json:"meta"`
LedgerSequence uint32 `json:"ledger_index"`
}
func (*TransactionWithMetaData) Balances ¶
func (txm *TransactionWithMetaData) Balances() (BalanceSlice, error)
func (*TransactionWithMetaData) GetAffectedNodes ¶
func (t *TransactionWithMetaData) GetAffectedNodes() []NodeEffect
func (*TransactionWithMetaData) GetType ¶
func (t *TransactionWithMetaData) GetType() string
func (TransactionWithMetaData) MarshalJSON ¶
func (txm TransactionWithMetaData) MarshalJSON() ([]byte, error)
func (*TransactionWithMetaData) Trades ¶
func (txm *TransactionWithMetaData) Trades() (TradeSlice, error)
func (*TransactionWithMetaData) UnmarshalJSON ¶
func (txm *TransactionWithMetaData) UnmarshalJSON(b []byte) error
type TrustSet ¶
type TxBase ¶
type TxBase struct {
TransactionType TransactionType
Flags *TransactionFlag `json:",omitempty"`
SourceTag *uint32 `json:",omitempty"`
Account Account
Sequence uint32
Fee Value
SigningPubKey *PublicKey `json:",omitempty"`
TxnSignature *VariableLength `json:",omitempty"`
Memos Memos `json:",omitempty"`
PreviousTxnID *Hash256 `json:",omitempty"`
LastLedgerSequence *uint32 `json:",omitempty"`
// contains filtered or unexported fields
}
func (*TxBase) GetAccount ¶
func (*TxBase) GetTransactionType ¶
func (t *TxBase) GetTransactionType() TransactionType
type Validation ¶
type Validation struct {
Flags uint32
LedgerHash Hash256
LedgerSequence uint32
CloseTime *uint32 // Should exist?
LoadFee *uint32 // Should exist?
Amendments Vector256
BaseFee *uint64 // Should exist?
ReserveBase *uint32 // Should exist?
ReserveIncrement *uint32 // Should exist?
SigningTime uint32
SigningPubKey PublicKey
Signature VariableLength
// contains filtered or unexported fields
}
func (*Validation) GetType ¶
func (v *Validation) GetType() string
func (*Validation) String ¶
func (v *Validation) String() string
type Value ¶
func NewNativeValue ¶
NewNativeValue returns a Value with n drops. If the value is impossible an error is returned.
func (Value) Add ¶
Add adds a to b and returns the sum as a new Value.
Example ¶
v1, _ := NewValue("100", false)
v2, _ := NewValue("200.199", false)
sum, _ := v1.Add(*v2)
fmt.Println(v1.String())
fmt.Println(v2.String())
fmt.Println(sum.String())
Output: 100 200.199 300.199
func (Value) Compare ¶
Compare returns an integer comparing two Values. The result will be 0 if a==b, -1 if a < b, and +1 if a > b.
func (Value) IsScientific ¶
func (*Value) MarshalText ¶
func (*Value) UnmarshalText ¶
type VariableLength ¶
type VariableLength []byte
func (*VariableLength) Bytes ¶
func (v *VariableLength) Bytes() []byte
func (VariableLength) MarshalText ¶
func (v VariableLength) MarshalText() ([]byte, error)
func (*VariableLength) String ¶
func (v *VariableLength) String() string
func (*VariableLength) Unmarshal ¶
func (v *VariableLength) Unmarshal(r Reader) error
func (*VariableLength) UnmarshalText ¶
func (v *VariableLength) UnmarshalText(b []byte) error
Expects variable length hex
type Work ¶
type Work struct {
*LedgerRange
MissingLedgers LedgerSlice
MissingNodes []Hash256
}
Source Files
¶
- amount.go
- currency.go
- decoder.go
- doc.go
- encoder.go
- factory.go
- flags.go
- format.go
- hash.go
- hashable.go
- index.go
- inner.go
- interface.go
- json.go
- ledger.go
- ledgerentry.go
- ledgerset.go
- memo.go
- metadata.go
- path.go
- proposal.go
- query.go
- reader.go
- result.go
- ripples.go
- signing.go
- string.go
- time.go
- transaction.go
- util.go
- validation.go
- value.go
- wire.go