Documentation ¶
Overview ¶
Package field implements fast arithmetic modulo 2^255-19.
Index ¶
- Constants
- Variables
- func DecodeCompactU16Length(bytes []byte) int
- func DecodeCompactU16LengthFromByteReader(reader io.ByteReader) (int, error)
- func EncodeCompactU16Length(bytes *[]byte, ln int)
- func GetAddedRemovedPubkeys(previous PublicKeySlice, next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
- func IsOnCurve(b []byte) bool
- func ReverseBytes(s []byte)
- func Uint32FromTypeID(vid TypeID, order binary.ByteOrder) (out uint32)
- func Uint8FromTypeID(vid TypeID) (out uint8)
- type AccountMeta
- type AccountMetaSlice
- func (slice *AccountMetaSlice) Append(account *AccountMeta)
- func (slice AccountMetaSlice) Get(index int) *AccountMeta
- func (slice AccountMetaSlice) GetAccounts() []*AccountMeta
- func (slice AccountMetaSlice) GetKeys() PublicKeySlice
- func (slice AccountMetaSlice) GetSigners() []*AccountMeta
- func (slice AccountMetaSlice) Len() int
- func (slice *AccountMetaSlice) SetAccounts(accounts []*AccountMeta) error
- func (slice AccountMetaSlice) SplitFrom(index int) (AccountMetaSlice, AccountMetaSlice)
- type AccountsGettable
- type AccountsSettable
- type Base58
- type BaseVariant
- type BinaryMarshaler
- type BinaryUnmarshaler
- type CompiledInstruction
- type Decoder
- func (dec *Decoder) Decode(v interface{}) (err error)
- func (dec *Decoder) Discard(n int) (err error)
- func (dec *Decoder) HasRemaining() bool
- func (dec *Decoder) IsBin() bool
- func (dec *Decoder) IsBorsh() bool
- func (dec *Decoder) IsCompactU16() bool
- func (dec *Decoder) Peek(n int) (out []byte, err error)
- func (dec *Decoder) Position() uint
- func (d *Decoder) Read(buf []byte) (int, error)
- func (dec *Decoder) ReadBool() (out bool, err error)
- func (dec *Decoder) ReadByte() (out byte, err error)
- func (dec *Decoder) ReadByteSlice() (out []byte, err error)
- func (dec *Decoder) ReadBytes(n int) (out []byte, err error)
- func (dec *Decoder) ReadCompactU16() (out int, err error)
- func (dec *Decoder) ReadCompactU16Length() (int, error)
- func (dec *Decoder) ReadFloat128(order binary.ByteOrder) (out Float128, err error)
- func (dec *Decoder) ReadFloat32(order binary.ByteOrder) (out float32, err error)
- func (dec *Decoder) ReadFloat64(order binary.ByteOrder) (out float64, err error)
- func (dec *Decoder) ReadInt128(order binary.ByteOrder) (out Int128, err error)
- func (dec *Decoder) ReadInt16(order binary.ByteOrder) (out int16, err error)
- func (dec *Decoder) ReadInt32(order binary.ByteOrder) (out int32, err error)
- func (dec *Decoder) ReadInt64(order binary.ByteOrder) (out int64, err error)
- func (dec *Decoder) ReadInt8() (out int8, err error)
- func (dec *Decoder) ReadLength() (length int, err error)
- func (dec *Decoder) ReadNBytes(n int) (out []byte, err error)
- func (dec *Decoder) ReadRustString() (out string, err error)
- func (dec *Decoder) ReadString() (out string, err error)
- func (dec *Decoder) ReadTypeID() (out TypeID, err error)
- func (dec *Decoder) ReadUint128(order binary.ByteOrder) (out Uint128, err error)
- func (dec *Decoder) ReadUint16(order binary.ByteOrder) (out uint16, err error)
- func (dec *Decoder) ReadUint32(order binary.ByteOrder) (out uint32, err error)
- func (dec *Decoder) ReadUint64(order binary.ByteOrder) (out uint64, err error)
- func (dec *Decoder) ReadUint8() (out uint8, err error)
- func (dec *Decoder) ReadUvarint16() (out uint16, err error)
- func (dec *Decoder) ReadUvarint32() (out uint32, err error)
- func (dec *Decoder) ReadUvarint64() (uint64, error)
- func (dec *Decoder) ReadVarint16() (out int16, err error)
- func (dec *Decoder) ReadVarint32() (out int32, err error)
- func (d *Decoder) ReadVarint64() (out int64, err error)
- func (dec *Decoder) Remaining() int
- func (dec *Decoder) Reset(data []byte)
- func (dec *Decoder) SafeReadUTF8String() (out string, err error)
- func (dec *Decoder) SetEncoding(enc Encoding)
- func (dec *Decoder) SetPosition(idx uint) error
- func (dec *Decoder) SkipBytes(count uint) error
- type Element
- func (v *Element) Absolute(u *Element) *Element
- func (v *Element) Add(a, b *Element) *Element
- func (v *Element) Bytes() []byte
- func (v *Element) Equal(u *Element) int
- func (v *Element) Invert(z *Element) *Element
- func (v *Element) IsNegative() int
- func (v *Element) Mult32(x *Element, y uint32) *Element
- func (v *Element) Multiply(x, y *Element) *Element
- func (v *Element) Negate(a *Element) *Element
- func (v *Element) One() *Element
- func (v *Element) Pow22523(x *Element) *Element
- func (v *Element) Select(a, b *Element, cond int) *Element
- func (v *Element) Set(a *Element) *Element
- func (v *Element) SetBytes(x []byte) (*Element, error)
- func (r *Element) SqrtRatio(u, v *Element) (R *Element, wasSquare int)
- func (v *Element) Square(x *Element) *Element
- func (v *Element) Subtract(a, b *Element) *Element
- func (v *Element) Swap(u *Element, cond int)
- func (v *Element) Zero() *Element
- type Encoder
- func (e *Encoder) Encode(v interface{}) (err error)
- func (e *Encoder) WriteBool(b bool) (err error)
- func (e *Encoder) WriteByte(b byte) (err error)
- func (e *Encoder) WriteBytes(b []byte, writeLength bool) error
- func (e *Encoder) WriteCompactU16Length(ln int) (err error)
- func (e *Encoder) WriteFloat32(f float32, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteFloat64(f float64, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt128(i Int128, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt16(i int16, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt32(i int32, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteInt64(i int64, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteLength(length int) error
- func (e *Encoder) WriteRustString(s string) (err error)
- func (e *Encoder) WriteString(s string) (err error)
- func (e *Encoder) WriteUVarInt(v int) (err error)
- func (e *Encoder) WriteUint128(i Uint128, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint16(i uint16, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint32(i uint32, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint64(i uint64, order binary.ByteOrder) (err error)
- func (e *Encoder) WriteUint8(i uint8) (err error)
- func (e *Encoder) WriteVarInt(v int) (err error)
- func (e *Encoder) Written() int
- type Encoding
- type Float128
- type Hash
- type Instruction
- type Int128
- func (i Int128) BigInt() *big.Int
- func (i Int128) DecimalString() string
- func (i Int128) MarshalJSON() (data []byte, err error)
- func (i Int128) MarshalWithEncoder(enc *Encoder) error
- func (i Int128) String() string
- func (i *Int128) UnmarshalJSON(data []byte) error
- func (i *Int128) UnmarshalWithDecoder(dec *Decoder) error
- type InvalidDecoderError
- type Message
- func (m *Message) IsSigner(account PublicKey) bool
- func (m *Message) IsWritable(account PublicKey) bool
- func (mx *Message) MarshalBinary() ([]byte, error)
- func (m *Message) Signers() PublicKeySlice
- func (mx *Message) UnmarshalBase64(b64 string) error
- func (mx *Message) UnmarshalLegacy(decoder *Decoder) (err error)
- func (mx *Message) UnmarshalV0(decoder *Decoder) (err error)
- func (mx *Message) UnmarshalWithDecoder(decoder *Decoder) (err error)
- func (m *Message) Writable() (out PublicKeySlice)
- type MessageAddressTableLookup
- type MessageAddressTableLookupSlice
- type MessageHeader
- type MessageVersion
- type Point
- type PrivateKey
- type PublicKey
- func CreateProgramAddress(seeds [][]byte, programID PublicKey) (PublicKey, error)
- func FindAssociatedTokenAddress(wallet PublicKey, mint PublicKey) (PublicKey, uint8, error)
- func FindProgramAddress(seed [][]byte, programID PublicKey) (PublicKey, uint8, error)
- func MustPublicKeyFromBase58(in string) PublicKey
- func PublicKeyFromBase58(in string) (out PublicKey, err error)
- func PublicKeyFromBytes(in []byte) (out PublicKey)
- func (p PublicKey) Bytes() []byte
- func (p PublicKey) Equals(pb PublicKey) bool
- func (p PublicKey) IsZero() bool
- func (p PublicKey) MarshalText() ([]byte, error)
- func (p PublicKey) Short(n int) string
- func (p PublicKey) String() string
- func (p PublicKey) ToPointer() *PublicKey
- func (p *PublicKey) UnmarshalText(data []byte) (err error)
- type PublicKeySlice
- type Signature
- type Transaction
- func (tx *Transaction) MarshalBinary() ([]byte, error)
- func (tx *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
- func (tx Transaction) ToBase58() (string, error)
- func (tx Transaction) ToBase64() (string, error)
- func (tx *Transaction) UnmarshalBase58(b58 string) error
- func (tx *Transaction) UnmarshalBase64(b64 string) error
- func (tx *Transaction) UnmarshalWithDecoder(decoder *Decoder) (err error)
- type TypeID
- type Uint128
- func (i Uint128) BigInt() *big.Int
- func (i Uint128) Bytes() []byte
- func (i Uint128) DecimalString() string
- func (i Uint128) HexString() string
- func (i Uint128) MarshalJSON() (data []byte, err error)
- func (i Uint128) MarshalWithEncoder(enc *Encoder) error
- func (i Uint128) String() string
- func (i *Uint128) UnmarshalJSON(data []byte) error
- func (i *Uint128) UnmarshalWithDecoder(dec *Decoder) error
Constants ¶
const ( /// Number of bytes in a pubkey. PublicKeyLength = 32 // Maximum length of derived pubkey seed. MaxSeedLength = 32 // Maximum number of seeds. MaxSeeds = 16 /// Number of bytes in a signature. SignatureLength = 64 )
const PDA_MARKER = "ProgramDerivedAddress"
Variables ¶
var ( // Create new accounts, allocate account data, assign accounts to owning programs, // transfer lamports from System Program owned accounts and pay transacation fees. SystemProgramID = MustPublicKeyFromBase58("11111111111111111111111111111111") // Add configuration data to the chain and the list of public keys that are permitted to modify it. ConfigProgramID = MustPublicKeyFromBase58("Config1111111111111111111111111111111111111") // Create and manage accounts representing stake and rewards for delegations to validators. StakeProgramID = MustPublicKeyFromBase58("Stake11111111111111111111111111111111111111") // Create and manage accounts that track validator voting state and rewards. VoteProgramID = MustPublicKeyFromBase58("Vote111111111111111111111111111111111111111") BPFLoaderDeprecatedProgramID = MustPublicKeyFromBase58("BPFLoader1111111111111111111111111111111111") // Deploys, upgrades, and executes programs on the chain. BPFLoaderProgramID = MustPublicKeyFromBase58("BPFLoader2111111111111111111111111111111111") BPFLoaderUpgradeableProgramID = MustPublicKeyFromBase58("BPFLoaderUpgradeab1e11111111111111111111111") // Verify secp256k1 public key recovery operations (ecrecover). Secp256k1ProgramID = MustPublicKeyFromBase58("KeccakSecp256k11111111111111111111111111111") FeatureProgramID = MustPublicKeyFromBase58("Feature111111111111111111111111111111111111") )
var ( // A Token program on the Solana blockchain. // This program defines a common implementation for Fungible and Non Fungible tokens. TokenProgramID = MustPublicKeyFromBase58("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA") // A Uniswap-like exchange for the Token program on the Solana blockchain, // implementing multiple automated market maker (AMM) curves. TokenSwapProgramID = MustPublicKeyFromBase58("SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8") TokenSwapFeeOwner = MustPublicKeyFromBase58("HfoTxFR1Tm6kGmWgYWD6J7YHVy1UwqSULUGVLXkJqaKN") // A lending protocol for the Token program on the Solana blockchain inspired by Aave and Compound. TokenLendingProgramID = MustPublicKeyFromBase58("LendZqTs8gn5CTSJU1jWKhKuVpjJGom45nnwPb2AMTi") // This program defines the convention and provides the mechanism for mapping // the user's wallet address to the associated token accounts they hold. SPLAssociatedTokenAccountProgramID = MustPublicKeyFromBase58("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL") // The Memo program is a simple program that validates a string of UTF-8 encoded characters // and verifies that any accounts provided are signers of the transaction. // The program also logs the memo, as well as any verified signer addresses, // to the transaction log, so that anyone can easily observe memos // and know they were approved by zero or more addresses // by inspecting the transaction log from a trusted provider. MemoProgramID = MustPublicKeyFromBase58("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr") )
SPL:
var ( // The Mint for native SOL Token accounts SolMint = MustPublicKeyFromBase58("So11111111111111111111111111111111111111112") WrappedSol = SolMint )
var ( // The Clock sysvar contains data on cluster time, // including the current slot, epoch, and estimated wall-clock Unix timestamp. // It is updated every slot. SysVarClockPubkey = MustPublicKeyFromBase58("SysvarC1ock11111111111111111111111111111111") // The EpochSchedule sysvar contains epoch scheduling constants that are set in genesis, // and enables calculating the number of slots in a given epoch, // the epoch for a given slot, etc. // (Note: the epoch schedule is distinct from the leader schedule) SysVarEpochSchedulePubkey = MustPublicKeyFromBase58("SysvarEpochSchedu1e111111111111111111111111") // The Fees sysvar contains the fee calculator for the current slot. // It is updated every slot, based on the fee-rate governor. SysVarFeesPubkey = MustPublicKeyFromBase58("SysvarFees111111111111111111111111111111111") // The Instructions sysvar contains the serialized instructions in a Message while that Message is being processed. // This allows program instructions to reference other instructions in the same transaction. SysVarInstructionsPubkey = MustPublicKeyFromBase58("Sysvar1nstructions1111111111111111111111111") // The RecentBlockhashes sysvar contains the active recent blockhashes as well as their associated fee calculators. // It is updated every slot. // Entries are ordered by descending block height, // so the first entry holds the most recent block hash, // and the last entry holds an old block hash. SysVarRecentBlockHashesPubkey = MustPublicKeyFromBase58("SysvarRecentB1ockHashes11111111111111111111") // The Rent sysvar contains the rental rate. // Currently, the rate is static and set in genesis. // The Rent burn percentage is modified by manual feature activation. SysVarRentPubkey = MustPublicKeyFromBase58("SysvarRent111111111111111111111111111111111") // SysVarRewardsPubkey = MustPublicKeyFromBase58("SysvarRewards111111111111111111111111111111") // The SlotHashes sysvar contains the most recent hashes of the slot's parent banks. // It is updated every slot. SysVarSlotHashesPubkey = MustPublicKeyFromBase58("SysvarS1otHashes111111111111111111111111111") // The SlotHistory sysvar contains a bitvector of slots present over the last epoch. It is updated every slot. SysVarSlotHistoryPubkey = MustPublicKeyFromBase58("SysvarS1otHistory11111111111111111111111111") // The StakeHistory sysvar contains the history of cluster-wide stake activations and de-activations per epoch. // It is updated at the start of every epoch. SysVarStakeHistoryPubkey = MustPublicKeyFromBase58("SysvarStakeHistory1111111111111111111111111") )
var ( MetaplexCandyMachineV2ProgramID = MustPublicKeyFromBase58("cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ") MetaplexTokenMetadataProgramID = MustPublicKeyFromBase58("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s") )
var BE binary.ByteOrder = binary.BigEndian
var ErrMaxSeedLengthExceeded = errors.New("Max seed length exceeded")
var ErrVarIntBufferSize = errors.New("varint: invalid buffer size")
var LE binary.ByteOrder = binary.LittleEndian
var NoTypeIDDefaultID = TypeIDFromUint8(0)
var (
TokenMetadataProgramID = MustPublicKeyFromBase58("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s")
)
var TypeSize = struct { Bool int Byte int Int8 int Int16 int Uint8 int Uint16 int Uint32 int Uint64 int Uint128 int Float32 int Float64 int PublicKey int Signature int Tstamp int BlockTimestamp int CurrencyName int }{ Byte: 1, Bool: 1, Int8: 1, Int16: 2, Uint8: 1, Uint16: 2, Uint32: 4, Uint64: 8, Uint128: 16, Float32: 4, Float64: 8, }
Functions ¶
func DecodeCompactU16Length ¶
DecodeCompactU16Length decodes a "Compact-u16" length from the provided byte slice.
func DecodeCompactU16LengthFromByteReader ¶
func DecodeCompactU16LengthFromByteReader(reader io.ByteReader) (int, error)
DecodeCompactU16LengthFromByteReader decodes a "Compact-u16" length from the provided io.ByteReader.
func EncodeCompactU16Length ¶
func GetAddedRemovedPubkeys ¶
func GetAddedRemovedPubkeys(previous PublicKeySlice, next PublicKeySlice) (added PublicKeySlice, removed PublicKeySlice)
GetAddedRemovedPubkeys accepts two slices of pubkeys (`previous` and `next`), and returns two slices: - `added` is the slice of pubkeys that are present in `next` but NOT present in `previous`. - `removed` is the slice of pubkeys that are present in `previous` but are NOT present in `next`.
func ReverseBytes ¶
func ReverseBytes(s []byte)
func Uint32FromTypeID ¶
Uint32FromTypeID parses a TypeID bytes to a uint32.
func Uint8FromTypeID ¶
Uint32FromTypeID parses a TypeID bytes to a uint8.
Types ¶
type AccountMeta ¶
func Meta ¶
func Meta( pubKey PublicKey, ) *AccountMeta
Meta intializes a new AccountMeta with the provided pubKey.
func NewAccountMeta ¶
func NewAccountMeta( pubKey PublicKey, WRITE bool, SIGNER bool, ) *AccountMeta
func (*AccountMeta) SIGNER ¶
func (meta *AccountMeta) SIGNER() *AccountMeta
SIGNER sets IsSigner to true.
func (*AccountMeta) WRITE ¶
func (meta *AccountMeta) WRITE() *AccountMeta
WRITE sets IsWritable to true.
type AccountMetaSlice ¶
type AccountMetaSlice []*AccountMeta
func (*AccountMetaSlice) Append ¶
func (slice *AccountMetaSlice) Append(account *AccountMeta)
func (AccountMetaSlice) Get ¶
func (slice AccountMetaSlice) Get(index int) *AccountMeta
Get returns the AccountMeta at the desired index. If the index is not present, it returns nil.
func (AccountMetaSlice) GetAccounts ¶
func (slice AccountMetaSlice) GetAccounts() []*AccountMeta
func (AccountMetaSlice) GetKeys ¶
func (slice AccountMetaSlice) GetKeys() PublicKeySlice
GetKeys returns the pubkeys of all AccountMeta.
func (AccountMetaSlice) GetSigners ¶
func (slice AccountMetaSlice) GetSigners() []*AccountMeta
GetSigners returns the accounts that are signers.
func (AccountMetaSlice) Len ¶
func (slice AccountMetaSlice) Len() int
func (*AccountMetaSlice) SetAccounts ¶
func (slice *AccountMetaSlice) SetAccounts(accounts []*AccountMeta) error
func (AccountMetaSlice) SplitFrom ¶
func (slice AccountMetaSlice) SplitFrom(index int) (AccountMetaSlice, AccountMetaSlice)
type AccountsGettable ¶
type AccountsGettable interface {
GetAccounts() (accounts []*AccountMeta)
}
type AccountsSettable ¶
type AccountsSettable interface {
SetAccounts(accounts []*AccountMeta) error
}
type BaseVariant ¶
type BaseVariant struct { TypeID TypeID Impl interface{} }
type BinaryMarshaler ¶
type BinaryUnmarshaler ¶
type CompiledInstruction ¶
type CompiledInstruction struct { // Index into the message.accountKeys array indicating the program account that executes this instruction. // NOTE: it is actually a uint8, but using a uint16 because uint8 is treated as a byte everywhere, // and that can be an issue. ProgramIDIndex uint16 `json:"programIdIndex"` // List of ordered indices into the message.accountKeys array indicating which accounts to pass to the program. // NOTE: it is actually a []uint8, but using a uint16 because []uint8 is treated as a []byte everywhere, // and that can be an issue. Accounts []uint16 `json:"accounts"` // The program input data encoded in a base-58 string. Data Base58 `json:"data"` }
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder implements the EOS unpacking, similar to FC_BUFFER
func NewBinDecoder ¶
func NewDecoderWithEncoding ¶
func (*Decoder) HasRemaining ¶
func (*Decoder) IsCompactU16 ¶
func (*Decoder) ReadByteSlice ¶
func (*Decoder) ReadCompactU16 ¶
ReadCompactU16 reads a compact u16 from the decoder.
func (*Decoder) ReadCompactU16Length ¶
func (*Decoder) ReadFloat128 ¶
func (*Decoder) ReadFloat32 ¶
func (*Decoder) ReadFloat64 ¶
func (*Decoder) ReadInt128 ¶
func (*Decoder) ReadLength ¶
func (*Decoder) ReadRustString ¶
func (*Decoder) ReadString ¶
func (*Decoder) ReadTypeID ¶
func (*Decoder) ReadUint128 ¶
func (*Decoder) ReadUint16 ¶
func (*Decoder) ReadUint32 ¶
func (*Decoder) ReadUint64 ¶
func (*Decoder) ReadUvarint16 ¶
func (*Decoder) ReadUvarint32 ¶
func (*Decoder) ReadUvarint64 ¶
func (*Decoder) ReadVarint16 ¶
func (*Decoder) ReadVarint32 ¶
func (*Decoder) ReadVarint64 ¶
func (*Decoder) SafeReadUTF8String ¶
func (*Decoder) SetEncoding ¶
SetEncoding sets the encoding scheme to use for decoding.
func (*Decoder) SetPosition ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
Element represents an element of the field GF(2^255-19). Note that this is not a cryptographically secure group, and should only be used to interact with edwards25519.Point coordinates.
This type works similarly to math/big.Int, and all arguments and receivers are allowed to alias.
The zero value is a valid zero element.
func (*Element) IsNegative ¶
IsNegative returns 1 if v is negative, and 0 otherwise.
func (*Element) SetBytes ¶
SetBytes sets v to x, where x is a 32-byte little-endian encoding. If x is not of the right length, SetBytes returns nil and an error, and the receiver is unchanged.
Consistent with RFC 7748, the most significant bit (the high bit of the last byte) is ignored, and non-canonical values (2^255-19 through 2^255-1) are accepted. Note that this is laxer than specified by RFC 8032, but consistent with most Ed25519 implementations.
func (*Element) SqrtRatio ¶
SqrtRatio sets r to the non-negative square root of the ratio of u and v.
If u/v is square, SqrtRatio returns r and 1. If u/v is not square, SqrtRatio sets r according to Section 4.3 of draft-irtf-cfrg-ristretto255-decaf448-00, and returns r and 0.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
func NewBinEncoder ¶
func (*Encoder) WriteCompactU16Length ¶
func (*Encoder) WriteFloat32 ¶
func (*Encoder) WriteFloat64 ¶
func (*Encoder) WriteInt128 ¶
func (*Encoder) WriteInt16 ¶
func (*Encoder) WriteInt32 ¶
func (*Encoder) WriteInt64 ¶
func (*Encoder) WriteLength ¶
func (*Encoder) WriteRustString ¶
func (*Encoder) WriteString ¶
func (*Encoder) WriteUVarInt ¶
func (*Encoder) WriteUint128 ¶
func (*Encoder) WriteUint16 ¶
func (*Encoder) WriteUint32 ¶
func (*Encoder) WriteUint64 ¶
func (*Encoder) WriteUint8 ¶
func (*Encoder) WriteVarInt ¶
type Float128 ¶
type Float128 Uint128
func (Float128) MarshalJSON ¶
func (Float128) MarshalWithEncoder ¶
func (*Float128) UnmarshalJSON ¶
func (*Float128) UnmarshalWithDecoder ¶
type Instruction ¶
type Instruction interface { ProgramID() PublicKey // the programID the instruction acts on Accounts() []*AccountMeta // returns the list of accounts the instructions requires Data() ([]byte, error) // the binary encoded instructions }
type Int128 ¶
type Int128 Uint128
Int128
func (Int128) DecimalString ¶
func (Int128) MarshalJSON ¶
func (Int128) MarshalWithEncoder ¶
func (*Int128) UnmarshalJSON ¶
func (*Int128) UnmarshalWithDecoder ¶
type InvalidDecoderError ¶
An InvalidDecoderError describes an invalid argument passed to Decoder. (The argument to Decoder must be a non-nil pointer.)
func (*InvalidDecoderError) Error ¶
func (e *InvalidDecoderError) Error() string
type Message ¶
type Message struct { // List of base-58 encoded public keys used by the transaction, // including by the instructions and for signatures. // The first `message.header.numRequiredSignatures` public keys must sign the transaction. AccountKeys []PublicKey `json:"accountKeys"` // Details the account types and signatures required by the transaction. Header MessageHeader `json:"header"` // A base-58 encoded hash of a recent block in the ledger used to // prevent transaction duplication and to give transactions lifetimes. RecentBlockhash Hash `json:"recentBlockhash"` // List of program instructions that will be executed in sequence // and committed in one atomic transaction if all succeed. Instructions []CompiledInstruction `json:"instructions"` // contains filtered or unexported fields }
func (*Message) IsWritable ¶
func (*Message) MarshalBinary ¶
func (*Message) Signers ¶
func (m *Message) Signers() PublicKeySlice
Signers returns the pubkeys of all accounts that are signers.
func (*Message) UnmarshalBase64 ¶
func (*Message) UnmarshalLegacy ¶
func (*Message) UnmarshalV0 ¶
func (*Message) UnmarshalWithDecoder ¶
func (*Message) Writable ¶
func (m *Message) Writable() (out PublicKeySlice)
Writable returns the pubkeys of all accounts that are writable.
type MessageAddressTableLookupSlice ¶
type MessageAddressTableLookupSlice []MessageAddressTableLookup
func (MessageAddressTableLookupSlice) GetTableIDs ¶
func (lookups MessageAddressTableLookupSlice) GetTableIDs() PublicKeySlice
GetTableIDs returns the list of all address table IDs.
func (MessageAddressTableLookupSlice) NumLookups ¶
func (lookups MessageAddressTableLookupSlice) NumLookups() int
NumLookups returns the number of accounts in all the MessageAddressTableLookupSlice
type MessageHeader ¶
type MessageHeader struct { // The total number of signatures required to make the transaction valid. // The signatures must match the first `numRequiredSignatures` of `message.account_keys`. NumRequiredSignatures uint8 `json:"numRequiredSignatures"` // The last numReadonlySignedAccounts of the signed keys are read-only accounts. // Programs may process multiple transactions that load read-only accounts within // a single PoH entry, but are not permitted to credit or debit lamports or modify // account data. // Transactions targeting the same read-write account are evaluated sequentially. NumReadonlySignedAccounts uint8 `json:"numReadonlySignedAccounts"` // The last `numReadonlyUnsignedAccounts` of the unsigned keys are read-only accounts. NumReadonlyUnsignedAccounts uint8 `json:"numReadonlyUnsignedAccounts"` }
type MessageVersion ¶
type MessageVersion int
const ( MessageVersionLegacy MessageVersion = 0 // default MessageVersionV0 MessageVersion = 1 // v0 )
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point represents a point on the edwards25519 curve.
This type works similarly to math/big.Int, and all arguments and receivers are allowed to alias.
The zero value is NOT valid, and it may be used only as a receiver.
func (*Point) SetBytes ¶
SetBytes sets v = x, where x is a 32-byte encoding of v. If x does not represent a valid point on the curve, SetBytes returns nil and an error and the receiver is unchanged. Otherwise, SetBytes returns v.
Note that SetBytes accepts all non-canonical encodings of valid points. That is, it follows decoding rules that match most implementations in the ecosystem rather than RFC 8032.
type PrivateKey ¶
type PrivateKey []byte
func MustPrivateKeyFromBase58 ¶
func MustPrivateKeyFromBase58(in string) PrivateKey
func NewRandomPrivateKey ¶
func NewRandomPrivateKey() (PrivateKey, error)
func PrivateKeyFromBase58 ¶
func PrivateKeyFromBase58(privkey string) (PrivateKey, error)
func (PrivateKey) Bytes ¶
func (p PrivateKey) Bytes() []byte
func (PrivateKey) PublicKey ¶
func (k PrivateKey) PublicKey() PublicKey
func (PrivateKey) String ¶
func (k PrivateKey) String() string
type PublicKey ¶
type PublicKey [PublicKeyLength]byte
func CreateProgramAddress ¶
Create a program address. Ported from https://github.com/solana-labs/solana/blob/216983c50e0a618facc39aa07472ba6d23f1b33a/sdk/program/src/pubkey.rs#L204
func FindProgramAddress ¶
Find a valid program address and its corresponding bump seed.
func MustPublicKeyFromBase58 ¶
func PublicKeyFromBase58 ¶
func PublicKeyFromBytes ¶
func (PublicKey) IsZero ¶
IsZero returns whether the public key is zero. NOTE: the System Program public key is also zero.
func (PublicKey) MarshalText ¶
func (PublicKey) Short ¶
Short returns a shortened pubkey string, only including the first n chars, ellipsis, and the last n characters. NOTE: this is ONLY for visual representation for humans, and cannot be used for anything else.
func (*PublicKey) UnmarshalText ¶
type PublicKeySlice ¶
type PublicKeySlice []PublicKey
func (*PublicKeySlice) Append ¶
func (slice *PublicKeySlice) Append(pubkeys ...PublicKey)
func (PublicKeySlice) Has ¶
func (slice PublicKeySlice) Has(pubkey PublicKey) bool
func (PublicKeySlice) Split ¶
func (slice PublicKeySlice) Split(chunkSize int) []PublicKeySlice
Split splits the slice into chunks of the specified size.
func (*PublicKeySlice) UniqueAppend ¶
func (slice *PublicKeySlice) UniqueAppend(pubkey PublicKey) bool
UniqueAppend appends the provided pubkey only if it is not already present in the slice. Returns true when the provided pubkey wasn't already present.
type Transaction ¶
type Transaction struct { // A list of base-58 encoded signatures applied to the transaction. // The list is always of length `message.header.numRequiredSignatures` and not empty. // The signature at index `i` corresponds to the public key at index // `i` in `message.account_keys`. The first one is used as the transaction id. Signatures []Signature `json:"signatures"` // Defines the content of the transaction. Message Message `json:"message"` }
func NewTransaction ¶
func NewTransaction(instructions []Instruction, recentBlockHash Hash, payer PublicKey) (*Transaction, error)
func (*Transaction) MarshalBinary ¶
func (tx *Transaction) MarshalBinary() ([]byte, error)
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
func (Transaction) ToBase58 ¶
func (tx Transaction) ToBase58() (string, error)
func (Transaction) ToBase64 ¶
func (tx Transaction) ToBase64() (string, error)
func (*Transaction) UnmarshalBase58 ¶
func (tx *Transaction) UnmarshalBase58(b58 string) error
UnmarshalBase58 decodes a base58 encoded transaction.
func (*Transaction) UnmarshalBase64 ¶
func (tx *Transaction) UnmarshalBase64(b64 string) error
UnmarshalBase64 decodes a base64 encoded transaction.
func (*Transaction) UnmarshalWithDecoder ¶
func (tx *Transaction) UnmarshalWithDecoder(decoder *Decoder) (err error)
type TypeID ¶
type TypeID [8]byte
TypeID defines the internal representation of an instruction type ID (or account type, etc. in anchor programs) and it's used to associate instructions to decoders in the variant tracker.
func TypeIDFromBytes ¶
TypeIDFromBytes converts a []byte to a TypeID. The provided slice must be 8 bytes long or less.
func TypeIDFromUint32 ¶
TypeIDFromUint32 converts a uint32 to a TypeID.
func TypeIDFromUint8 ¶
TypeIDFromUint32 converts a uint8 to a TypeID.
type Uint128 ¶
Uint128
func NewUint128BigEndian ¶
func NewUint128BigEndian() *Uint128
func NewUint128LittleEndian ¶
func NewUint128LittleEndian() *Uint128