types

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 11 Imported by: 64

Documentation

Index

Constants

View Source
const (
	MessageVersionLegacy = "legacy"
	MessageVersionV0     = "v0"
)

Variables

View Source
var (
	ErrAccountFailedToBase58Decode     = errors.New("failed to base58 decode")
	ErrAccountFailedToHexDecode        = errors.New("failed to hex decode")
	ErrAccountPrivateKeyLengthMismatch = errors.New("key length mismatch")
)
View Source
var (
	ErrTransactionAddNotNecessarySignatures = errors.New("add not necessary signatures")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	PublicKey  common.PublicKey
	PrivateKey ed25519.PrivateKey
}

func AccountFromBase58

func AccountFromBase58(key string) (Account, error)

AccountFromBase58 generate a account by base58 private key

func AccountFromBytes

func AccountFromBytes(key []byte) (Account, error)

AccountFromBytes generate a account by bytes private key

func AccountFromHex

func AccountFromHex(key string) (Account, error)

AccountFromHex generate a account by hex private key

func AccountFromSeed

func AccountFromSeed(seed []byte) (Account, error)

AccountFromSeed generate a account by seed

func NewAccount

func NewAccount() Account

func (Account) Sign

func (a Account) Sign(message []byte) []byte

type AccountMeta

type AccountMeta struct {
	PubKey     common.PublicKey
	IsSigner   bool
	IsWritable bool
}

type AddressLookupTableAccount

type AddressLookupTableAccount struct {
	Key       common.PublicKey
	Addresses []common.PublicKey
}

type CompiledAddressLookupTable

type CompiledAddressLookupTable struct {
	AccountKey      common.PublicKey
	WritableIndexes []uint8
	ReadonlyIndexes []uint8
}

type CompiledInstruction

type CompiledInstruction struct {
	ProgramIDIndex int
	Accounts       []int
	Data           []byte
}

type CompiledKeyMeta

type CompiledKeyMeta struct {
	IsSigner   bool
	IsWritable bool
	IsInvoked  bool
}

type CompiledKeys

type CompiledKeys struct {
	Payer      *common.PublicKey
	KeyMetaMap map[common.PublicKey]CompiledKeyMeta
}

func NewCompiledKeys

func NewCompiledKeys(instructions []Instruction, payer *common.PublicKey) CompiledKeys

type Instruction

type Instruction struct {
	ProgramID common.PublicKey
	Accounts  []AccountMeta
	Data      []byte
}

type Message

type Message struct {
	Version             MessageVersion
	Header              MessageHeader
	Accounts            []common.PublicKey
	RecentBlockHash     string
	Instructions        []CompiledInstruction
	AddressLookupTables []CompiledAddressLookupTable
}

func MessageDeserialize

func MessageDeserialize(messageData []byte) (Message, error)

func MustMessageDeserialize

func MustMessageDeserialize(messageData []byte) Message

func NewMessage

func NewMessage(param NewMessageParam) Message

func (*Message) DecompileInstructions

func (m *Message) DecompileInstructions() []Instruction

DecompileInstructions hasn't support v0 message decode

func (*Message) Serialize

func (m *Message) Serialize() ([]byte, error)

type MessageHeader

type MessageHeader struct {
	NumRequireSignatures        uint8
	NumReadonlySignedAccounts   uint8
	NumReadonlyUnsignedAccounts uint8
}

type MessageVersion

type MessageVersion string

type NewMessageParam

type NewMessageParam struct {
	FeePayer        common.PublicKey
	Instructions    []Instruction
	RecentBlockhash string
	// v0 transaction
	AddressLookupTableAccounts []AddressLookupTableAccount
}

type NewTransactionParam

type NewTransactionParam struct {
	Message Message
	Signers []Account
}

type Signature

type Signature []byte

type Transaction

type Transaction struct {
	Signatures []Signature
	Message    Message
}

func MustTransactionDeserialize

func MustTransactionDeserialize(data []byte) Transaction

MustTransactionDeserialize can deserialize a tx from byte array, it panic if error ocour

func NewTransaction

func NewTransaction(param NewTransactionParam) (Transaction, error)

NewTransaction create a new tx by message and signer. it will reserve signatures slot.

func TransactionDeserialize

func TransactionDeserialize(tx []byte) (Transaction, error)

TransactionDeserialize can deserialize a tx from byte array

func (*Transaction) AddSignature

func (tx *Transaction) AddSignature(sig []byte) error

AddSignature will add or replace signature into the correct order signature's slot.

func (*Transaction) Serialize

func (tx *Transaction) Serialize() ([]byte, error)

Serialize pack tx into byte array

Jump to

Keyboard shortcuts

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