transaction

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 16 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, error)

func SignTransaction

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

func VerifyTransaction

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

Types

type AssetInfo added in v0.5.0

type AssetInfo struct {
	Contract  *clarity.ContractPrincipal
	AssetName string
}

func (*AssetInfo) Deserialize added in v0.5.0

func (a *AssetInfo) Deserialize(data []byte) (int, error)

func (*AssetInfo) Serialize added in v0.5.0

func (a *AssetInfo) Serialize() ([]byte, error)

type BaseTransaction

type BaseTransaction struct {
	Version           stacks.TransactionVersion
	ChainID           stacks.ChainID
	Auth              TransactionAuth
	PostConditionMode stacks.PostConditionMode
	PostConditions    []PostCondition
	/** @deprecated Not used, starting with Stacks 2.5. Still needed for serialization. */
	AnchorMode stacks.AnchorMode
}

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,
	postConditionMode stacks.PostConditionMode,
	postConditions []PostCondition,
) (*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,
	postConditionMode stacks.PostConditionMode,
	postConditions []PostCondition,
) (*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 DeserializePostCondition added in v0.5.0

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

func DeserializePostConditions

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

type PostConditionContractPrincipal added in v0.5.0

type PostConditionContractPrincipal struct {
	Contract *clarity.ContractPrincipal
}

func (*PostConditionContractPrincipal) Deserialize added in v0.5.0

func (pc *PostConditionContractPrincipal) Deserialize(data []byte) (int, error)

func (*PostConditionContractPrincipal) GetID added in v0.5.0

func (*PostConditionContractPrincipal) Serialize added in v0.5.0

func (pc *PostConditionContractPrincipal) Serialize() ([]byte, error)

type PostConditionFungible added in v0.5.0

type PostConditionFungible struct {
	Principal     PostConditionPrincipal
	ConditionCode stacks.FungibleConditionCode
	Amount        uint64
	Asset         *AssetInfo
}

func (*PostConditionFungible) Deserialize added in v0.5.0

func (pc *PostConditionFungible) Deserialize(data []byte) (int, error)

func (*PostConditionFungible) GetType added in v0.5.0

func (*PostConditionFungible) Serialize added in v0.5.0

func (pc *PostConditionFungible) Serialize() ([]byte, error)

type PostConditionNonFungible added in v0.5.0

type PostConditionNonFungible struct {
	Principal     PostConditionPrincipal
	ConditionCode stacks.NonFungibleConditionCode
	Asset         *AssetInfo
	AssetValue    clarity.ClarityValue
}

func (*PostConditionNonFungible) Deserialize added in v0.5.0

func (pc *PostConditionNonFungible) Deserialize(data []byte) (int, error)

func (*PostConditionNonFungible) GetType added in v0.5.0

func (*PostConditionNonFungible) Serialize added in v0.5.0

func (pc *PostConditionNonFungible) Serialize() ([]byte, error)

type PostConditionOriginPrincipal added in v0.5.0

type PostConditionOriginPrincipal struct {
}

func (*PostConditionOriginPrincipal) Deserialize added in v0.5.0

func (pc *PostConditionOriginPrincipal) Deserialize(data []byte) (int, error)

func (*PostConditionOriginPrincipal) GetID added in v0.5.0

func (*PostConditionOriginPrincipal) Serialize added in v0.5.0

func (pc *PostConditionOriginPrincipal) Serialize() ([]byte, error)

type PostConditionPrincipal added in v0.5.0

type PostConditionPrincipal interface {
	Serialize() ([]byte, error)
	Deserialize([]byte) (int, error)
	GetID() stacks.PostConditionPrincipalType
}

func DeserializePostConditionPrincipal added in v0.5.0

func DeserializePostConditionPrincipal(data []byte) (PostConditionPrincipal, int, error)

type PostConditionSTX added in v0.5.0

type PostConditionSTX struct {
	Principal     PostConditionPrincipal
	ConditionCode stacks.FungibleConditionCode
	Amount        uint64
}

func (*PostConditionSTX) Deserialize added in v0.5.0

func (pc *PostConditionSTX) Deserialize(data []byte) (int, error)

func (*PostConditionSTX) GetType added in v0.5.0

func (*PostConditionSTX) Serialize added in v0.5.0

func (pc *PostConditionSTX) Serialize() ([]byte, error)

type PostConditionStandardPrincipal added in v0.5.0

type PostConditionStandardPrincipal struct {
	Address *clarity.StandardPrincipal
}

func (*PostConditionStandardPrincipal) Deserialize added in v0.5.0

func (pc *PostConditionStandardPrincipal) Deserialize(data []byte) (int, error)

func (*PostConditionStandardPrincipal) GetID added in v0.5.0

func (*PostConditionStandardPrincipal) Serialize added in v0.5.0

func (pc *PostConditionStandardPrincipal) Serialize() ([]byte, error)

type SmartContractPayload added in v0.3.0

type SmartContractPayload struct {
	ContractName   string
	CodeBody       string
	ClarityVersion stacks.ClarityVersion
}

func NewSmartContractPayload added in v0.3.0

func NewSmartContractPayload(contractName string, codeBody string, clarityVersion stacks.ClarityVersion) (*SmartContractPayload, error)

func (*SmartContractPayload) Deserialize added in v0.3.0

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

func (*SmartContractPayload) Serialize added in v0.3.0

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

type SmartContractTransaction added in v0.3.0

type SmartContractTransaction struct {
	BaseTransaction
	Payload SmartContractPayload
}

func MakeContractDeploy added in v0.3.0

func MakeContractDeploy(
	contractName string,
	codeBody string,
	clarityVersion stacks.ClarityVersion,
	network stacks.StacksNetwork,
	senderAddress string,
	senderKey []byte,
	fee *big.Int,
	nonce *big.Int,
	postConditionMode stacks.PostConditionMode,
	postConditions []PostCondition,
) (*SmartContractTransaction, error)

func NewSmartContractTransaction added in v0.3.0

func NewSmartContractTransaction(
	contractName string,
	codeBody string,
	clarityVersion stacks.ClarityVersion,
	version stacks.TransactionVersion,
	chainID stacks.ChainID,
	signer [20]byte,
	nonce uint64,
	fee uint64,
	postConditionMode stacks.PostConditionMode,
	postConditions []PostCondition,
) (*SmartContractTransaction, error)

func (*SmartContractTransaction) Clone added in v0.3.0

func (*SmartContractTransaction) Deserialize added in v0.3.0

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

func (*SmartContractTransaction) GetAuth added in v0.3.0

func (*SmartContractTransaction) GetPayload added in v0.3.0

func (t *SmartContractTransaction) GetPayload() Payload

func (*SmartContractTransaction) Serialize added in v0.3.0

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

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,
	postConditionMode stacks.PostConditionMode,
	postConditions []PostCondition,
) (*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