codec

package module
v0.0.0-...-05cdd0b Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Unlicense Imports: 11 Imported by: 1

README

Stacks Blockchain Codec

This project provides a Go implementation of the transaction wire format for the Stacks blockchain. It includes functionality for decoding various Stacks blockchain data structures, including transactions, addresses, and Clarity values.

Features

  • Decode Stacks blockchain transactions
  • Convert between different address formats
  • Decode Clarity values
  • Support for various payload types including token transfers, contract calls, and coinbase transactions

Installation

To use this package in your Go project, you can install it using:

go get github.com/stxpub/codec

Usage

Here's a basic example of how to use the transaction decoder:

package main

import (
    "bytes"
    "encoding/hex"
    "fmt"
    "log"

    "github.com/yourusername/stacks-codec/codec"
)

func main() {
    // Example transaction hex
    txHex := "00000000010400c1c66bdc612ebf90fd9b343f31f7f1750e50a13b000000000000333b00000000000000c8..."

    data, err := hex.DecodeString(txHex)
    if err != nil {
        log.Fatal(err)
    }

    var tx codec.Transaction
    err = tx.Decode(bytes.NewReader(data))
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("%+v\n", tx)
}

For more detailed usage examples, please refer to the tests in the codec package.

Testing

To run the tests, use the following command in the project root directory:

go test ./...

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the Unlicense.

Known issues

Encoding of transactions is not yet supported.

Documentation

Index

Constants

View Source
const C32_CHARACTERS = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Version   AddressVersion
	HashBytes [20]byte
}

func (*Address) Decode

func (a *Address) Decode(r *bytes.Reader) error

func (*Address) ToStacks

func (a *Address) ToStacks() string

type AddressVersion

type AddressVersion uint8 //enums:enum
const (
	MainnetSingleSig AddressVersion = 22 // P
	MainnetMultiSig  AddressVersion = 20 // M
	TestnetSingleSig AddressVersion = 26 // T
	TestnetMultiSig  AddressVersion = 21 // N
)
const AddressVersionN AddressVersion = 27

AddressVersionN is the highest valid value for type AddressVersion, plus one.

func AddressVersionValues

func AddressVersionValues() []AddressVersion

AddressVersionValues returns all possible values for the type AddressVersion.

func (*AddressVersion) Decode

func (a *AddressVersion) Decode(r *bytes.Reader) error

func (AddressVersion) Desc

func (i AddressVersion) Desc() string

Desc returns the description of the AddressVersion value.

func (AddressVersion) Int64

func (i AddressVersion) Int64() int64

Int64 returns the AddressVersion value as an int64.

func (AddressVersion) MarshalText

func (i AddressVersion) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*AddressVersion) SetInt64

func (i *AddressVersion) SetInt64(in int64)

SetInt64 sets the AddressVersion value from an int64.

func (*AddressVersion) SetString

func (i *AddressVersion) SetString(s string) error

SetString sets the AddressVersion value from its string representation, and returns an error if the string is invalid.

func (AddressVersion) String

func (i AddressVersion) String() string

String returns the string representation of this AddressVersion value.

func (*AddressVersion) UnmarshalText

func (i *AddressVersion) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (AddressVersion) Values

func (i AddressVersion) Values() []enums.Enum

Values returns all possible values for the type AddressVersion.

type AnchorMode

type AnchorMode uint8 //enums:enum
const (
	AnchorBlock AnchorMode = iota + 1
	MicroBlock
	Any
)
const AnchorModeN AnchorMode = 4

AnchorModeN is the highest valid value for type AnchorMode, plus one.

func AnchorModeValues

func AnchorModeValues() []AnchorMode

AnchorModeValues returns all possible values for the type AnchorMode.

func (*AnchorMode) Decode

func (a *AnchorMode) Decode(r *bytes.Reader) error

func (AnchorMode) Desc

func (i AnchorMode) Desc() string

Desc returns the description of the AnchorMode value.

func (AnchorMode) Int64

func (i AnchorMode) Int64() int64

Int64 returns the AnchorMode value as an int64.

func (AnchorMode) MarshalText

func (i AnchorMode) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*AnchorMode) SetInt64

func (i *AnchorMode) SetInt64(in int64)

SetInt64 sets the AnchorMode value from an int64.

func (*AnchorMode) SetString

func (i *AnchorMode) SetString(s string) error

SetString sets the AnchorMode value from its string representation, and returns an error if the string is invalid.

func (AnchorMode) String

func (i AnchorMode) String() string

String returns the string representation of this AnchorMode value.

func (*AnchorMode) UnmarshalText

func (i *AnchorMode) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (AnchorMode) Values

func (i AnchorMode) Values() []enums.Enum

Values returns all possible values for the type AnchorMode.

type AssetInfo

type AssetInfo struct {
	Address      Address
	ContractName Name
	AssetName    Name
}

func (*AssetInfo) Decode

func (a *AssetInfo) Decode(r *bytes.Reader) error

type AuthorizationType

type AuthorizationType uint8 //enums:enum
const (
	Standard  AuthorizationType = 0x04
)
const AuthorizationTypeN AuthorizationType = 6

AuthorizationTypeN is the highest valid value for type AuthorizationType, plus one.

func AuthorizationTypeValues

func AuthorizationTypeValues() []AuthorizationType

AuthorizationTypeValues returns all possible values for the type AuthorizationType.

func (*AuthorizationType) Decode

func (a *AuthorizationType) Decode(r *bytes.Reader) error

func (AuthorizationType) Desc

func (i AuthorizationType) Desc() string

Desc returns the description of the AuthorizationType value.

func (AuthorizationType) Int64

func (i AuthorizationType) Int64() int64

Int64 returns the AuthorizationType value as an int64.

func (AuthorizationType) MarshalText

func (i AuthorizationType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*AuthorizationType) SetInt64

func (i *AuthorizationType) SetInt64(in int64)

SetInt64 sets the AuthorizationType value from an int64.

func (*AuthorizationType) SetString

func (i *AuthorizationType) SetString(s string) error

SetString sets the AuthorizationType value from its string representation, and returns an error if the string is invalid.

func (AuthorizationType) String

func (i AuthorizationType) String() string

String returns the string representation of this AuthorizationType value.

func (*AuthorizationType) UnmarshalText

func (i *AuthorizationType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (AuthorizationType) Values

func (i AuthorizationType) Values() []enums.Enum

Values returns all possible values for the type AuthorizationType.

type Bool

type Bool struct {
	Value bool
}

func (*Bool) ClarityDecode

func (b *Bool) ClarityDecode(r *bytes.Reader) error

type ChainID

type ChainID uint32

func (*ChainID) Decode

func (c *ChainID) Decode(r *bytes.Reader) error

type ClarityBuffer

type ClarityBuffer struct {
	Length uint32
	Data   []byte
}

func (*ClarityBuffer) ClarityDecode

func (b *ClarityBuffer) ClarityDecode(r *bytes.Reader) error

type ClarityContractPrincipal

type ClarityContractPrincipal struct {
	ClarityPrincipal
	Name string
}

func (*ClarityContractPrincipal) ClarityDecode

func (c *ClarityContractPrincipal) ClarityDecode(r *bytes.Reader) error

type ClarityPrincipal

type ClarityPrincipal struct {
	Version byte
	Hash160 [20]byte
}

func (*ClarityPrincipal) ClarityDecode

func (p *ClarityPrincipal) ClarityDecode(r *bytes.Reader) error

type ClarityType

type ClarityType uint8 //enums:enum

Define an enum called ClarityType with the following values: 0x00: 128-bit signed integer 0x01: 128-bit unsigned integer 0x02: buffer 0x03: boolean true 0x04: boolean false 0x05: standard principal 0x06: contract principal 0x07: Ok response 0x08: Err response 0x09: None option 0x0a: Some option 0x0b: List 0x0c: Tuple 0x0d: StringASCII 0x0e: StringUTF8

const (
	Int128Signed ClarityType = iota
	Int128Unsigned
	Buffer
	BooleanTrue
	BooleanFalse
	StandardPrincipal
	ContractPrincipal
	OkResponse
	ErrResponse
	NoneOption
	SomeOption
	ListType
	TupleType
	StringASCIIType
	StringUTF8Type
)
const ClarityTypeN ClarityType = 15

ClarityTypeN is the highest valid value for type ClarityType, plus one.

func ClarityTypeValues

func ClarityTypeValues() []ClarityType

ClarityTypeValues returns all possible values for the type ClarityType.

func (ClarityType) Desc

func (i ClarityType) Desc() string

Desc returns the description of the ClarityType value.

func (ClarityType) Int64

func (i ClarityType) Int64() int64

Int64 returns the ClarityType value as an int64.

func (ClarityType) MarshalText

func (i ClarityType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*ClarityType) SetInt64

func (i *ClarityType) SetInt64(in int64)

SetInt64 sets the ClarityType value from an int64.

func (*ClarityType) SetString

func (i *ClarityType) SetString(s string) error

SetString sets the ClarityType value from its string representation, and returns an error if the string is invalid.

func (ClarityType) String

func (i ClarityType) String() string

String returns the string representation of this ClarityType value.

func (*ClarityType) UnmarshalText

func (i *ClarityType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (ClarityType) Values

func (i ClarityType) Values() []enums.Enum

Values returns all possible values for the type ClarityType.

type ClarityValue

type ClarityValue interface {
	ClarityDecode(*bytes.Reader) error
}

type CoinbasePayload

type CoinbasePayload struct {
	Buffer [32]byte
}

func (*CoinbasePayload) Decode

func (c *CoinbasePayload) Decode(r *bytes.Reader) error

Implement Decode for CoinbasePayload

type ContractCallPayload

type ContractCallPayload struct {
	Origin   Address
	Contract Name
	Function Name
}

func (*ContractCallPayload) Decode

func (c *ContractCallPayload) Decode(r *bytes.Reader) error

Implement Decode for ContractCallPayload

type ContractDeployPayload

type ContractDeployPayload struct {
	ContractName Name
	CodeBody     string
}

func (*ContractDeployPayload) Decode

func (c *ContractDeployPayload) Decode(r *bytes.Reader) error

Implement Decode for ContractDeployPayload

type Decoder

type Decoder interface {
	Decode(*bytes.Reader) error
}

type FTPostConditionBody

type FTPostConditionBody struct {
	Principal Principal
	AssetInfo AssetInfo
	Code      FungibleConditionCode
	Amount    uint64
}

func (*FTPostConditionBody) Decode

func (n *FTPostConditionBody) Decode(r *bytes.Reader) error

type FungibleConditionCode

type FungibleConditionCode uint8 //enums:enum
const (
	SentEq FungibleConditionCode = iota + 1
	SentGt
	SentGe
	SentLt
	SentLe
)
const FungibleConditionCodeN FungibleConditionCode = 6

FungibleConditionCodeN is the highest valid value for type FungibleConditionCode, plus one.

func FungibleConditionCodeValues

func FungibleConditionCodeValues() []FungibleConditionCode

FungibleConditionCodeValues returns all possible values for the type FungibleConditionCode.

func (*FungibleConditionCode) Decode

func (f *FungibleConditionCode) Decode(r *bytes.Reader) error

Implement Decode for FungibleConditionCode

func (FungibleConditionCode) Desc

func (i FungibleConditionCode) Desc() string

Desc returns the description of the FungibleConditionCode value.

func (FungibleConditionCode) Int64

func (i FungibleConditionCode) Int64() int64

Int64 returns the FungibleConditionCode value as an int64.

func (FungibleConditionCode) MarshalText

func (i FungibleConditionCode) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*FungibleConditionCode) SetInt64

func (i *FungibleConditionCode) SetInt64(in int64)

SetInt64 sets the FungibleConditionCode value from an int64.

func (*FungibleConditionCode) SetString

func (i *FungibleConditionCode) SetString(s string) error

SetString sets the FungibleConditionCode value from its string representation, and returns an error if the string is invalid.

func (FungibleConditionCode) String

func (i FungibleConditionCode) String() string

String returns the string representation of this FungibleConditionCode value.

func (*FungibleConditionCode) UnmarshalText

func (i *FungibleConditionCode) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (FungibleConditionCode) Values

func (i FungibleConditionCode) Values() []enums.Enum

Values returns all possible values for the type FungibleConditionCode.

type HashMode

type HashMode uint8 //enums:enum
const (
	// hash160(public-key), same as bitcoin's p2pkh
	P2PKH HashMode = iota
	// hash160(multisig-redeem-script), same as bitcoin's multisig p2sh
	P2SH
	// hash160(segwit-program-00(p2pkh)), same as bitcoin's p2sh-p2wpkh
	P2WPKH
	// hash160(segwit-program-00(public-keys)), same as bitcoin's p2sh-p2wsh
	P2WSH
)
const HashModeN HashMode = 4

HashModeN is the highest valid value for type HashMode, plus one.

func HashModeValues

func HashModeValues() []HashMode

HashModeValues returns all possible values for the type HashMode.

func (*HashMode) Decode

func (h *HashMode) Decode(r *bytes.Reader) error

func (HashMode) Desc

func (i HashMode) Desc() string

Desc returns the description of the HashMode value.

func (HashMode) Int64

func (i HashMode) Int64() int64

Int64 returns the HashMode value as an int64.

func (HashMode) MarshalText

func (i HashMode) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*HashMode) SetInt64

func (i *HashMode) SetInt64(in int64)

SetInt64 sets the HashMode value from an int64.

func (*HashMode) SetString

func (i *HashMode) SetString(s string) error

SetString sets the HashMode value from its string representation, and returns an error if the string is invalid.

func (HashMode) String

func (i HashMode) String() string

String returns the string representation of this HashMode value.

func (*HashMode) UnmarshalText

func (i *HashMode) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (HashMode) Values

func (i HashMode) Values() []enums.Enum

Values returns all possible values for the type HashMode.

type Int128

type Int128 struct {
	Value *big.Int
}

func (*Int128) ClarityDecode

func (i *Int128) ClarityDecode(r *bytes.Reader) error

type List

type List struct {
	Length uint32
	Values []ClarityValue
}

func (*List) ClarityDecode

func (l *List) ClarityDecode(r *bytes.Reader) error

type MultiSigSpendingCondition

type MultiSigSpendingCondition struct {
	Authorizations []SpendingAuthorizationField
	SignatureCount uint16
}

func (*MultiSigSpendingCondition) Decode

func (msc *MultiSigSpendingCondition) Decode(r *bytes.Reader) error

Implement Decode for MultiSigSpendingCondition

type NFTConditionCode

type NFTConditionCode uint8 //enums:enum
const (
	Sent    NFTConditionCode = 0x10
	NotSent NFTConditionCode = 0x11
)
const NFTConditionCodeN NFTConditionCode = 18

NFTConditionCodeN is the highest valid value for type NFTConditionCode, plus one.

func NFTConditionCodeValues

func NFTConditionCodeValues() []NFTConditionCode

NFTConditionCodeValues returns all possible values for the type NFTConditionCode.

func (*NFTConditionCode) Decode

func (n *NFTConditionCode) Decode(r *bytes.Reader) error

Implement Decode for NFTConditionCode

func (NFTConditionCode) Desc

func (i NFTConditionCode) Desc() string

Desc returns the description of the NFTConditionCode value.

func (NFTConditionCode) Int64

func (i NFTConditionCode) Int64() int64

Int64 returns the NFTConditionCode value as an int64.

func (NFTConditionCode) MarshalText

func (i NFTConditionCode) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*NFTConditionCode) SetInt64

func (i *NFTConditionCode) SetInt64(in int64)

SetInt64 sets the NFTConditionCode value from an int64.

func (*NFTConditionCode) SetString

func (i *NFTConditionCode) SetString(s string) error

SetString sets the NFTConditionCode value from its string representation, and returns an error if the string is invalid.

func (NFTConditionCode) String

func (i NFTConditionCode) String() string

String returns the string representation of this NFTConditionCode value.

func (*NFTConditionCode) UnmarshalText

func (i *NFTConditionCode) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (NFTConditionCode) Values

func (i NFTConditionCode) Values() []enums.Enum

Values returns all possible values for the type NFTConditionCode.

type NFTPostConditionBody

type NFTPostConditionBody struct {
	Principal Principal
	AssetInfo AssetInfo
	AssetName ClarityValue
	Code      NFTConditionCode
}

func (*NFTPostConditionBody) Decode

func (n *NFTPostConditionBody) Decode(r *bytes.Reader) error

type NakamotoCoinbasePayload

type NakamotoCoinbasePayload struct {
	Buffer [32]byte
	// TODO: add support for optional principal
	VRFProof [80]byte
}

func (*NakamotoCoinbasePayload) Decode

func (n *NakamotoCoinbasePayload) Decode(r *bytes.Reader) error

Implement Decode for NakamotoCoinbasePayload

type Name

type Name string

func (*Name) Decode

func (s *Name) Decode(r *bytes.Reader) error

TODO: add regex checks

type NetworkVersion

type NetworkVersion uint8 //enums:enum
const (
	Mainnet NetworkVersion = iota
	Testnet
)

TODO: do the validation during decode but consider preserving the version byte. Instead of the enum, just implement Stringer.

const NetworkVersionN NetworkVersion = 2

NetworkVersionN is the highest valid value for type NetworkVersion, plus one.

func NetworkVersionValues

func NetworkVersionValues() []NetworkVersion

NetworkVersionValues returns all possible values for the type NetworkVersion.

func (*NetworkVersion) Decode

func (v *NetworkVersion) Decode(r *bytes.Reader) error

func (NetworkVersion) Desc

func (i NetworkVersion) Desc() string

Desc returns the description of the NetworkVersion value.

func (NetworkVersion) Int64

func (i NetworkVersion) Int64() int64

Int64 returns the NetworkVersion value as an int64.

func (NetworkVersion) MarshalText

func (i NetworkVersion) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*NetworkVersion) SetInt64

func (i *NetworkVersion) SetInt64(in int64)

SetInt64 sets the NetworkVersion value from an int64.

func (*NetworkVersion) SetString

func (i *NetworkVersion) SetString(s string) error

SetString sets the NetworkVersion value from its string representation, and returns an error if the string is invalid.

func (NetworkVersion) String

func (i NetworkVersion) String() string

String returns the string representation of this NetworkVersion value.

func (*NetworkVersion) UnmarshalText

func (i *NetworkVersion) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (NetworkVersion) Values

func (i NetworkVersion) Values() []enums.Enum

Values returns all possible values for the type NetworkVersion.

type Option

type Option struct {
	IsSome bool
	Value  ClarityValue
}

func (*Option) ClarityDecode

func (opt *Option) ClarityDecode(r *bytes.Reader) error

type Payload

type Payload struct {
	Type                    PayloadType
	Transfer                *STXTransferPayload
	ContractDeploy          *ContractDeployPayload
	ContractCall            *ContractCallPayload
	Coinbase                *CoinbasePayload
	VersionedContractDeploy *VersionedContractDeployPayload
	NakamotoCoinbase        *NakamotoCoinbasePayload
	TenureChange            *TenureChangePayload
}

func (*Payload) Decode

func (p *Payload) Decode(r *bytes.Reader) error

Implement Decode for Payload

type PayloadType

type PayloadType uint8 //enums:enum
const (
	TokenTransfer PayloadType = iota
	ContractDeploy
	ContractCall
	PoisonMicroblock
	Coinbase
	// https://github.com/stacksgov/sips/blob/main/sips/sip-015/sip-015-network-upgrade.md
	CoinbaseToAltRecipient
	VersionedContractDeploy
	// https://github.com/stacksgov/sips/blob/main/sips/sip-021/sip-021-nakamoto.md
	TenureChange
	NakamotoCoinbase
)
const PayloadTypeN PayloadType = 9

PayloadTypeN is the highest valid value for type PayloadType, plus one.

func PayloadTypeValues

func PayloadTypeValues() []PayloadType

PayloadTypeValues returns all possible values for the type PayloadType.

func (*PayloadType) Decode

func (p *PayloadType) Decode(r *bytes.Reader) error

Implement Decode for PayloadType

func (PayloadType) Desc

func (i PayloadType) Desc() string

Desc returns the description of the PayloadType value.

func (PayloadType) Int64

func (i PayloadType) Int64() int64

Int64 returns the PayloadType value as an int64.

func (PayloadType) MarshalText

func (i PayloadType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PayloadType) SetInt64

func (i *PayloadType) SetInt64(in int64)

SetInt64 sets the PayloadType value from an int64.

func (*PayloadType) SetString

func (i *PayloadType) SetString(s string) error

SetString sets the PayloadType value from its string representation, and returns an error if the string is invalid.

func (PayloadType) String

func (i PayloadType) String() string

String returns the string representation of this PayloadType value.

func (*PayloadType) UnmarshalText

func (i *PayloadType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (PayloadType) Values

func (i PayloadType) Values() []enums.Enum

Values returns all possible values for the type PayloadType.

type PostCondition

type PostCondition struct {
	Type PostConditionType
	STX  *STXPostConditionBody
	FT   *FTPostConditionBody
	NFT  *NFTPostConditionBody
}

func (*PostCondition) Decode

func (p *PostCondition) Decode(r *bytes.Reader) error

Implement Decode for PostCondition

type PostConditionMode

type PostConditionMode uint8 //enums:enum
const (
	Allow PostConditionMode = iota + 1
	Deny
)
const PostConditionModeN PostConditionMode = 3

PostConditionModeN is the highest valid value for type PostConditionMode, plus one.

func PostConditionModeValues

func PostConditionModeValues() []PostConditionMode

PostConditionModeValues returns all possible values for the type PostConditionMode.

func (*PostConditionMode) Decode

func (p *PostConditionMode) Decode(r *bytes.Reader) error

func (PostConditionMode) Desc

func (i PostConditionMode) Desc() string

Desc returns the description of the PostConditionMode value.

func (PostConditionMode) Int64

func (i PostConditionMode) Int64() int64

Int64 returns the PostConditionMode value as an int64.

func (PostConditionMode) MarshalText

func (i PostConditionMode) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PostConditionMode) SetInt64

func (i *PostConditionMode) SetInt64(in int64)

SetInt64 sets the PostConditionMode value from an int64.

func (*PostConditionMode) SetString

func (i *PostConditionMode) SetString(s string) error

SetString sets the PostConditionMode value from its string representation, and returns an error if the string is invalid.

func (PostConditionMode) String

func (i PostConditionMode) String() string

String returns the string representation of this PostConditionMode value.

func (*PostConditionMode) UnmarshalText

func (i *PostConditionMode) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (PostConditionMode) Values

func (i PostConditionMode) Values() []enums.Enum

Values returns all possible values for the type PostConditionMode.

type PostConditionType

type PostConditionType uint8 //enums:enum
const (
	STXPostCondition PostConditionType = iota
	FTPostCondition
	NFTPostCondition
)
const PostConditionTypeN PostConditionType = 3

PostConditionTypeN is the highest valid value for type PostConditionType, plus one.

func PostConditionTypeValues

func PostConditionTypeValues() []PostConditionType

PostConditionTypeValues returns all possible values for the type PostConditionType.

func (*PostConditionType) Decode

func (p *PostConditionType) Decode(r *bytes.Reader) error

Implement Decode for PostConditionType

func (PostConditionType) Desc

func (i PostConditionType) Desc() string

Desc returns the description of the PostConditionType value.

func (PostConditionType) Int64

func (i PostConditionType) Int64() int64

Int64 returns the PostConditionType value as an int64.

func (PostConditionType) MarshalText

func (i PostConditionType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PostConditionType) SetInt64

func (i *PostConditionType) SetInt64(in int64)

SetInt64 sets the PostConditionType value from an int64.

func (*PostConditionType) SetString

func (i *PostConditionType) SetString(s string) error

SetString sets the PostConditionType value from its string representation, and returns an error if the string is invalid.

func (PostConditionType) String

func (i PostConditionType) String() string

String returns the string representation of this PostConditionType value.

func (*PostConditionType) UnmarshalText

func (i *PostConditionType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (PostConditionType) Values

func (i PostConditionType) Values() []enums.Enum

Values returns all possible values for the type PostConditionType.

type Principal

type Principal struct {
	Type         PrincipalType
	Address      Address
	ContractName Name
}

func (*Principal) Decode

func (p *Principal) Decode(r *bytes.Reader) error

Implement Decode for Principal

type PrincipalType

type PrincipalType uint8 //enums:enum
const (
	PrincipalStandard PrincipalType = 0x02
	PrincipalContract PrincipalType = 0x03
	RecipientStandard PrincipalType = 0x05
	RecipientContract PrincipalType = 0x06
)
const PrincipalTypeN PrincipalType = 7

PrincipalTypeN is the highest valid value for type PrincipalType, plus one.

func PrincipalTypeValues

func PrincipalTypeValues() []PrincipalType

PrincipalTypeValues returns all possible values for the type PrincipalType.

func (*PrincipalType) Decode

func (p *PrincipalType) Decode(r *bytes.Reader) error

Implement Decode for PrincipalType

func (PrincipalType) Desc

func (i PrincipalType) Desc() string

Desc returns the description of the PrincipalType value.

func (PrincipalType) Int64

func (i PrincipalType) Int64() int64

Int64 returns the PrincipalType value as an int64.

func (PrincipalType) MarshalText

func (i PrincipalType) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*PrincipalType) SetInt64

func (i *PrincipalType) SetInt64(in int64)

SetInt64 sets the PrincipalType value from an int64.

func (*PrincipalType) SetString

func (i *PrincipalType) SetString(s string) error

SetString sets the PrincipalType value from its string representation, and returns an error if the string is invalid.

func (PrincipalType) String

func (i PrincipalType) String() string

String returns the string representation of this PrincipalType value.

func (*PrincipalType) UnmarshalText

func (i *PrincipalType) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (PrincipalType) Values

func (i PrincipalType) Values() []enums.Enum

Values returns all possible values for the type PrincipalType.

type Response

type Response struct {
	IsOk   bool
	Result ClarityValue
}

func (*Response) ClarityDecode

func (res *Response) ClarityDecode(r *bytes.Reader) error

type STXPostConditionBody

type STXPostConditionBody struct {
	Principal Principal
	Code      FungibleConditionCode
	Amount    uint64
}

func (*STXPostConditionBody) Decode

func (s *STXPostConditionBody) Decode(r *bytes.Reader) error

type STXTransferPayload

type STXTransferPayload struct {
	Recipient Principal
	Amount    uint64
}

func (*STXTransferPayload) Decode

func (s *STXTransferPayload) Decode(r *bytes.Reader) error

Implement Decode for STXTransferPayload

type SingleSigSpendingCondition

type SingleSigSpendingCondition struct {
	PublicKeyEncoding byte
	Signature         [65]byte
}

func (*SingleSigSpendingCondition) Decode

func (sssc *SingleSigSpendingCondition) Decode(r *bytes.Reader) error

Implement Decode for SingleSigSpendingCondition

type SpendingAuthorizationField

type SpendingAuthorizationField struct {
	FieldID byte
	Body    []byte
}

func (*SpendingAuthorizationField) Decode

func (saf *SpendingAuthorizationField) Decode(r *bytes.Reader) error

Implement Decode for SpendingAuthorizationField

type SpendingCondition

type SpendingCondition struct {
	HashMode           HashMode
	PubKeyHash         [20]byte
	Nonce              uint64
	Fee                uint64
	SingleSigCondition *SingleSigSpendingCondition
	MultiSigCondition  *MultiSigSpendingCondition
}

func (*SpendingCondition) Decode

func (s *SpendingCondition) Decode(r *bytes.Reader) error

type StringASCII

type StringASCII struct {
	Length uint32
	Value  string
}

func (*StringASCII) ClarityDecode

func (s *StringASCII) ClarityDecode(r *bytes.Reader) error

type StringUTF8

type StringUTF8 struct {
	Length uint32
	Value  string
}

func (*StringUTF8) ClarityDecode

func (s *StringUTF8) ClarityDecode(r *bytes.Reader) error

type TenureChangeCause

type TenureChangeCause uint8 //enums:enum
const (
	BlockFound TenureChangeCause = iota
	Extend
)
const TenureChangeCauseN TenureChangeCause = 2

TenureChangeCauseN is the highest valid value for type TenureChangeCause, plus one.

func TenureChangeCauseValues

func TenureChangeCauseValues() []TenureChangeCause

TenureChangeCauseValues returns all possible values for the type TenureChangeCause.

func (TenureChangeCause) Desc

func (i TenureChangeCause) Desc() string

Desc returns the description of the TenureChangeCause value.

func (TenureChangeCause) Int64

func (i TenureChangeCause) Int64() int64

Int64 returns the TenureChangeCause value as an int64.

func (TenureChangeCause) MarshalText

func (i TenureChangeCause) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*TenureChangeCause) SetInt64

func (i *TenureChangeCause) SetInt64(in int64)

SetInt64 sets the TenureChangeCause value from an int64.

func (*TenureChangeCause) SetString

func (i *TenureChangeCause) SetString(s string) error

SetString sets the TenureChangeCause value from its string representation, and returns an error if the string is invalid.

func (TenureChangeCause) String

func (i TenureChangeCause) String() string

String returns the string representation of this TenureChangeCause value.

func (*TenureChangeCause) UnmarshalText

func (i *TenureChangeCause) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (TenureChangeCause) Values

func (i TenureChangeCause) Values() []enums.Enum

Values returns all possible values for the type TenureChangeCause.

type TenureChangePayload

type TenureChangePayload struct {
	ConsensusHash          [20]byte
	PrevConsensusHash      [20]byte
	BurnchainConsensusHash [20]byte
	PrevTenureEnd          [32]byte
	Cause                  TenureChangeCause
	PubkeyHash             [20]byte
}

func (*TenureChangePayload) Decode

func (t *TenureChangePayload) Decode(r *bytes.Reader) error

Implement Decode for TenureChangePayload

type Transaction

type Transaction struct {
	Version           NetworkVersion
	CID               ChainID
	Authorization     TransactionAuthorization
	AnchorMode        AnchorMode
	PostConditionMode PostConditionMode
	PostConditions    []*PostCondition
	Payload           Payload
}

func (*Transaction) Decode

func (t *Transaction) Decode(r *bytes.Reader) error

type TransactionAuthorization

type TransactionAuthorization struct {
	Type             AuthorizationType
	OriginCondition  SpendingCondition
	SponsorCondition *SpendingCondition
}

func (*TransactionAuthorization) Decode

type Tuple

type Tuple struct {
	Length uint32
	Values map[string]ClarityValue
}

func (*Tuple) ClarityDecode

func (t *Tuple) ClarityDecode(r *bytes.Reader) error

type UInt128

type UInt128 struct {
	Value *big.Int
}

func (*UInt128) ClarityDecode

func (u *UInt128) ClarityDecode(r *bytes.Reader) error

type VersionedContractDeployPayload

type VersionedContractDeployPayload struct {
	ClarityVersion byte
	ContractDeployPayload
}

func (*VersionedContractDeployPayload) Decode

Implement Decode for VersionedContractDeployPayload

Jump to

Keyboard shortcuts

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