Documentation
¶
Index ¶
- Constants
- func CreateTopic(ctx context.Context, db *sql.DB, topic TopicID, name string, txid string, ...) error
- func EncodeNewsMessage(topic TopicID, headline string, content string) []byte
- func EncodeTopicCreationMessage(topic TopicID, name string, retentionDays int32) []byte
- func OPReturnToReadable(data []byte) string
- func Persist(ctx context.Context, db *sql.DB, values []OPReturn) error
- func TopicExists(ctx context.Context, db *sql.DB, topic TopicID) (bool, error)
- type CoinNews
- type OPReturn
- type Topic
- type TopicID
- type TopicInfo
Constants ¶
const TopicIdLength = 4
Variables ¶
This section is empty.
Functions ¶
func CreateTopic ¶
func EncodeNewsMessage ¶
Format for OP_RETURN message: <topic (4 bytes)><headline (64 bytes)><message (arbitrary length)>
func EncodeTopicCreationMessage ¶
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 ¶
Types ¶
type CoinNews ¶
type CoinNews struct {
ID int64
Topic TopicID
TopicName string
Headline string
Content string
Fee btcutil.Amount
CreatedAt *time.Time
}
func ListCoinNews ¶
ListCoinNews returns OP_RETURNs that match a known topic, with the per-topic retention cutoff applied. Topic match (first 4 bytes / 8 hex chars of op_return_data) and retention are done in SQL; the Go pass only strips topic-creation rows and empty payloads.
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 ¶
List returns the most-recent OP_RETURNs, ordered by created_at desc, capped at `limit`. Pass 0 (or any value <= 0) to skip the cap — only do that when the caller genuinely needs the full table; this table grows linearly with chain height. The returned slice is freshly allocated; element values are shared, so OPReturn fields must be treated read-only.