transaction

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTransaction

func BroadcastTransaction(tx StacksTransaction, network *stacks.StacksNetwork) (string, error)

func SerializePostConditions

func SerializePostConditions(postConditions []PostCondition) []byte

Assume empty post condition

func SignTransaction

func SignTransaction(tx StacksTransaction, privateKey []byte) error

func VerifyTransaction

func VerifyTransaction(tx StacksTransaction, publicKey []byte) (bool, error)

Types

type BaseTransaction

type BaseTransaction struct {
	Version           stacks.TransactionVersion
	ChainID           stacks.ChainID
	Auth              TransactionAuth
	AnchorMode        stacks.AnchorMode
	PostConditionMode stacks.PostConditionMode
	PostConditions    []PostCondition
}

type ContractCallPayload

type ContractCallPayload struct {
	ContractAddress clarity.ClarityValue // Can be either StandardPrincipal or ContractPrincipal
	ContractName    string
	FunctionName    string
	FunctionArgs    []clarity.ClarityValue
}

func NewContractCallPayload

func NewContractCallPayload(contractAddress string, contractName string, functionName string, functionArgs []clarity.ClarityValue) (*ContractCallPayload, error)

func (*ContractCallPayload) Deserialize

func (p *ContractCallPayload) Deserialize(data []byte) (int, error)

func (*ContractCallPayload) Serialize

func (p *ContractCallPayload) Serialize() ([]byte, error)

type ContractCallTransaction

type ContractCallTransaction struct {
	BaseTransaction
	Payload ContractCallPayload
}

func MakeContractCall

func MakeContractCall(
	contractAddress string,
	contractName string,
	functionName string,
	functionArgs []clarity.ClarityValue,
	network stacks.StacksNetwork,
	senderAddress string,
	senderKey []byte,
	fee *big.Int,
	nonce *big.Int,
) (*ContractCallTransaction, error)

func NewContractCallTransaction

func NewContractCallTransaction(
	contractAddress string,
	contractName string,
	functionName string,
	functionArgs []clarity.ClarityValue,
	version stacks.TransactionVersion,
	chainID stacks.ChainID,
	signer [20]byte,
	nonce uint64,
	fee uint64,
	anchorMode stacks.AnchorMode,
	postConditionMode stacks.PostConditionMode,
) (*ContractCallTransaction, error)

func (*ContractCallTransaction) Clone

func (*ContractCallTransaction) Deserialize

func (t *ContractCallTransaction) Deserialize(data []byte) error

func (*ContractCallTransaction) GetAuth

func (*ContractCallTransaction) GetPayload

func (t *ContractCallTransaction) GetPayload() Payload

func (*ContractCallTransaction) Serialize

func (t *ContractCallTransaction) Serialize() ([]byte, error)

func (*ContractCallTransaction) Sign

func (t *ContractCallTransaction) Sign(privateKey []byte) error

func (*ContractCallTransaction) Verify

func (t *ContractCallTransaction) Verify(publicKey []byte) (bool, error)

type CustomError

type CustomError struct {
	Message string
	Err     error
}

func (*CustomError) Error

func (e *CustomError) Error() string

type NonceInfo

type NonceInfo struct {
	LastExecutedTxNonce   *int64  `json:"last_executed_tx_nonce"`
	LastMempoolTxNonce    *int64  `json:"last_mempool_tx_nonce"`
	PossibleNextNonce     int64   `json:"possible_next_nonce"`
	DetectedMissingNonces []int64 `json:"detected_missing_nonces"`
}

type Payload

type Payload interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) (int, error)
}

type PostCondition

type PostCondition interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) (int, error)
	GetType() stacks.PostConditionType
}

func DeserializePostConditions

func DeserializePostConditions(data []byte) ([]PostCondition, int, error)

Assume empty post condition

type SpendingCondition

type SpendingCondition struct {
	HashMode    stacks.AddressHashMode
	Signer      [20]byte
	Nonce       uint64
	Fee         uint64
	KeyEncoding stacks.PubKeyEncoding
	Signature   [stacks.RecoverableECDSASigLengthBytes]byte
}

func (*SpendingCondition) Deserialize

func (sc *SpendingCondition) Deserialize(data []byte) (int, error)

func (*SpendingCondition) Serialize

func (sc *SpendingCondition) Serialize() ([]byte, error)

type StacksTransaction

type StacksTransaction interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) error
	GetAuth() *TransactionAuth
	GetPayload() Payload
	Clone() StacksTransaction
}

func DeserializeTransaction

func DeserializeTransaction(data []byte) (StacksTransaction, error)

type TokenTransferPayload

type TokenTransferPayload struct {
	Recipient clarity.ClarityValue // Can be either StandardPrincipal or ContractPrincipal
	Amount    uint64
	Memo      string
}

func NewTokenTransferPayload

func NewTokenTransferPayload(recipient string, amount uint64, memo string) (*TokenTransferPayload, error)

func (*TokenTransferPayload) Deserialize

func (p *TokenTransferPayload) Deserialize(data []byte) (int, error)

func (*TokenTransferPayload) Serialize

func (p *TokenTransferPayload) Serialize() ([]byte, error)

type TokenTransferTransaction

type TokenTransferTransaction struct {
	BaseTransaction
	Payload TokenTransferPayload
}

func MakeSTXTokenTransfer

func MakeSTXTokenTransfer(
	recipient string,
	amount big.Int,
	memo string,
	network stacks.StacksNetwork,
	senderAddress string,
	senderKey []byte,
	fee *big.Int,
	nonce *big.Int,
) (*TokenTransferTransaction, error)

func NewTokenTransferTransaction

func NewTokenTransferTransaction(
	recipient string,
	amount uint64,
	memo string,
	version stacks.TransactionVersion,
	chainID stacks.ChainID,
	signer [20]byte,
	nonce uint64,
	fee uint64,
	anchorMode stacks.AnchorMode,
	postConditionMode stacks.PostConditionMode,
) (*TokenTransferTransaction, error)

func (*TokenTransferTransaction) Clone

func (*TokenTransferTransaction) Deserialize

func (t *TokenTransferTransaction) Deserialize(data []byte) error

func (*TokenTransferTransaction) GetAuth

func (*TokenTransferTransaction) GetPayload

func (t *TokenTransferTransaction) GetPayload() Payload

func (*TokenTransferTransaction) Serialize

func (t *TokenTransferTransaction) Serialize() ([]byte, error)

func (*TokenTransferTransaction) Sign

func (t *TokenTransferTransaction) Sign(privateKey []byte) error

func (*TokenTransferTransaction) Verify

func (t *TokenTransferTransaction) Verify(publicKey []byte) (bool, error)

type TransactionAuth

type TransactionAuth struct {
	AuthType    stacks.AuthType
	OriginAuth  SpendingCondition
	SponsorAuth *SpendingCondition
}

func (*TransactionAuth) Deserialize

func (auth *TransactionAuth) Deserialize(data []byte) (int, error)

func (*TransactionAuth) Serialize

func (auth *TransactionAuth) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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