opreturns

package
v0.0.0-...-5a53b6d Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const TopicIdLength = 4

Variables

This section is empty.

Functions

func CreateTopic

func CreateTopic(ctx context.Context, db *sql.DB, topic TopicID, name string, txid string, confirmed bool, retentionDays int32) error

func EncodeNewsMessage

func EncodeNewsMessage(topic TopicID, headline string, content string) []byte

Format for OP_RETURN message: <topic (4 bytes)><headline (64 bytes)><message (arbitrary length)>

func EncodeTopicCreationMessage

func EncodeTopicCreationMessage(topic TopicID, name string, retentionDays int32) []byte

Format for OP_RETURN message: <topic>new<retention_days_1byte><title> retention_days is stored as a single byte (0-255, where 0 = infinite)

func OPReturnToReadable

func OPReturnToReadable(data []byte) string

func Persist

func Persist(
	ctx context.Context, db *sql.DB, values []OPReturn,
) error

func TopicExists

func TopicExists(ctx context.Context, db *sql.DB, topic TopicID) (bool, error)

Types

type CoinNews

type CoinNews struct {
	ID        int64
	Topic     TopicID
	TopicName string
	Headline  string
	Content   string
	Fee       btcutil.Amount

	CreatedAt *time.Time
}

func ListCoinNews

func ListCoinNews(ctx context.Context, db *sql.DB) ([]CoinNews, error)

type OPReturn

type OPReturn struct {
	ID        int64
	TxID      string
	Vout      int32
	Data      []byte
	Fee       btcutil.Amount // 0 can either mean zero fee or unknown fee
	Height    *uint32
	CreatedAt *time.Time
}

func List

func List(ctx context.Context, db *sql.DB) ([]OPReturn, error)

type Topic

type Topic struct {
	ID            int64
	Topic         TopicID
	Name          string
	Confirmed     bool
	Txid          string
	RetentionDays int32

	CreatedAt time.Time
}

func ListTopics

func ListTopics(ctx context.Context, db *sql.DB) ([]Topic, error)

type TopicID

type TopicID [TopicIdLength]byte

func ValidNewsTopicID

func ValidNewsTopicID(topic string) (TopicID, error)

func (TopicID) String

func (t TopicID) String() string

type TopicInfo

type TopicInfo struct {
	ID            TopicID
	Name          string
	RetentionDays int32
}

func IsCreateTopic

func IsCreateTopic(data []byte) (TopicInfo, bool)

Jump to

Keyboard shortcuts

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