types

package
Version: v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 10 Imported by: 28

Documentation

Index

Constants

This section is empty.

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 added in v1.7.0

func AccountFromBase58(key string) (Account, error)

AccountFromBase58 generate a account by base58 private key

func AccountFromBytes added in v1.7.0

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

AccountFromBytes generate a account by bytes private key

func AccountFromHex added in v1.7.0

func AccountFromHex(key string) (Account, error)

AccountFromHex generate a account by hex private key

func AccountFromSeed added in v1.11.0

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

AccountFromSeed generate a account by seed

func NewAccount

func NewAccount() Account

func (Account) Sign added in v1.7.0

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

type AccountMeta

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

type CompiledInstruction

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

type Instruction

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

type Message

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

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

func (*Message) Serialize

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

type MessageHeader

type MessageHeader struct {
	NumRequireSignatures        uint8
	NumReadonlySignedAccounts   uint8
	NumReadonlyUnsignedAccounts uint8
}

type NewMessageParam added in v1.9.0

type NewMessageParam struct {
	FeePayer        common.PublicKey
	Instructions    []Instruction
	RecentBlockhash string
}

type NewTransactionParam added in v1.9.0

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 added in v1.7.0

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 added in v1.7.0

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