Documentation ¶
Index ¶
- Variables
- func DecimalsInBigInt(decimal uint32) *big.Int
- func DecodeInstruction(programID PublicKey, accounts []*AccountMeta, data []byte) (interface{}, error)
- func NewRandomPrivateKey() (PublicKey, PrivateKey, error)
- func RegisterInstructionDecoder(programID PublicKey, decoder InstructionDecoder)
- type Account
- type AccountMeta
- type AccountSettable
- type Base58
- type ByteWrapper
- type CompiledInstruction
- type Data
- type EncodingType
- type Hash
- type Instruction
- type InstructionDecoder
- type Message
- type MessageHeader
- type Padding
- type PrivateKey
- type PublicKey
- type Signature
- type Transaction
- func (t *Transaction) AccountMetaList() (out []*AccountMeta)
- func (t *Transaction) IsSigner(account PublicKey) bool
- func (t *Transaction) IsWritable(account PublicKey) bool
- func (t *Transaction) ResolveProgramIDIndex(programIDIndex uint8) (PublicKey, error)
- func (t *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
- func (t *Transaction) TouchAccount(account PublicKey) bool
- type TransactionOption
Constants ¶
This section is empty.
Variables ¶
View Source
var InstructionDecoderRegistry = map[string]InstructionDecoder{}
Functions ¶
func DecimalsInBigInt ¶
func DecodeInstruction ¶
func DecodeInstruction(programID PublicKey, accounts []*AccountMeta, data []byte) (interface{}, error)
func NewRandomPrivateKey ¶
func NewRandomPrivateKey() (PublicKey, PrivateKey, error)
func RegisterInstructionDecoder ¶
func RegisterInstructionDecoder(programID PublicKey, decoder InstructionDecoder)
Types ¶
type Account ¶
type Account struct {
PrivateKey PrivateKey
}
func NewAccount ¶
func NewAccount() *Account
type AccountMeta ¶
type AccountSettable ¶
type AccountSettable interface {
SetAccounts(accounts []*AccountMeta) error
}
type CompiledInstruction ¶
type CompiledInstruction struct { // Index into the message.accountKeys array indicating the program account that executes this instruction. ProgramIDIndex uint8 `json:"programIdIndex"` AccountCount bin.Varuint16 `json:"-" bin:"sizeof=Accounts"` DataLength bin.Varuint16 `json:"-" bin:"sizeof=Data"` // List of ordered indices into the message.accountKeys array indicating which accounts to pass to the program. Accounts []uint8 `json:"accounts"` // The program input data encoded in a base-58 string. Data Base58 `json:"data"` }
func (*CompiledInstruction) ResolveInstructionAccounts ¶
func (ci *CompiledInstruction) ResolveInstructionAccounts(message *Message) (out []*AccountMeta)
type Data ¶
type Data struct { Content []byte Encoding EncodingType }
func (Data) MarshalJSON ¶
func (*Data) UnmarshalJSON ¶
type EncodingType ¶
type EncodingType string
const ( EncodingBase58 EncodingType = "base58" // limited to Account data of less than 129 bytes EncodingBase64 EncodingType = "base64" // will return base64 encoded data for Account data of any size EncodingBase64Zstd EncodingType = "base64+zstd" // compresses the Account data using Zstandard and base64-encodes the result // attempts to use program-specific state parsers to // return more human-readable and explicit account state data. // If "jsonParsed" is requested but a parser cannot be found, // the field falls back to "base64" encoding, detectable when the data field is type <string>. // Cannot be used if specifying dataSlice parameters (offset, length). EncodingJSONParsed EncodingType = "jsonParsed" EncodingJSON EncodingType = "json" // NOTE: not usable in almost-all places. )
type Hash ¶
type Hash PublicKey
func HashFromBase58 ¶
func MustHashFromBase58 ¶
func (Hash) MarshalJSON ¶
func (*Hash) UnmarshalJSON ¶
type Instruction ¶
type Instruction interface { Accounts() []*AccountMeta // returns the list of accounts the instructions requires ProgramID() PublicKey // the programID the instruction acts on Data() ([]byte, error) // the binary encoded instructions }
type InstructionDecoder ¶
type InstructionDecoder func(instructionAccounts []*AccountMeta, data []byte) (interface{}, error)
InstructionDecoder receives the AccountMeta FOR THAT INSTRUCTION, and not the accounts of the *Message object. Resolve with CompiledInstruction.ResolveInstructionAccounts(message) beforehand.
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"` }
func (*Message) AccountMetaList ¶
func (m *Message) AccountMetaList() (out []*AccountMeta)
func (*Message) IsWritable ¶
func (*Message) ResolveProgramIDIndex ¶
func (*Message) TouchAccount ¶
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 PrivateKey ¶
type PrivateKey []byte
func MustPrivateKeyFromBase58 ¶
func MustPrivateKeyFromBase58(in string) PrivateKey
func PrivateKeyFromBase58 ¶
func PrivateKeyFromBase58(privkey string) (PrivateKey, error)
func PrivateKeyFromSolanaKeygenFile ¶
func PrivateKeyFromSolanaKeygenFile(file string) (PrivateKey, error)
func (PrivateKey) PublicKey ¶
func (k PrivateKey) PublicKey() PublicKey
func (PrivateKey) String ¶
func (k PrivateKey) String() string
type PublicKey ¶
type PublicKey [32]byte
func MustPublicKeyFromBase58 ¶
func PublicKeyFromBase58 ¶
func PublicKeyFromBytes ¶
func (PublicKey) MarshalJSON ¶
func (*PublicKey) UnmarshalJSON ¶
type Signature ¶
type Signature [64]byte
/
func MustSignatureFromBase58 ¶
func SignatureFromBase58 ¶
func (Signature) MarshalJSON ¶
func (*Signature) UnmarshalJSON ¶
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 MustTransactionFromData ¶
func MustTransactionFromData(in []byte) *Transaction
func NewTransaction ¶
func NewTransaction(instructions []Instruction, blockHash Hash, opts ...TransactionOption) (*Transaction, error)
func TransactionFromData ¶
func TransactionFromData(in []byte) (*Transaction, error)
func (*Transaction) AccountMetaList ¶
func (t *Transaction) AccountMetaList() (out []*AccountMeta)
func (*Transaction) IsSigner ¶
func (t *Transaction) IsSigner(account PublicKey) bool
func (*Transaction) IsWritable ¶
func (t *Transaction) IsWritable(account PublicKey) bool
func (*Transaction) ResolveProgramIDIndex ¶
func (t *Transaction) ResolveProgramIDIndex(programIDIndex uint8) (PublicKey, error)
func (*Transaction) Sign ¶
func (t *Transaction) Sign(getter privateKeyGetter) (out []Signature, err error)
func (*Transaction) TouchAccount ¶
func (t *Transaction) TouchAccount(account PublicKey) bool
type TransactionOption ¶
type TransactionOption interface {
// contains filtered or unexported methods
}
func TransactionPayer ¶
func TransactionPayer(payer PublicKey) TransactionOption
Source Files ¶
Click to show internal directories.
Click to hide internal directories.