Documentation ¶
Index ¶
- Constants
- Variables
- func Base58Decode(b, alphabet string) ([]byte, error)
- func Base58Encode(b []byte, alphabet string) string
- func CreateEmptyRawTransactionAndHash(from, pubkey string, destinationTag int64, sequence uint32, to string, ...) (string, string, error)
- func CreateTokenEmptyRawTransactionAndHash(from, pubkey string, destinationTag int64, sequence uint32, to string, ...) (string, string, error)
- func Decode(input string, alphabet *Alphabet) ([]byte, error)
- func Encode(input []byte, alphabet *Alphabet) string
- func GetProgramHashFromAddress(address string) ([]byte, error)
- func SignRawTransaction(hash string, prikey []byte) (string, error)
- func VerifyAndCombinRawTransaction(emptyTrans string, signature, publicKey string) (bool, string)
- type Account
- type Alphabet
- type Amount
- func (a Amount) Abs() *Amount
- func (a Amount) Add(b *Amount) (*Amount, error)
- func (a Amount) ApplyInterest() (*Amount, error)
- func (a Amount) Asset() *Asset
- 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) MarshalBinary() ([]byte, error)
- func (a Amount) Multiply(b *Amount) (*Amount, error)
- func (a Amount) Negate() *Amount
- func (a Amount) Ratio(b Amount) *Value
- 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) UnmarshalBinary(b []byte) error
- func (a Amount) ZeroClone() *Amount
- type Asset
- type Currency
- func (c *Currency) Bytes() []byte
- func (c Currency) Clone() Currency
- func (a Currency) Compare(b Currency) int
- 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) Rate(seconds uint32) float64
- func (c Currency) String() string
- func (c Currency) Type() CurrencyType
- func (c *Currency) Unmarshal(r Reader) error
- type CurrencyAmount
- type CurrencyType
- type ExchangeRate
- type Hash
- func AccountId(key Key, sequence *uint32) (Hash, error)
- func AccountPrivateKey(key Key, sequence *uint32) (Hash, error)
- func AccountPublicKey(key Key, sequence *uint32) (Hash, error)
- func NewAccountId(b []byte) (Hash, error)
- func NewAccountPrivateKey(b []byte) (Hash, error)
- func NewAccountPublicKey(b []byte) (Hash, error)
- func NewFamilySeed(b []byte) (Hash, error)
- func NewNodePrivateKey(b []byte) (Hash, error)
- func NewNodePublicKey(b []byte) (Hash, error)
- func NewRippleHash(s string) (Hash, error)
- func NewRippleHashCheck(s string, version HashVersion) (Hash, error)
- func NodePrivateKey(key Key) (Hash, error)
- func NodePublicKey(key Key) (Hash, error)
- type HashVersion
- type Key
- type LimitByteReader
- type Path
- type PathElem
- type PathSet
- type Reader
- type RippleTime
- type TxStruct
- 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) Float() float64
- func (v Value) IsNative() bool
- func (v Value) IsNegative() bool
- func (v Value) IsZero() bool
- func (a Value) Less(b Value) bool
- func (v *Value) Marshal(w io.Writer) error
- func (v Value) MarshalBinary() ([]byte, error)
- func (a Value) Multiply(b Value) (*Value, error)
- func (v Value) Native() (*Value, error)
- func (v Value) Negate() *Value
- func (v Value) NonNative() (*Value, error)
- func (v Value) Rat() *big.Rat
- func (a Value) Ratio(b Value) (*Value, error)
- func (v Value) String() string
- func (a Value) Subtract(b Value) (*Value, error)
- func (v *Value) Unmarshal(r Reader) error
- func (v *Value) UnmarshalBinary(b []byte) error
- func (v Value) ZeroClone() *Value
Constants ¶
const ( ACCOUNT_ZERO = "rrrrrrrrrrrrrrrrrrrrrhoLvTp" ACCOUNT_ONE = "rrrrrrrrrrrrrrrrrrrrBZbvji" NaN = "rrrrrrrrrrrrrrrrrrrn5RM1rHd" ROOT = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh" )
const ( PATH_BOUNDARY pathEntry = 0xFF PATH_END pathEntry = 0x00 PATH_ACCOUNT pathEntry = 0x01 PATH_REDEEM pathEntry = 0x02 PATH_CURRENCY pathEntry = 0x10 PATH_ISSUER pathEntry = 0x20 )
const ( AddressPrefix byte = 0x00 PAYMENT uint16 = 0x00 HP_TRANSACTION_SIGN uint32 = 0x53545800 TxCanonicalSignature uint32 = 0x80000000 // Payment flags TxNoDirectRipple uint32 = 0x00010000 TxPartialPayment uint32 = 0x00020000 TxLimitQuality uint32 = 0x00040000 TxCircle uint32 = 0x00080000 // Not implemented )
Variables ¶
var ( CurveOrder = []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41} HalfCurveOrder = []byte{0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5D, 0x57, 0x6E, 0x73, 0x57, 0xA4, 0x50, 0x1D, 0xDF, 0xE9, 0x2F, 0x46, 0x68, 0x1B, 0x20, 0xA0} )
var (
ErrorInvalidBase58String = errors.New("invalid base58 string")
)
Errors
var (
RippleAlphabet = NewAlphabet("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz")
)
Alphabet: copy from https://en.wikipedia.org/wiki/Base58
Functions ¶
func Base58Decode ¶ added in v1.0.11
Base58Decode decodes a modified base58 string to a byte slice and checks checksum.
func Base58Encode ¶ added in v1.0.11
Base58Encode encodes a byte slice to a modified base58 string.
func CreateTokenEmptyRawTransactionAndHash ¶ added in v1.0.11
Types ¶
type Account ¶ added in v1.0.11
type Account [20]byte
func NewAccountFromAddress ¶ added in v1.0.11
Expects address in base58 form
type Alphabet ¶
type Alphabet struct {
// contains filtered or unexported fields
}
Alphabet The base58 alphabet object.
func NewAlphabet ¶
NewAlphabet create a custom alphabet from 58-length string. Note: len(rune(alphabet)) must be 58.
type Amount ¶ added in v1.0.11
func (Amount) ApplyInterest ¶ added in v1.0.11
func (Amount) IsPositive ¶ added in v1.0.11
func (Amount) MarshalBinary ¶ added in v1.0.11
func (Amount) Ratio ¶ added in v1.0.11
Ratio returns the ratio between a and b. Returns a zero value when division is impossible
func (Amount) SameValue ¶ added in v1.0.11
Returns true if the values are equal, but ignores the currency and issuer
func (*Amount) UnmarshalBinary ¶ added in v1.0.11
type Currency ¶ added in v1.0.11
type Currency [20]byte
func NewCurrency ¶ added in v1.0.11
Accepts currency as either a 3 character code or a 40 character hex string
func (Currency) String ¶ added in v1.0.11
Currency in human parsable form Demurrage is formatted, for example, as XAU (0.50%pa)
func (Currency) Type ¶ added in v1.0.11
func (c Currency) Type() CurrencyType
type CurrencyAmount ¶ added in v1.0.11
type CurrencyType ¶ added in v1.0.11
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 ExchangeRate ¶ added in v1.0.11
type ExchangeRate uint64
func NewExchangeRate ¶ added in v1.0.11
func NewExchangeRate(a, b *Amount) (ExchangeRate, error)
func (*ExchangeRate) Bytes ¶ added in v1.0.11
func (e *ExchangeRate) Bytes() []byte
type Hash ¶ added in v1.0.11
type Hash interface { Version() HashVersion Payload() []byte PayloadTrimmed() []byte Value() *big.Int String() string Clone() Hash MarshalText() ([]byte, error) }
func AccountPrivateKey ¶ added in v1.0.11
func AccountPublicKey ¶ added in v1.0.11
func NewAccountId ¶ added in v1.0.11
func NewAccountPrivateKey ¶ added in v1.0.11
func NewAccountPublicKey ¶ added in v1.0.11
func NewFamilySeed ¶ added in v1.0.11
func NewNodePrivateKey ¶ added in v1.0.11
func NewNodePublicKey ¶ added in v1.0.11
func NewRippleHash ¶ added in v1.0.11
func NewRippleHashCheck ¶ added in v1.0.11
func NewRippleHashCheck(s string, version HashVersion) (Hash, error)
Checks hash matches expected version
func NodePrivateKey ¶ added in v1.0.11
func NodePublicKey ¶ added in v1.0.11
type HashVersion ¶ added in v1.0.11
type HashVersion byte
const ( ALPHABET = "rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz" RIPPLE_ACCOUNT_ID HashVersion = 0 RIPPLE_NODE_PUBLIC HashVersion = 28 RIPPLE_NODE_PRIVATE HashVersion = 32 RIPPLE_FAMILY_SEED HashVersion = 33 RIPPLE_ACCOUNT_PRIVATE HashVersion = 34 RIPPLE_ACCOUNT_PUBLIC HashVersion = 35 )
type LimitByteReader ¶ added in v1.0.11
func LimitedByteReader ¶ added in v1.0.11
func LimitedByteReader(r Reader, n int64) *LimitByteReader
func (*LimitByteReader) Len ¶ added in v1.0.11
func (l *LimitByteReader) Len() int
func (*LimitByteReader) Read ¶ added in v1.0.11
func (l *LimitByteReader) Read(p []byte) (n int, err error)
func (*LimitByteReader) ReadByte ¶ added in v1.0.11
func (l *LimitByteReader) ReadByte() (c byte, err error)
func (*LimitByteReader) UnreadByte ¶ added in v1.0.11
func (l *LimitByteReader) UnreadByte() error
type Path ¶ added in v1.0.11
type Path []PathElem
Path represents a single path of liquidity that a transaction may use.
type PathElem ¶ added in v1.0.11
PathElem represents one link in a path.
func (PathElem) MarshalJSON ¶ added in v1.0.11
type PathSet ¶ added in v1.0.11
type PathSet []Path
PathSet represents a collection of possible paths that a transaction may use.
type Reader ¶ added in v1.0.11
type Reader interface { io.ByteScanner io.Reader Len() int }
func NewVariableByteReader ¶ added in v1.0.11
type RippleTime ¶ added in v1.0.11
type RippleTime struct {
T uint32
}
Represents a time as the number of seconds since the Ripple epoch: January 1st, 2000 (00:00 UTC)
func NewRippleTime ¶ added in v1.0.11
func NewRippleTime(t uint32) *RippleTime
func Now ¶ added in v1.0.11
func Now() *RippleTime
func (*RippleTime) SetString ¶ added in v1.0.11
func (t *RippleTime) SetString(s string) error
Accepts time formatted as 2006-Jan-02 15:04:05
func (*RippleTime) SetUint32 ¶ added in v1.0.11
func (t *RippleTime) SetUint32(n uint32)
func (RippleTime) Short ¶ added in v1.0.11
func (t RippleTime) Short() string
Returns time formatted as 15:04:05
func (RippleTime) String ¶ added in v1.0.11
func (t RippleTime) String() string
Returns time formatted as 2006-Jan-02 15:04:05
func (RippleTime) Time ¶ added in v1.0.11
func (t RippleTime) Time() time.Time
func (RippleTime) Uint32 ¶ added in v1.0.11
func (t RippleTime) Uint32() uint32
type TxStruct ¶
type TxStruct struct { TransactionType []byte Flags []byte Sequence []byte LastLedgerSequence []byte Amount []byte Fee []byte SigningPubKey []byte TxnSignature []byte Account []byte Destination []byte DestinationTag []byte Memos []byte Paths []byte SendMax []byte //如果SendMax交易指令中省略了该字段,则认为它等于Amount }
func NewTxStruct ¶
func (TxStruct) ToEmptyRawWiths ¶
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is the numeric type in Ripple. It can store numbers in two different representations: native and non-native. Non-native numbers are stored as a mantissa (Num) in the range [1e15,1e16) plus an exponent (Offset) in the range [-96,80]. Native values are stored as an integer number of "drips" each representing 1/1000000. Throughout the library, native values are interpreted as drips unless otherwise specified.
func NewNativeValue ¶ added in v1.0.11
NewNativeValue returns a Value with n drops. If the value is impossible an error is returned.
func NewNonNativeValue ¶ added in v1.0.11
NewNonNativeValue returns a Value of n*10^offset.
func NewValue ¶ added in v1.0.11
NewValue accepts a string representation of a value and a flag to indicate if it should be stored as native. If the native flag is set AND a decimal is used, the number is interpreted as XRP. If no decimal is used, it is interpreted as drips.
func (Value) Compare ¶ added in v1.0.11
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) IsNegative ¶ added in v1.0.11
func (Value) MarshalBinary ¶ added in v1.0.11
func (Value) NonNative ¶ added in v1.0.11
NonNative returns a clone of the value in non-native format.
func (Value) Ratio ¶ added in v1.0.11
Ratio returns the ratio a/b. XRP are interpreted at face value rather than drips. The result of Ratio is always a non-native Value for additional precision.
func (Value) String ¶ added in v1.0.11
String returns the Value as a string for human consumption. Native values are represented as decimal XRP rather than drips.