data

package
v0.0.0-...-a88d24b Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2014 License: ISC Imports: 18 Imported by: 0

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

Examples

Constants

View Source
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
)
View Source
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'
)
View Source
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
)
View Source
const (
	PATH_BOUNDARY uint8 = 0xFF
	PATH_END      uint8 = 0x00
)

Variables

View Source
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{} },
}
View Source
var HashableTypes []string
View Source
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}} },
}
View Source
var LedgerFactory = [...]func() Hashable{
	func() Hashable { return &Ledger{} },
}

Functions

func CheckSignature

func CheckSignature(h Hashable) (bool, error)

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

func NewAccountFromAddress(s string) (*Account, error)

Expects address in base58 form

func (*Account) Bytes

func (a *Account) Bytes() []byte

func (Account) Equals

func (a Account) Equals(b Account) bool

func (Account) Hash

func (a Account) Hash() (crypto.Hash, error)

func (Account) Hash256

func (a Account) Hash256() Hash256

func (Account) IsZero

func (a Account) IsZero() bool

func (Account) Less

func (a Account) Less(b Account) bool

func (*Account) Marshal

func (a *Account) Marshal(w io.Writer) error

func (Account) MarshalText

func (a Account) MarshalText() ([]byte, error)

func (Account) String

func (a Account) String() string

func (*Account) Unmarshal

func (a *Account) Unmarshal(r Reader) error

func (*Account) UnmarshalText

func (a *Account) UnmarshalText(b []byte) error

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) GetType

func (le *AccountRoot) GetType() string

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) Hash

func (h *AccountSet) Hash() Hash256

func (*AccountSet) Raw

func (h *AccountSet) Raw() []byte

func (*AccountSet) SetHash

func (h *AccountSet) SetHash(hash []byte)

func (*AccountSet) SetRaw

func (h *AccountSet) SetRaw(raw []byte)

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 Amendment

type Amendment struct {
	TxBase
	Amendment Hash256
}

func (*Amendment) Hash

func (h *Amendment) Hash() Hash256

func (*Amendment) Raw

func (h *Amendment) Raw() []byte

func (*Amendment) SetHash

func (h *Amendment) SetHash(hash []byte)

func (*Amendment) SetRaw

func (h *Amendment) SetRaw(raw []byte)

func (*Amendment) String

func (a *Amendment) String() string

type Amendments

type Amendments struct {
	AmendmentsFields
	// contains filtered or unexported fields
}

func (*Amendments) GetLedgerEntryType

func (le *Amendments) GetLedgerEntryType() LedgerEntryType

func (*Amendments) GetType

func (le *Amendments) GetType() string

func (*Amendments) String

func (a *Amendments) String() string

type AmendmentsFields

type AmendmentsFields struct {
	Flags      *LedgerEntryFlag `json:",omitempty"`
	Amendments Hash256
}

type Amount

type Amount struct {
	*Value
	Currency Currency
	Issuer   Account
}

func NewAmount

func NewAmount(v interface{}) (*Amount, error)

Requires v to be in computer parsable form

func (Amount) Abs

func (a Amount) Abs() *Amount

func (Amount) Add

func (a Amount) Add(b *Amount) (*Amount, error)

func (Amount) ApplyInterest

func (a Amount) ApplyInterest() (*Amount, error)

func (*Amount) Bytes

func (a *Amount) Bytes() []byte

func (Amount) Clone

func (a Amount) Clone() *Amount

func (Amount) Divide

func (a Amount) Divide(b *Amount) (*Amount, error)

func (Amount) Equals

func (a Amount) Equals(b Amount) bool

func (Amount) IsPositive

func (a Amount) IsPositive() bool

func (Amount) Machine

func (a Amount) Machine() string

Amount in computer parsable form

func (*Amount) Marshal

func (a *Amount) Marshal(w io.Writer) error

func (Amount) MarshalJSON

func (a Amount) MarshalJSON() ([]byte, error)

func (Amount) Multiply

func (a Amount) Multiply(b *Amount) (*Amount, error)

func (Amount) Negate

func (a Amount) Negate() *Amount

func (Amount) SameValue

func (a Amount) SameValue(b *Amount) bool

Returns true if the values are equal, but ignores the currency and issuer

func (Amount) String

func (a Amount) String() string

Amount in human parsable form with demurrage applied

func (Amount) Subtract

func (a Amount) Subtract(b *Amount) (*Amount, error)

func (*Amount) Unmarshal

func (a *Amount) Unmarshal(r Reader) error

func (*Amount) UnmarshalJSON

func (a *Amount) UnmarshalJSON(b []byte) (err error)

func (Amount) ZeroClone

func (a Amount) ZeroClone() *Amount

Returns a new Amount with the same currency and issuer, but a zero value

type Balance

type Balance struct {
	Account  Account
	Balance  Value
	Change   Value
	Currency Currency
}

func (Balance) String

func (b Balance) String() string

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 CompressedNodeEntry struct {
	Hash Hash256
	Pos  uint8
}

type Currency

type Currency [20]byte

func NewCurrency

func NewCurrency(s string) (Currency, error)

Accepts currency as either a 3 character code or a 40 character hex string

func (*Currency) Bytes

func (c *Currency) Bytes() []byte

func (Currency) Clone

func (c Currency) Clone() Currency

func (Currency) Equals

func (c Currency) Equals(other Currency) bool

func (Currency) IsNative

func (c Currency) IsNative() bool

func (Currency) Less

func (a Currency) Less(b Currency) bool

func (Currency) Machine

func (c Currency) Machine() string

Currency in computer parsable form

func (*Currency) Marshal

func (c *Currency) Marshal(w io.Writer) error

func (Currency) MarshalText

func (c Currency) MarshalText() ([]byte, error)

func (Currency) Rate

func (c Currency) Rate(seconds uint32) float64

func (Currency) String

func (c Currency) String() 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) Unmarshal

func (c *Currency) Unmarshal(r Reader) error

func (*Currency) UnmarshalText

func (c *Currency) UnmarshalText(text []byte) error

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 NewDecoder(r Reader) *Decoder

func (*Decoder) CompressedInnerNode

func (dec *Decoder) CompressedInnerNode(typ NodeType) (*InnerNode, error)

func (*Decoder) Hash

func (dec *Decoder) Hash() (*Hash256, error)

func (*Decoder) HashPrefix

func (dec *Decoder) HashPrefix() (HashPrefix, error)

func (*Decoder) Header

func (dec *Decoder) Header() (*NodeHeader, error)

func (*Decoder) InnerNode

func (dec *Decoder) InnerNode(typ NodeType) (*InnerNode, error)

func (*Decoder) Ledger

func (dec *Decoder) Ledger() (*Ledger, error)

func (*Decoder) LedgerEntry

func (dec *Decoder) LedgerEntry() (LedgerEntry, error)

func (*Decoder) Prefix

func (dec *Decoder) Prefix() (Hashable, 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)

func (*Decoder) Wire

func (dec *Decoder) Wire(typ NodeType) (Hashable, error)

type Directory

type Directory struct {
	DirectoryFields
	// contains filtered or unexported fields
}

func (*Directory) GetLedgerEntryType

func (le *Directory) GetLedgerEntryType() LedgerEntryType

func (*Directory) GetType

func (le *Directory) GetType() string

func (*Directory) String

func (d *Directory) String() string

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) HashPrefix

func (enc *Encoder) HashPrefix(w io.Writer, h Hashable) error

func (*Encoder) Hex

func (enc *Encoder) Hex(w io.Writer, h Hashable) error

func (*Encoder) Ledger

func (enc *Encoder) Ledger(w io.Writer, h Hashable) error

func (*Encoder) Node

func (enc *Encoder) Node(h Hashable) error

func (*Encoder) NodeType

func (enc *Encoder) NodeType(w io.Writer, h Hashable) error

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) GetType

func (le *FeeSetting) GetType() string

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 Hash128

type Hash128 [16]byte

func (Hash128) Bytes

func (h Hash128) Bytes() []byte

func (*Hash128) Marshal

func (h *Hash128) Marshal(w io.Writer) error

func (Hash128) MarshalText

func (h Hash128) MarshalText() ([]byte, error)

func (Hash128) String

func (h Hash128) String() string

func (*Hash128) Unmarshal

func (h *Hash128) Unmarshal(r Reader) error

func (*Hash128) UnmarshalText

func (h *Hash128) UnmarshalText(b []byte) error

type Hash160

type Hash160 [20]byte

func (Hash160) Bytes

func (h Hash160) Bytes() []byte

func (*Hash160) Marshal

func (h *Hash160) Marshal(w io.Writer) error

func (Hash160) MarshalText

func (h Hash160) MarshalText() ([]byte, error)

func (Hash160) String

func (h Hash160) String() string

func (*Hash160) Unmarshal

func (h *Hash160) Unmarshal(r Reader) error

func (*Hash160) UnmarshalText

func (h *Hash160) UnmarshalText(b []byte) error

type Hash256

type Hash256 [32]byte

func GetAccountRootIndex

func GetAccountRootIndex(account Account) (*Hash256, error)

func GetAmendmentsIndex

func GetAmendmentsIndex() (*Hash256, error)

func GetBookIndex

func GetBookIndex(paysCurrency, getsCurrency Hash160, paysIssuer, getsIssuer Hash160) (*Hash256, error)

func GetDirectoryNodeIndex

func GetDirectoryNodeIndex(root Hash256, index *NodeIndex) (*Hash256, error)

func GetFeeIndex

func GetFeeIndex() (*Hash256, error)

func GetLedgerHashIndex

func GetLedgerHashIndex() (*Hash256, error)

func GetOfferIndex

func GetOfferIndex(account Account, sequence uint32) (*Hash256, error)

func GetOwnerDirectoryIndex

func GetOwnerDirectoryIndex(account Account) (*Hash256, error)

func GetPreviousLedgerHashIndex

func GetPreviousLedgerHashIndex(sequence uint32) (*Hash256, error)

func GetRippleStateIndex

func GetRippleStateIndex(a, b Account, c Currency) (*Hash256, error)

func LedgerIndex

func LedgerIndex(le LedgerEntry) (*Hash256, error)

func NewHash256

func NewHash256(value interface{}) (*Hash256, error)

Accepts either a hex string or a byte slice of length 32

func (Hash256) Bytes

func (h Hash256) Bytes() []byte

func (Hash256) Compare

func (h Hash256) Compare(x Hash256) int

func (Hash256) IsZero

func (h Hash256) IsZero() bool

func (*Hash256) Marshal

func (h *Hash256) Marshal(w io.Writer) error

func (Hash256) MarshalText

func (h Hash256) MarshalText() ([]byte, error)

func (Hash256) String

func (h Hash256) String() string

func (Hash256) TruncatedString

func (h Hash256) TruncatedString(length int) string

func (*Hash256) Unmarshal

func (h *Hash256) Unmarshal(r Reader) error

func (*Hash256) UnmarshalText

func (h *Hash256) UnmarshalText(b []byte) error

func (Hash256) Xor

func (h Hash256) Xor(x Hash256) Hash256

type HashPrefix

type HashPrefix uint32

func (HashPrefix) Bytes

func (h HashPrefix) Bytes() []byte

func (HashPrefix) String

func (h HashPrefix) String() string

type Hashable

type Hashable interface {
	GetType() string
	Hash() Hash256
	Raw() []byte
	SetHash([]byte)
	SetRaw([]byte)
	String() string
}

func NewHashable

func NewHashable(typ reflect.Type) (Hashable, error)

type InnerNode

type InnerNode struct {
	Type     NodeType
	Children [16]Hash256
	// contains filtered or unexported fields
}

func (InnerNode) Count

func (n InnerNode) Count() int

func (InnerNode) Each

func (n InnerNode) Each(f InnerNodeFunc) error

func (InnerNode) GetType

func (n InnerNode) GetType() string

func (*InnerNode) Hash

func (h *InnerNode) Hash() Hash256

func (*InnerNode) Raw

func (h *InnerNode) Raw() []byte

func (*InnerNode) SetHash

func (h *InnerNode) SetHash(hash []byte)

func (*InnerNode) SetRaw

func (h *InnerNode) SetRaw(raw []byte)

func (InnerNode) String

func (n InnerNode) String() string

type InnerNodeFunc

type InnerNodeFunc func(pos int, child Hash256) error

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 NewEmptyLedger(sequence uint32) *Ledger

func (*Ledger) GetType

func (l *Ledger) GetType() string

func (*Ledger) Hash

func (h *Ledger) Hash() Hash256

func (Ledger) MarshalJSON

func (l Ledger) MarshalJSON() ([]byte, error)

func (*Ledger) Raw

func (h *Ledger) Raw() []byte

func (*Ledger) SetHash

func (h *Ledger) SetHash(hash []byte)

func (*Ledger) SetRaw

func (h *Ledger) SetRaw(raw []byte)

func (*Ledger) String

func (l *Ledger) String() string

func (*Ledger) UnmarshalJSON

func (l *Ledger) UnmarshalJSON(b []byte) error

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) GetType

func (le *LedgerHashes) GetType() string

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 LedgerRange struct {
	Start uint32
	End   uint32
	Max   uint32
}

type LedgerSet

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

func NewLedgerSet

func NewLedgerSet(start, capacity uint32) *LedgerSet

func (*LedgerSet) Count

func (l *LedgerSet) Count() uint32

func (*LedgerSet) Extend

func (l *LedgerSet) Extend(i uint32)

func (*LedgerSet) Max

func (l *LedgerSet) Max() uint32

func (*LedgerSet) Set

func (l *LedgerSet) Set(i uint32) time.Duration

func (*LedgerSet) String

func (l *LedgerSet) String() string

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

func (*LedgerSet) Taken

func (l *LedgerSet) Taken() uint32

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

type LimitByteReader struct {
	R Reader // underlying reader
	N int64  // max bytes remaining
}

func LimitedByteReader

func LimitedByteReader(r Reader, n int64) *LimitByteReader

func (*LimitByteReader) Len

func (l *LimitByteReader) Len() int

func (*LimitByteReader) Read

func (l *LimitByteReader) Read(p []byte) (n int, err error)

func (*LimitByteReader) ReadByte

func (l *LimitByteReader) ReadByte() (c byte, err error)

type Memo

type Memo struct {
	Memo struct {
		MemoType VariableLength
		MemoData VariableLength
	}
}

type Memos

type Memos []Memo

func (*Memos) Marshal

func (m *Memos) Marshal(w io.Writer) error

func (*Memos) Unmarshal

func (m *Memos) Unmarshal(r Reader) error

type MetaData

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

func (*MetaData) GetType

func (m *MetaData) GetType() string

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) Marshal

func (e NodeEffects) Marshal(w io.Writer) error

func (NodeEffects) Unmarshal

func (e NodeEffects) Unmarshal(r Reader) error

type NodeFormat

type NodeFormat uint8

type NodeHeader

type NodeHeader struct {
	LedgerIndex uint32

	NodeType NodeType
	// contains filtered or unexported fields
}

type NodeIndex

type NodeIndex uint64

func (NodeIndex) MarshalText

func (i NodeIndex) MarshalText() ([]byte, error)

func (*NodeIndex) Next

func (i *NodeIndex) Next() *NodeIndex

func (*NodeIndex) Previous

func (i *NodeIndex) Previous() *NodeIndex

func (*NodeIndex) UnmarshalText

func (i *NodeIndex) UnmarshalText(b []byte) error

type NodeType

type NodeType uint8

func (NodeType) String

func (n NodeType) String() string

type Offer

type Offer struct {
	OfferFields
	// contains filtered or unexported fields
}

func (*Offer) GetLedgerEntryType

func (le *Offer) GetLedgerEntryType() LedgerEntryType

func (*Offer) GetType

func (le *Offer) GetType() string

func (*Offer) String

func (o *Offer) String() string

type OfferCancel

type OfferCancel struct {
	TxBase
	OfferSequence uint32
}

func (*OfferCancel) Hash

func (h *OfferCancel) Hash() Hash256

func (*OfferCancel) Raw

func (h *OfferCancel) Raw() []byte

func (*OfferCancel) SetHash

func (h *OfferCancel) SetHash(hash []byte)

func (*OfferCancel) SetRaw

func (h *OfferCancel) SetRaw(raw []byte)

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) Hash

func (h *OfferCreate) Hash() Hash256

func (*OfferCreate) Raw

func (h *OfferCreate) Raw() []byte

func (*OfferCreate) SetHash

func (h *OfferCreate) SetHash(hash []byte)

func (*OfferCreate) SetRaw

func (h *OfferCreate) SetRaw(raw []byte)

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

type Path struct {
	Account  *Account
	Currency *Currency
	Issuer   *Account
}

func (Path) MarshalJSON

func (p Path) MarshalJSON() ([]byte, error)

func (Path) PathEntry

func (p Path) PathEntry() PathEntry

type PathEntry

type PathEntry uint8

type Paths

type Paths [][]Path

func (*Paths) Marshal

func (p *Paths) Marshal(w io.Writer) error

func (*Paths) Unmarshal

func (p *Paths) Unmarshal(r Reader) error

type Payment

type Payment struct {
	TxBase
	Destination    Account
	Amount         Amount
	SendMax        *Amount  `json:",omitempty"`
	Paths          *Paths   `json:",omitempty"`
	DestinationTag *uint32  `json:",omitempty"`
	InvoiceID      *Hash256 `json:",omitempty"`
}

func (*Payment) Hash

func (h *Payment) Hash() Hash256

func (*Payment) Raw

func (h *Payment) Raw() []byte

func (*Payment) SetHash

func (h *Payment) SetHash(hash []byte)

func (*Payment) SetRaw

func (h *Payment) SetRaw(raw []byte)

func (*Payment) String

func (p *Payment) String() string

type Proposal

type Proposal struct {
	LedgerHash     Hash256
	PreviousLedger Hash256
	Sequence       uint32
	CloseTime      uint32
	PublicKey      PublicKey
	Signature      VariableLength
	// contains filtered or unexported fields
}

func (*Proposal) GetType

func (p *Proposal) GetType() string

func (*Proposal) Hash

func (h *Proposal) Hash() Hash256

func (*Proposal) Raw

func (h *Proposal) Raw() []byte

func (*Proposal) SetHash

func (h *Proposal) SetHash(hash []byte)

func (*Proposal) SetRaw

func (h *Proposal) SetRaw(raw []byte)

func (*Proposal) String

func (p *Proposal) String() string

type PublicKey

type PublicKey [33]byte

func (*PublicKey) Bytes

func (p *PublicKey) Bytes() []byte

func (PublicKey) IsZero

func (p PublicKey) IsZero() bool

func (*PublicKey) Marshal

func (k *PublicKey) Marshal(w io.Writer) error

func (PublicKey) MarshalText

func (p PublicKey) MarshalText() ([]byte, error)

func (PublicKey) String

func (p PublicKey) String() string

func (*PublicKey) Unmarshal

func (k *PublicKey) Unmarshal(r Reader) error

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(b []byte) error

Expects public key hex

type Query

type Query struct {
	MinLedger *uint64
	MaxLedger *uint64
	Account   *Account
	Limit     *uint64
	Order     []string
	Instance  interface{}
}

type Reader

type Reader interface {
	io.ByteReader
	io.Reader
	Len() int
}

func NewVariableByteReader

func NewVariableByteReader(r Reader) (Reader, error)

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) Hash

func (r RegularKey) Hash() (crypto.Hash, error)

func (*RegularKey) Marshal

func (k *RegularKey) Marshal(w io.Writer) error

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) GetType

func (le *RippleState) GetType() string

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 SetFee struct {
	TxBase
	BaseFee           uint64
	ReferenceFeeUnits uint32
	ReserveBase       uint32
	ReserveIncrement  uint32
}

func (*SetFee) Hash

func (h *SetFee) Hash() Hash256

func (*SetFee) Raw

func (h *SetFee) Raw() []byte

func (*SetFee) SetHash

func (h *SetFee) SetHash(hash []byte)

func (*SetFee) SetRaw

func (h *SetFee) SetRaw(raw []byte)

func (*SetFee) String

func (f *SetFee) String() string

type SetRegularKey

type SetRegularKey struct {
	TxBase
	RegularKey *RegularKey `json:",omitempty"`
}

func (*SetRegularKey) Hash

func (h *SetRegularKey) Hash() Hash256

func (*SetRegularKey) Raw

func (h *SetRegularKey) Raw() []byte

func (*SetRegularKey) SetHash

func (h *SetRegularKey) SetHash(hash []byte)

func (*SetRegularKey) SetRaw

func (h *SetRegularKey) SetRaw(raw []byte)

func (*SetRegularKey) String

func (s *SetRegularKey) String() string

type Trade

type Trade struct {
	Buyer    Account
	Seller   Account
	Price    Value
	Amount   Value
	Currency Currency
	Issuer   Account
}

func (Trade) String

func (t Trade) String() string

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 TrustSet struct {
	TxBase
	LimitAmount *Amount `json:",omitempty"`
	QualityIn   *uint32 `json:",omitempty"`
	QualityOut  *uint32 `json:",omitempty"`
}

func (*TrustSet) Hash

func (h *TrustSet) Hash() Hash256

func (*TrustSet) Raw

func (h *TrustSet) Raw() []byte

func (*TrustSet) SetHash

func (h *TrustSet) SetHash(hash []byte)

func (*TrustSet) SetRaw

func (h *TrustSet) SetRaw(raw []byte)

func (*TrustSet) String

func (t *TrustSet) String() string

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 (t *TxBase) GetAccount() string

func (*TxBase) GetBase

func (t *TxBase) GetBase() *TxBase

func (*TxBase) GetTransactionType

func (t *TxBase) GetTransactionType() TransactionType

func (*TxBase) GetType

func (t *TxBase) GetType() string

func (*TxBase) Hash

func (h *TxBase) Hash() Hash256

func (*TxBase) Raw

func (h *TxBase) Raw() []byte

func (*TxBase) SetHash

func (h *TxBase) SetHash(hash []byte)

func (*TxBase) SetRaw

func (h *TxBase) SetRaw(raw []byte)

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) Hash

func (h *Validation) Hash() Hash256

func (*Validation) Raw

func (h *Validation) Raw() []byte

func (*Validation) SetHash

func (h *Validation) SetHash(hash []byte)

func (*Validation) SetRaw

func (h *Validation) SetRaw(raw []byte)

func (*Validation) String

func (v *Validation) String() string

type Value

type Value struct {
	Native   bool
	Negative bool
	Num      uint64
	Offset   int64
}

func NewNativeValue

func NewNativeValue(n int64) (*Value, error)

NewNativeValue returns a Value with n drops. If the value is impossible an error is returned.

func NewValue

func NewValue(s string, native bool) (*Value, error)

func (Value) Abs

func (v Value) Abs() *Value

Abs returns a copy of v with a positive sign

func (Value) Add

func (a Value) Add(b Value) (*Value, error)

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) Bytes

func (v *Value) Bytes() []byte

func (Value) Clone

func (v Value) Clone() *Value

Clone returns a Value which is a copy of v.

func (Value) Compare

func (a Value) Compare(b Value) int

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) Divide

func (num Value) Divide(den Value) (*Value, error)

func (Value) Equals

func (a Value) Equals(b Value) bool

func (Value) IsScientific

func (v Value) IsScientific() bool

func (Value) IsZero

func (v Value) IsZero() bool

func (Value) Less

func (a Value) Less(b Value) bool

Less compares values and returns true if v is less than other

func (*Value) Marshal

func (v *Value) Marshal(w io.Writer) error

func (*Value) MarshalText

func (v *Value) MarshalText() ([]byte, error)

func (Value) Multiply

func (a Value) Multiply(b Value) (*Value, error)

func (Value) Negate

func (v Value) Negate() *Value

Negate returns a new Value with the opposite sign of v.

func (Value) String

func (v Value) String() string

func (Value) Subtract

func (a Value) Subtract(b Value) (*Value, error)

func (*Value) Unmarshal

func (v *Value) Unmarshal(r Reader) error

func (*Value) UnmarshalText

func (v *Value) UnmarshalText(b []byte) error

func (Value) ZeroClone

func (v Value) ZeroClone() *Value

ZeroClone returns a zero Value, native or non-native depending on v's setting.

type VariableLength

type VariableLength []byte

func (*VariableLength) Bytes

func (v *VariableLength) Bytes() []byte

func (*VariableLength) Marshal

func (v *VariableLength) Marshal(w io.Writer) error

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 Vector256

type Vector256 []Hash256

func (*Vector256) Marshal

func (v *Vector256) Marshal(w io.Writer) error

func (*Vector256) Unmarshal

func (v *Vector256) Unmarshal(r Reader) error

type Wire

type Wire interface {
	Unmarshal(Reader) error
	Marshal(io.Writer) error
}

type Work

type Work struct {
	*LedgerRange
	MissingLedgers LedgerSlice
	MissingNodes   []Hash256
}

Jump to

Keyboard shortcuts

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