carrier

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package carrier is the record's transport: one transaction that is never mined, whose output 0 holds the record as PushDrop [S] under the identity's record derivation, and whose txid is the commitment the mined token carries.

A carrier is kept off the chain by BRC-60's device turned the other way round: a far-future nLockTime with a non-final input makes it unmineable in practice, while SPV still verifies it through its funding parent. Nothing in the SDK's verification path reads finality (verified at v1.7.1), so the host admits it like any other object; the topic manager is what refuses one that could reach the chain.

The carrier, funding lock and sweep are the library's (package carrier of github.com/lightwebinc/bcommon); this package is finger's use of them, supplying the record derivation, the funding tag, the record's rules and its identity key, and keeps the API finger's callers were built on.

Index

Constants

View Source
const LockTime = bccarrier.LockTime

LockTime is 2100-01-01T00:00:00Z. With an input whose sequence is below the maximum, a transaction with this nLockTime is not mineable before then. Frozen at the first mint: a reader refuses anything lower.

View Source
const Sequence = bccarrier.Sequence

Sequence is the carrier's input sequence. Any value below 0xFFFFFFFF keeps the locktime in force; zero is the conventional non-final value.

Variables

View Source
var (
	ErrNotCarrier = bccarrier.ErrNotCarrier
	ErrShape      = bccarrier.ErrShape
	ErrMineable   = bccarrier.ErrMineable
	ErrLock       = bccarrier.ErrLock
	ErrSignature  = bccarrier.ErrSignature
	ErrUnlocking  = bccarrier.ErrUnlocking
)

The library's sentinels, the same values, so errors.Is matches either name.

Functions

func Classify

func Classify(s []byte) (bool, error)

Classify takes an output whose first field is a record. An output that is not a record at all (wrong magic, or not a record map) is someone else's PushDrop and skipped; one that is a record but malformed refuses the carrier.

func Commitment

func Commitment(tx *transaction.Transaction) [32]byte

Commitment is the carrier's txid in hash byte order: SHA-256d over the transaction bytes, exactly as the token carries it and as the plane keys the object. It is NOT the display hex reversed.

func DecodeFunding

func DecodeFunding(s *script.Script) (*ec.PublicKey, bool)

DecodeFunding reports whether s is a funding output and returns its locking key.

func FundingLock

func FundingLock(ctx context.Context, w wallet.Interface, originator string) (*script.Script, error)

FundingLock is the script a funding-tree output is locked with: the identity's record key with the funding tag as its one field and no signature, `<key> OP_CHECKSIG <tag> OP_DROP`. The record unlocker's single signature spends it exactly as it would a bare pay-to-public-key; the tag is for the host, which admits funding outputs by it so that a later spend of one (the kill switch) is something it sees.

func Mint

func Mint(ctx context.Context, w wallet.Interface, originator string, rec *record.Record,
	funding *transaction.Transaction, vout uint32) (*transaction.Transaction, error)

Mint builds and signs a carrier for rec, spending output vout of funding through the wallet. Output 0 carries the whole input value back under the record derivation, so the fee is zero and SPV's outputs<=inputs holds.

Only wallet.Interface touches key material: the field signature comes from Lock and the input signature from the record unlocker, so a hardware or remote wallet mints exactly as the embedded one does.

func Params

func Params() bccarrier.Params

Params is finger's carrier: the record key under token.Protocol, the funding tag, a record's decode and own rules as the payload's rules, and record.ErrField as the identity sentinel, so an identity key that does not parse still reads "record: field has the wrong shape: identity key: ...". token.Protocol and token.FundingTag are vars and are read on every call, so no copy of them is held here to disagree with them.

func Sweep

func Sweep(ctx context.Context, w wallet.Interface, originator string, tree *transaction.Transaction, vouts []uint32,
	fee *transaction.Transaction, feeVout uint32, feeUnlocker transaction.UnlockingScriptTemplate, change *script.Script, feeRate, floor uint64) (*transaction.Transaction, error)

Sweep builds and signs the kill switch over the given outputs of a funding tree, with a funding-shaped tombstone at output 0; see the library's Sweep for the shape and why the tombstone is there.

func SweepAt added in v0.6.0

func SweepAt(ctx context.Context, w wallet.Interface, originator string, tree *transaction.Transaction, vouts []uint32,
	fee *transaction.Transaction, feeVout uint32, feeUnlocker transaction.UnlockingScriptTemplate, change *script.Script, fees bcmint.Fees) (*transaction.Transaction, error)

SweepAt is Sweep at a fee policy, the same one minting pays by: the policy's rate (a fraction of a satoshi a byte included) rounded up, at least its floor; see the library's SweepAt.

Types

type Carrier

type Carrier struct {
	Tx          *transaction.Transaction
	OutputIndex uint32
	Record      *record.Record
	// RecordBytes are the exact bytes pushed, which the field signature covers
	// and which a re-encode must reproduce.
	RecordBytes []byte
	LockingKey  *ec.PublicKey
	Signature   []byte
}

Carrier is a decoded carrier transaction.

func Decode

func Decode(tx *transaction.Transaction) (*Carrier, error)

Decode finds the one record output. A transaction with no record output is not a carrier; one with two is refused as well, because the commitment would then name two records at once.

func (*Carrier) Validate

func (c *Carrier) Validate() error

Validate applies what a carrier must satisfy on its own: the record's own rules, unmineability, the lock derivation from the record's identity key, and the field signature under that lock. The chain rules that need the previous state (prev, witness, sequence) belong to the verifier and the lookup service, not here.

The record's rules are applied to c.Record, the record Decode already holds, rather than to a fresh decode of RecordBytes: Validate has always judged that value, and the two differ only when a caller changed one of them.

Jump to

Keyboard shortcuts

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