tapdb

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 70 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNumTxRetries is the default number of times we'll retry a
	// transaction if it fails with an error that permits transaction
	// repetition.
	DefaultNumTxRetries = 10

	// DefaultInitialRetryDelay is the default initial delay between
	// retries. This will be used to generate a random delay between -50%
	// and +50% of this value, so 20 to 60 milliseconds. The retry will be
	// doubled after each attempt until we reach DefaultMaxRetryDelay. We
	// start with a random value to avoid multiple goroutines that are
	// created at the same time to effectively retry at the same time.
	DefaultInitialRetryDelay = time.Millisecond * 40

	// DefaultMaxRetryDelay is the default maximum delay between retries.
	DefaultMaxRetryDelay = time.Second * 3
)
View Source
const (
	// LatestMigrationVersion is the latest migration version of the
	// database.  This is used to implement downgrade protection for the
	// daemon.
	//
	// NOTE: This MUST be updated when a new migration is added.
	LatestMigrationVersion = 25
)
View Source
const (
	PostgresTag = "15"
)
View Source
const StatsCacheDuration = time.Minute * 30

StatsCacheDuration is the duration for which the stats cache is valid.

View Source
const Subsystem = "TADB"

Subsystem defines the logging code for this subsystem.

Variables

View Source
var (
	// ErrFetchMintingBatches is returned when fetching multiple minting
	// batches fails.
	ErrFetchMintingBatches = errors.New("unable to fetch minting batches")

	// ErrBatchParsing is returned when parsing a fetching minting batch
	// fails.
	ErrBatchParsing = errors.New("unable to parse batch")

	// ErrBindBatchTx is returned when binding a tx to a minting batch
	// fails.
	ErrBindBatchTx = errors.New("unable to bind batch tx")

	// ErrEcodePsbt is returned when serializing a PSBT fails.
	ErrEncodePsbt = errors.New("unable to encode psbt")
)
View Source
var (
	// ErrEncodeGenesisPoint is returned when encoding a genesis point
	// before upserting it fails.
	ErrEncodeGenesisPoint = errors.New("unable to encode genesis point")

	// ErrReadOutpoint is returned when decoding an outpoint fails.
	ErrReadOutpoint = errors.New("unable to read outpoint")

	// ErrUpsertGenesisPoint is returned when upserting a genesis point
	// fails.
	ErrUpsertGenesisPoint = errors.New("unable to upsert genesis point")

	// ErrUpsertGroupKey is returned when upserting a group key fails.
	ErrUpsertGroupKey = errors.New("unable to upsert group key")

	// ErrUpsertInternalKey is returned when upserting an internal key
	// fails.
	ErrUpsertInternalKey = errors.New("unable to upsert internal key")

	// ErrUpsertScriptKey is returned when upserting a script key fails.
	ErrUpsertScriptKey = errors.New("unable to upsert script key")

	// ErrNoAssetGroup is returned when no matching asset group is found.
	ErrNoAssetGroup = errors.New("no matching asset group")

	// ErrGroupGenesisInfo is returned when fetching genesis info for an
	// asset group fails.
	ErrGroupGenesisInfo = errors.New("unable to fetch group genesis info")

	// ErrTapscriptRootSize is returned when the given tapscript root is not
	// exactly 32 bytes.
	ErrTapscriptRootSize = errors.New("tapscript root invalid: wrong size")

	// ErrFetchGenesisAsset is returned when fetching the database ID for an
	// asset genesis fails.
	ErrFetchGenesisID = errors.New("unable to fetch genesis asset")
)
View Source
var (
	// TargetLatest is a MigrationTarget that migrates to the latest
	// version available.
	TargetLatest = func(mig *migrate.Migrate, _ int, _ uint) error {
		return mig.Up()
	}

	// TargetVersion is a MigrationTarget that migrates to the given
	// version.
	TargetVersion = func(version uint) MigrationTarget {
		return func(mig *migrate.Migrate, _ int, _ uint) error {
			return mig.Migrate(version)
		}
	}
)
View Source
var (
	// DefaultPostgresFixtureLifetime is the default maximum time a Postgres
	// test fixture is being kept alive. After that time the docker
	// container will be terminated forcefully, even if the tests aren't
	// fully executed yet. So this time needs to be chosen correctly to be
	// longer than the longest expected individual test run time.
	DefaultPostgresFixtureLifetime = 60 * time.Minute
)
View Source
var (
	// DefaultStoreTimeout is the default timeout used for any interaction
	// with the storage/database.
	DefaultStoreTimeout = time.Second * 10
)
View Source
var (
	// ErrMigrationDowngrade is returned when a database downgrade is
	// detected.
	ErrMigrationDowngrade = errors.New("database downgrade detected")
)
View Source
var (
	// ErrNoMultiverseRoot is returned when no universe root is found for
	// the target proof type.
	ErrNoMultiverseRoot = errors.New("no multiverse root found")
)
View Source
var (
	// ErrRetriesExceeded is returned when a transaction is retried more
	// than the max allowed valued without a success.
	ErrRetriesExceeded = errors.New("db tx retries exceeded")
)
View Source
var (
	// MaxValidSQLTime is the maximum valid time that can be rendered as a
	// time string and can be used for comparisons in SQL.
	MaxValidSQLTime = time.Date(9999, 12, 31, 23, 59, 59, 999999, time.UTC)
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func InsertTestdata added in v0.4.0

func InsertTestdata(t *testing.T, db *BaseDB, fileName string)

InsertTestdata reads the given file from the testdata directory and inserts its content into the given database.

func IsDeadlockError added in v0.4.0

func IsDeadlockError(err error) bool

IsDeadlockError returns true if the given error is a deadlock error.

func IsSchemaError added in v0.4.0

func IsSchemaError(err error) bool

IsSchemaError returns true if the given error is a schema error.

func IsSerializationError added in v0.2.1

func IsSerializationError(err error) bool

IsSerializationError returns true if the given error is a serialization error.

func IsSerializationOrDeadlockError added in v0.4.0

func IsSerializationOrDeadlockError(err error) bool

IsSerializationOrDeadlockError returns true if the given error is either a deadlock error or a serialization error.

func MapSQLError

func MapSQLError(err error) error

MapSQLError attempts to interpret a given error as a database agnostic SQL error.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type ActiveAssetsStore

type ActiveAssetsStore interface {
	// UpsertAssetStore houses the methods related to inserting/updating
	// assets.
	UpsertAssetStore

	// QueryAssets fetches the set of fully confirmed assets.
	QueryAssets(context.Context, QueryAssetFilters) ([]ConfirmedAsset,
		error)

	// QueryAssetBalancesByAsset queries the balances for assets or
	// alternatively for a selected one that matches the passed asset ID
	// filter.
	QueryAssetBalancesByAsset(context.Context,
		QueryAssetBalancesByAssetFilters) ([]RawAssetBalance, error)

	// QueryAssetBalancesByGroup queries the asset balances for asset
	// groups or alternatively for a selected one that matches the passed
	// filter.
	QueryAssetBalancesByGroup(context.Context,
		QueryAssetBalancesByGroupFilters) ([]RawAssetGroupBalance,
		error)

	// FetchGroupedAssets fetches all assets with non-nil group keys.
	FetchGroupedAssets(context.Context) ([]RawGroupedAsset, error)

	// FetchAssetProofs fetches all the asset proofs we have stored on
	// disk.
	FetchAssetProofs(ctx context.Context) ([]AssetProof, error)

	// FetchAssetProofsSizes fetches all the asset proofs lengths that are
	// stored on disk.
	FetchAssetProofsSizes(ctx context.Context) ([]AssetProofSize, error)

	// FetchAssetProof fetches the asset proof for a given asset identified
	// by its script key.
	FetchAssetProof(ctx context.Context,
		arg FetchAssetProof) ([]AssetProofI, error)

	// HasAssetProof returns true if we have proof for a given asset
	// identified by its script key.
	HasAssetProof(ctx context.Context, scriptKey []byte) (bool, error)

	// FetchAssetProofsByAssetID fetches all asset proofs for a given asset
	// ID.
	FetchAssetProofsByAssetID(ctx context.Context,
		assetID []byte) ([]AssetProofByIDRow, error)

	// UpsertChainTx inserts a new or updates an existing chain tx into the
	// DB.
	UpsertChainTx(ctx context.Context, arg ChainTxParams) (int64, error)

	// FetchChainTx fetches a chain tx from the DB.
	FetchChainTx(ctx context.Context, txid []byte) (ChainTx, error)

	// UpsertManagedUTXO inserts a new or updates an existing managed UTXO
	// to disk and returns the primary key.
	UpsertManagedUTXO(ctx context.Context, arg RawManagedUTXO) (int64,
		error)

	// FetchAssetID fetches the `asset_id` (primary key) from the assets
	// table for a given asset identified by `Outpoint` and
	// `TweakedScriptKey`.
	FetchAssetID(ctx context.Context, arg FetchAssetID) ([]int64, error)

	// UpsertAssetProofByID inserts a new or updates an existing asset
	// proof on disk.
	UpsertAssetProofByID(ctx context.Context, arg ProofUpdateByID) error

	// UpsertAssetWitness upserts a new prev input for an asset into the
	// database.
	UpsertAssetWitness(context.Context, PrevInput) error

	// FetchAssetWitnesses attempts to fetch either all the asset witnesses
	// on disk (NULL param), or the witness for a given asset ID.
	FetchAssetWitnesses(context.Context, sql.NullInt64) ([]AssetWitness,
		error)

	// FetchManagedUTXO fetches a managed UTXO based on either the outpoint
	// or the transaction that anchors it.
	FetchManagedUTXO(context.Context, UtxoQuery) (AnchorPoint, error)

	// FetchManagedUTXOs fetches all managed UTXOs.
	FetchManagedUTXOs(context.Context) ([]ManagedUTXORow, error)

	// ApplyPendingOutput applies a transfer output (new amount and script
	// key) based on the existing script key of an asset.
	ApplyPendingOutput(ctx context.Context, arg ApplyPendingOutput) (int64,
		error)

	// DeleteManagedUTXO deletes the managed utxo identified by the passed
	// serialized outpoint.
	DeleteManagedUTXO(ctx context.Context, outpoint []byte) error

	// UpdateUTXOLease leases a managed UTXO identified by the passed
	// serialized outpoint.
	UpdateUTXOLease(ctx context.Context, arg UpdateUTXOLease) error

	// DeleteUTXOLease deletes the lease on a managed UTXO identified by
	// the passed serialized outpoint.
	DeleteUTXOLease(ctx context.Context, outpoint []byte) error

	// DeleteExpiredUTXOLeases deletes all expired UTXO leases.
	DeleteExpiredUTXOLeases(ctx context.Context, now sql.NullTime) error

	// ConfirmChainAnchorTx marks a new anchor transaction that was
	// previously unconfirmed as confirmed.
	ConfirmChainAnchorTx(ctx context.Context, arg AnchorTxConf) error

	// InsertAssetTransfer inserts a new asset transfer into the DB.
	InsertAssetTransfer(ctx context.Context,
		arg NewAssetTransfer) (int64, error)

	// InsertAssetTransferInput inserts a new asset transfer input into the
	// DB.
	InsertAssetTransferInput(ctx context.Context,
		arg NewTransferInput) error

	// InsertAssetTransferOutput inserts a new asset transfer output into
	// the DB.
	InsertAssetTransferOutput(ctx context.Context,
		arg NewTransferOutput) error

	// SetTransferOutputProofDeliveryStatus sets the delivery status of a
	// given transfer output proof.
	SetTransferOutputProofDeliveryStatus(ctx context.Context,
		arg OutputProofDeliveryStatus) error

	// FetchTransferInputs fetches the inputs to a given asset transfer.
	FetchTransferInputs(ctx context.Context,
		transferID int64) ([]TransferInputRow, error)

	// FetchTransferOutputs fetches the outputs to a given asset transfer.
	FetchTransferOutputs(ctx context.Context,
		transferID int64) ([]TransferOutputRow, error)

	// QueryAssetTransfers queries for a set of asset transfers in the db.
	QueryAssetTransfers(ctx context.Context,
		query sqlc.QueryAssetTransfersParams) ([]AssetTransferRow,
		error)

	// DeleteAssetWitnesses deletes the witnesses on disk associated with a
	// given asset ID.
	DeleteAssetWitnesses(ctx context.Context, assetID int64) error

	// LogProofTransferAttempt logs a new proof transfer attempt.
	LogProofTransferAttempt(ctx context.Context,
		arg LogProofTransAttemptParams) error

	// QueryProofTransferAttempts returns timestamps from the proof transfer
	// attempts log.
	QueryProofTransferAttempts(ctx context.Context,
		arg QueryProofTransAttemptsParams) ([]time.Time, error)

	// InsertPassiveAsset inserts a new row which includes the data
	// necessary to re-anchor a passive asset.
	InsertPassiveAsset(ctx context.Context, arg NewPassiveAsset) error

	// QueryPassiveAssets returns the data required to re-anchor
	// pending passive assets that are anchored at the given outpoint.
	QueryPassiveAssets(ctx context.Context,
		transferID int64) ([]PassiveAsset, error)

	// ReAnchorPassiveAssets re-anchors the passive assets identified by
	// the passed params.
	ReAnchorPassiveAssets(ctx context.Context, arg ReAnchorParams) error

	// InsertBurn inserts a new row to the asset burns table which
	// includes all important data related to the burn.
	InsertBurn(ctx context.Context, arg sqlc.InsertBurnParams) (int64,
		error)

	// QueryBurns returns all burn entries that match the passed filters.
	QueryBurns(ctx context.Context,
		arg sqlc.QueryBurnsParams) ([]sqlc.QueryBurnsRow, error)
}

ActiveAssetsStore is a sub-set of the main sqlc.Querier interface that contains methods related to querying the set of confirmed assets.

type AddrBook

type AddrBook interface {
	// UpsertAssetStore houses the methods related to inserting/updating
	// assets.
	UpsertAssetStore

	// GroupStore houses the methods related to fetching genesis assets and
	// asset groups related to them.
	GroupStore

	// FetchScriptKeyStore houses the methods related to fetching all
	// information about a script key.
	FetchScriptKeyStore

	// FetchAddrs returns all the addresses based on the constraints of the
	// passed AddrQuery.
	FetchAddrs(ctx context.Context, arg AddrQuery) ([]Addresses, error)

	// FetchAddrByTaprootOutputKey returns a single address based on its
	// Taproot output key or a sql.ErrNoRows error if no such address
	// exists.
	FetchAddrByTaprootOutputKey(ctx context.Context,
		arg []byte) (AddrByTaprootOutput, error)

	// InsertAddr inserts a new address into the database.
	InsertAddr(ctx context.Context, arg NewAddr) (int64, error)

	// UpsertInternalKey inserts a new or updates an existing internal key
	// into the database and returns the primary key.
	UpsertInternalKey(ctx context.Context, arg InternalKey) (int64, error)

	// UpsertScriptKey inserts a new script key on disk into the DB.
	UpsertScriptKey(context.Context, NewScriptKey) (int64, error)

	// SetAddrManaged sets an address as being managed by the internal
	// wallet.
	SetAddrManaged(ctx context.Context, arg AddrManaged) error

	// UpsertManagedUTXO inserts a new or updates an existing managed UTXO
	// to disk and returns the primary key.
	UpsertManagedUTXO(ctx context.Context, arg RawManagedUTXO) (int64,
		error)

	// UpsertChainTx inserts a new or updates an existing chain tx into the
	// DB.
	UpsertChainTx(ctx context.Context, arg ChainTxParams) (int64, error)

	// UpsertAddrEvent inserts a new or updates an existing address event
	// and returns the primary key.
	UpsertAddrEvent(ctx context.Context, arg UpsertAddrEvent) (int64, error)

	// FetchAddrEvent returns a single address event based on its primary
	// key.
	FetchAddrEvent(ctx context.Context, id int64) (AddrEvent, error)

	// FetchAddrEventByAddrKeyAndOutpoint returns a single address event
	// based on its address Taproot output key and outpoint.
	FetchAddrEventByAddrKeyAndOutpoint(ctx context.Context,
		arg FetchAddrEventByOutpoint) (AddrEventByOutpoint, error)

	// QueryEventIDs returns a list of event IDs and their corresponding
	// address IDs that match the given query parameters.
	QueryEventIDs(ctx context.Context, query AddrEventQuery) ([]AddrEventID,
		error)

	// FetchAssetProof fetches the asset proof for a given asset identified
	// by its script key.
	FetchAssetProof(ctx context.Context,
		arg FetchAssetProof) ([]AssetProofI, error)

	// FetchGenesisByAssetID attempts to fetch asset genesis information
	// for a given asset ID.
	FetchGenesisByAssetID(ctx context.Context,
		assetID []byte) (sqlc.GenesisInfoView, error)

	// FetchInternalKeyLocator fetches the key locator for an internal key.
	FetchInternalKeyLocator(ctx context.Context, rawKey []byte) (KeyLocator,
		error)

	// FetchAssetMetaByHash fetches the asset meta for a given meta hash.
	FetchAssetMetaByHash(ctx context.Context,
		metaDataHash []byte) (sqlc.FetchAssetMetaByHashRow, error)

	// FetchAssetMetaForAsset fetches the asset meta for a given asset.
	FetchAssetMetaForAsset(ctx context.Context,
		assetID []byte) (AssetMeta, error)
}

AddrBook is an interface that represents the storage backed needed to create the TapAddressBook book. We need to be able to insert/fetch addresses, and also make internal keys since each address has an internal key and a script key (tho they can be the same).

type AddrBookTxOptions

type AddrBookTxOptions struct {
	// contains filtered or unexported fields
}

AddrBookTxOptions defines the set of db txn options the AddrBook understands.

func (*AddrBookTxOptions) ReadOnly

func (a *AddrBookTxOptions) ReadOnly() bool

ReadOnly returns true if the transaction should be read only.

NOTE: This implements the TxOptions

type AddrByTaprootOutput

type AddrByTaprootOutput = sqlc.FetchAddrByTaprootOutputKeyRow

AddrByTaprootOutput is a type alias for returning an address by its Taproot output key.

type AddrEvent

type AddrEvent = sqlc.FetchAddrEventRow

AddrEvent is a type alias for fetching an address event row.

type AddrEventByOutpoint added in v0.4.0

type AddrEventByOutpoint = sqlc.FetchAddrEventByAddrKeyAndOutpointRow

AddrEventByOutpoint is a type alias for fetching an address event row by outpoint.

type AddrEventID

type AddrEventID = sqlc.QueryEventIDsRow

AddrEventID is a type alias for fetching the ID of an address event and its corresponding address.

type AddrEventQuery

type AddrEventQuery = sqlc.QueryEventIDsParams

AddrEventQuery is a type alias for a query into the set of known address events.

type AddrManaged

type AddrManaged = sqlc.SetAddrManagedParams

AddrManaged is a type alias for setting an address as managed.

type AddrQuery

type AddrQuery = sqlc.FetchAddrsParams

AddrQuery as a type alias for a query into the set of known addresses.

type Addresses

type Addresses = sqlc.FetchAddrsRow

Addresses is a type alias for the full address row with key locator information.

type AggregateStats

type AggregateStats = sqlc.QueryUniverseStatsRow

AggregateStats is used to return the aggregate stats for the entire Universe.

type AnchorPoint

type AnchorPoint = sqlc.FetchManagedUTXORow

AnchorPoint wraps a managed UTXO along with all the auxiliary information it references.

type AnchorTxConf

type AnchorTxConf = sqlc.ConfirmChainAnchorTxParams

AnchorTxConf identifies an unconfirmed anchor tx to confirm.

type ApplyPendingOutput

type ApplyPendingOutput = sqlc.ApplyPendingOutputParams

ApplyPendingOutput is used to update the script key and amount of an existing asset.

type AssetAnchor

type AssetAnchor = sqlc.AnchorPendingAssetsParams

AssetAnchor is used to bind assets on disk with the transaction that will create them on-chain.

type AssetBalance

type AssetBalance struct {
	ID           asset.ID
	Balance      uint64
	Tag          string
	MetaHash     [asset.MetaHashLen]byte
	Type         asset.Type
	GenesisPoint wire.OutPoint
	OutputIndex  uint32
}

AssetBalance holds a balance query result for a particular asset or all assets tracked by this daemon.

type AssetGroupBalance

type AssetGroupBalance struct {
	GroupKey *btcec.PublicKey
	Balance  uint64
}

AssetGroupBalance holds abalance query result for a particular asset group or all asset groups tracked by this daemon.

type AssetGroupKey

type AssetGroupKey = sqlc.UpsertAssetGroupKeyParams

AssetGroupKey is used to insert a new asset key group into the DB.

type AssetGroupWitness added in v0.3.0

type AssetGroupWitness = sqlc.UpsertAssetGroupWitnessParams

AssetGroupWitness is used to insert the group key witness for a given asset on disk.

type AssetHumanReadable

type AssetHumanReadable struct {
	// ID is the unique identifier for the asset.
	ID asset.ID

	// Version is the version of the asset.
	Version asset.Version

	// Amount is the number of units represented by the asset.
	Amount uint64

	// LockTime, if non-zero, restricts an asset from being moved prior to
	// the represented block height in the chain.
	LockTime uint64

	// RelativeLockTime, if non-zero, restricts an asset from being moved
	// until a number of blocks after the confirmation height of the latest
	// transaction for the asset is reached.
	RelativeLockTime uint64

	// Tag is the human-readable identifier for the asset.
	Tag string

	// MetaHash is the hash of the meta data for this asset.
	MetaHash [asset.MetaHashLen]byte

	// Type uniquely identifies the type of Taproot asset.
	Type asset.Type

	// GroupKey is the tweaked public key that is used to associate assets
	// together across distinct asset IDs.
	GroupKey *btcec.PublicKey
}

AssetHumanReadable is a subset of the base asset struct that only includes human-readable asset fields.

type AssetMeta added in v0.5.0

type AssetMeta = sqlc.FetchAssetMetaForAssetRow

AssetMeta is the metadata record for an asset.

type AssetMintingStore

type AssetMintingStore struct {
	// contains filtered or unexported fields
}

AssetMintingStore is an implementation of the tapgarden.PlantingLog interface backed by a persistent database. The abstracted BatchedPendingAssetStore permits re-use of the main storage related business logic for any backend that can implement the specified interface.

func NewAssetMintingStore

func NewAssetMintingStore(db BatchedPendingAssetStore) *AssetMintingStore

NewAssetMintingStore creates a new AssetMintingStore from the specified BatchedPendingAssetStore interface.

func (*AssetMintingStore) AddSeedlingGroups added in v0.4.0

func (a *AssetMintingStore) AddSeedlingGroups(ctx context.Context,
	genesisOutpoint wire.OutPoint, assetGroups []*asset.AssetGroup) error

AddSeedlingGroups stores the asset groups for seedlings associated with a batch.

func (*AssetMintingStore) AddSeedlingsToBatch

func (a *AssetMintingStore) AddSeedlingsToBatch(ctx context.Context,
	batchKey *btcec.PublicKey, seedlings ...*tapgarden.Seedling) error

AddSeedlingsToBatch adds a new set of seedlings to an existing batch.

func (*AssetMintingStore) AddSproutsToBatch

func (a *AssetMintingStore) AddSproutsToBatch(ctx context.Context,
	batchKey *btcec.PublicKey, genesisPacket *tapsend.FundedPsbt,
	assetRoot *commitment.TapCommitment) error

AddSproutsToBatch updates a batch with the passed batch transaction and also binds the genesis transaction (which will create the set of assets in the batch) to the batch itself.

func (*AssetMintingStore) CommitBatchTapSibling added in v0.4.0

func (a *AssetMintingStore) CommitBatchTapSibling(ctx context.Context,
	batchKey *btcec.PublicKey, batchSibling *chainhash.Hash) error

CommitBatchTapSibling updates the tapscript sibling of a batch based on the batch key.

func (*AssetMintingStore) CommitBatchTx added in v0.4.0

func (a *AssetMintingStore) CommitBatchTx(ctx context.Context,
	batchKey *btcec.PublicKey, genesisPacket *tapsend.FundedPsbt) error

CommitBatchTx updates the genesis transaction of a batch based on the batch key.

func (*AssetMintingStore) CommitMintingBatch

func (a *AssetMintingStore) CommitMintingBatch(ctx context.Context,
	newBatch *tapgarden.MintingBatch) error

CommitMintingBatch commits a new minting batch to disk along with any seedlings specified as part of the batch. A new internal key is also created, with the batch referencing that internal key. This internal key will be used as the internal key which will mint all the assets in the batch.

func (*AssetMintingStore) CommitSignedGenesisTx

func (a *AssetMintingStore) CommitSignedGenesisTx(ctx context.Context,
	batchKey *btcec.PublicKey, genesisPkt *tapsend.FundedPsbt,
	anchorOutputIndex uint32, merkleRoot, tapTreeRoot []byte,
	tapSibling []byte) error

CommitSignedGenesisTx binds a fully signed genesis transaction to a pending batch on disk. The anchor output index and script root are also stored to ensure we can reconstruct the private key needed to sign for the batch. The genesis transaction itself is inserted as a new chain transaction, which all other components then reference.

TODO(roasbeef): or could just re-read assets from disk and set the script root manually?

func (*AssetMintingStore) DeleteTapscriptTree added in v0.4.0

func (a *AssetMintingStore) DeleteTapscriptTree(ctx context.Context,
	rootHash chainhash.Hash) error

DeleteTapscriptTree deletes the Tapscript tree with the given root hash, including all nodes and edges.

func (*AssetMintingStore) FetchAllBatches

func (a *AssetMintingStore) FetchAllBatches(
	ctx context.Context) ([]*tapgarden.MintingBatch, error)

FetchAllBatches fetches all batches on disk.

func (*AssetMintingStore) FetchAssetMeta added in v0.4.0

func (a *AssetMintingStore) FetchAssetMeta(ctx context.Context,
	ID asset.ID) (*proof.MetaReveal, error)

FetchAssetMeta fetches the meta reveal for an asset genesis.

func (*AssetMintingStore) FetchGroupByGenesis

func (a *AssetMintingStore) FetchGroupByGenesis(ctx context.Context,
	genesisID int64) (*asset.AssetGroup, error)

FetchGroupByGenesis fetches the asset group created by the genesis referenced by the given ID.

func (*AssetMintingStore) FetchGroupByGroupKey

func (a *AssetMintingStore) FetchGroupByGroupKey(ctx context.Context,
	groupKey *btcec.PublicKey) (*asset.AssetGroup, error)

FetchGroupByGroupKey fetches the asset group with a matching tweaked key, including the genesis information used to create the group.

func (*AssetMintingStore) FetchMintingBatch

func (a *AssetMintingStore) FetchMintingBatch(ctx context.Context,
	batchKey *btcec.PublicKey) (*tapgarden.MintingBatch, error)

FetchMintingBatch fetches the single batch with the given batch key.

func (*AssetMintingStore) FetchNonFinalBatches

func (a *AssetMintingStore) FetchNonFinalBatches(
	ctx context.Context) ([]*tapgarden.MintingBatch, error)

FetchNonFinalBatches fetches all the batches that aren't fully finalized on disk.

func (*AssetMintingStore) FetchScriptKeyByTweakedKey added in v0.4.0

func (a *AssetMintingStore) FetchScriptKeyByTweakedKey(ctx context.Context,
	tweakedKey *btcec.PublicKey) (*asset.TweakedScriptKey, error)

FetchScriptKeyByTweakedKey fetches the populated script key given the tweaked script key.

func (*AssetMintingStore) FetchSeedlingGroups added in v0.4.0

func (a *AssetMintingStore) FetchSeedlingGroups(ctx context.Context,
	genPoint wire.OutPoint, anchorOutputIndex uint32,
	seedlings []*tapgarden.Seedling) ([]*asset.AssetGroup, error)

FetchSeedlingGroups is used to fetch the asset groups for seedlings associated with a funded batch.

func (*AssetMintingStore) LoadTapscriptTree added in v0.4.0

func (a *AssetMintingStore) LoadTapscriptTree(ctx context.Context,
	rootHash chainhash.Hash) (*asset.TapscriptTreeNodes, error)

LoadTapscriptTree loads the Tapscript tree with the given root hash, and decodes the tree into a TapscriptTreeNodes object.

func (*AssetMintingStore) MarkBatchConfirmed

func (a *AssetMintingStore) MarkBatchConfirmed(ctx context.Context,
	batchKey *btcec.PublicKey, blockHash *chainhash.Hash,
	blockHeight uint32, txIndex uint32,
	mintingProofs proof.AssetBlobs) error

MarkBatchConfirmed stores final confirmation information for a batch on disk.

func (*AssetMintingStore) StoreTapscriptTree added in v0.4.0

func (a *AssetMintingStore) StoreTapscriptTree(ctx context.Context,
	treeNodes asset.TapscriptTreeNodes) (*chainhash.Hash, error)

StoreTapscriptTree persists a Tapscript tree given a validated set of TapLeafs or a TapBranch. If the store succeeds, the root hash of the Tapscript tree is returned.

func (*AssetMintingStore) UpdateBatchState

func (a *AssetMintingStore) UpdateBatchState(ctx context.Context,
	batchKey *btcec.PublicKey, newState tapgarden.BatchState) error

UpdateBatchState updates the state of a batch based on the batch key.

type AssetProof

type AssetProof = sqlc.FetchAssetProofsRow

AssetProof is the asset proof for a given asset, identified by its script key.

type AssetProofByIDRow added in v0.3.0

type AssetProofByIDRow = sqlc.FetchAssetProofsByAssetIDRow

AssetProofByIDRow is the asset proof for a given asset, identified by its asset ID.

type AssetProofI

type AssetProofI = sqlc.FetchAssetProofRow

AssetProofI is identical to AssetProof but is used for the case where the proofs for a specific asset are fetched.

type AssetProofSize added in v0.5.0

type AssetProofSize = sqlc.FetchAssetProofsSizesRow

AssetProofSize is the asset proof size for a given asset, identified by its script key.

type AssetQueryFilters

type AssetQueryFilters struct {
	tapfreighter.CommitmentConstraints

	// MinAnchorHeight is the minimum block height the asset's anchor tx
	// must have been confirmed at.
	MinAnchorHeight int32
}

AssetQueryFilters is a wrapper struct over the CommitmentConstraints struct which lets us filter the results of the set of assets returned.

type AssetSeedling

type AssetSeedling = sqlc.AssetSeedling

AssetSeedling is an asset seedling.

type AssetSeedlingItem

type AssetSeedlingItem = sqlc.InsertAssetSeedlingIntoBatchParams

AssetSeedlingItem is used to insert a seedling into an asset based on the batch key of the batch.

type AssetSeedlingShell

type AssetSeedlingShell = sqlc.InsertAssetSeedlingParams

AssetSeedlingShell holds the components of a seedling asset.

type AssetSeedlingTuple

type AssetSeedlingTuple = sqlc.FetchSeedlingIDParams

AssetSeedlingTuple is used to look up the ID of a seedling.

type AssetSprout

type AssetSprout = sqlc.FetchAssetsForBatchRow

AssetSprout is used to fetch the set of assets from disk.

type AssetStatsPerDay added in v0.2.3

type AssetStatsPerDay = sqlc.QueryAssetStatsPerDaySqliteRow

AssetStatsPerDay is the assets stats record for a given day.

type AssetStatsPerDayPg added in v0.2.3

type AssetStatsPerDayPg = sqlc.QueryAssetStatsPerDayPostgresRow

AssetStatsPerDayPg is the assets stats record for a given day (for Postgres).

type AssetStatsPerDayQuery added in v0.2.3

type AssetStatsPerDayQuery = sqlc.QueryAssetStatsPerDaySqliteParams

AssetStatsPerDayQuery is the query used to fetch the asset stats for a given day.

type AssetStatsPerDayQueryPg added in v0.2.3

type AssetStatsPerDayQueryPg = sqlc.QueryAssetStatsPerDayPostgresParams

AssetStatsPerDayQueryPg is the query used to fetch the asset stats for a given day (for Postgres).

type AssetStore

type AssetStore struct {
	// contains filtered or unexported fields
}

AssetStore is used to query for the set of pending and confirmed assets.

func NewAssetStore

func NewAssetStore(db BatchedAssetStore, metaDB BatchedMetaStore,
	clock clock.Clock, dbType sqlc.BackendType) *AssetStore

NewAssetStore creates a new AssetStore from the specified BatchedAssetStore interface.

func (*AssetStore) AssetsDBSize added in v0.5.0

func (a *AssetStore) AssetsDBSize(ctx context.Context) (int64, error)

AssetsDBSize returns the total size of the taproot assets database.

func (*AssetStore) ConfirmProofDelivery added in v0.5.0

func (a *AssetStore) ConfirmProofDelivery(ctx context.Context,
	anchorOutpoint wire.OutPoint, outputPosition uint64) error

ConfirmProofDelivery marks a transfer output proof as successfully delivered to counterparty.

func (*AssetStore) DeleteExpiredLeases added in v0.3.0

func (a *AssetStore) DeleteExpiredLeases(ctx context.Context) error

DeleteExpiredLeases deletes all expired leases from the database.

func (*AssetStore) FetchAllAssets

func (a *AssetStore) FetchAllAssets(ctx context.Context, includeSpent,
	includeLeased bool, query *AssetQueryFilters) ([]*asset.ChainAsset,
	error)

FetchAllAssets fetches the set of confirmed assets stored on disk.

func (*AssetStore) FetchAssetProofs

func (a *AssetStore) FetchAssetProofs(ctx context.Context,
	targetAssets ...proof.Locator) (proof.AssetBlobs, error)

FetchAssetProofs returns the latest proof file for either the set of target assets, or all assets if no script keys for an asset are passed in.

TODO(roasbeef): potentially have a version that writes thru a reader instead?

func (*AssetStore) FetchAssetProofsSizes added in v0.5.0

func (a *AssetStore) FetchAssetProofsSizes(
	ctx context.Context) ([]AssetProofSize, error)

FetchAssetProofsSizes fetches the sizes of the proofs in the db.

func (*AssetStore) FetchCommitment

func (a *AssetStore) FetchCommitment(ctx context.Context, id asset.ID,
	anchorPoint wire.OutPoint, groupKey *asset.GroupKey,
	scriptKey *asset.ScriptKey,
	mustBeLeased bool) (*tapfreighter.AnchoredCommitment, error)

FetchCommitment returns a specific commitment identified by the given asset parameters. If no commitment is found, ErrNoCommitment is returned. With mustBeLeased the caller decides whether the asset output should've been leased before or not. If mustBeLeased is false, then the state of the lease is not checked.

func (*AssetStore) FetchGroupedAssets

func (a *AssetStore) FetchGroupedAssets(ctx context.Context) (
	[]*AssetHumanReadable, error)

FetchGroupedAssets fetches the set of assets with non-nil group keys.

func (*AssetStore) FetchIssuanceProof added in v0.4.0

func (a *AssetStore) FetchIssuanceProof(ctx context.Context, id asset.ID,
	anchorOutpoint wire.OutPoint) (proof.Blob, error)

FetchIssuanceProof fetches the issuance proof for an asset, given the anchor point of the issuance (NOT the genesis point for the asset). For the AssetStore, we leave this unimplemented as we will only use this feature from the FileArchiver.

NOTE: This implements the proof.Archiver interface.

func (*AssetStore) FetchManagedUTXOs

func (a *AssetStore) FetchManagedUTXOs(ctx context.Context) (
	[]*ManagedUTXO, error)

FetchManagedUTXOs fetches all UTXOs we manage.

func (*AssetStore) FetchProof

func (a *AssetStore) FetchProof(ctx context.Context,
	locator proof.Locator) (proof.Blob, error)

FetchProof fetches a proof for an asset uniquely identified by the passed ProofIdentifier.

If a proof cannot be found, then ErrProofNotFound should be returned. If multiple proofs exist for the given fields of the locator then ErrMultipleProofs is returned to indicate more specific fields need to be set in the Locator (e.g. the OutPoint).

NOTE: This implements the proof.Archiver interface.

func (*AssetStore) FetchProofs added in v0.3.0

func (a *AssetStore) FetchProofs(ctx context.Context,
	id asset.ID) ([]*proof.AnnotatedProof, error)

FetchProofs fetches all proofs for assets uniquely identified by the passed asset ID.

NOTE: This implements the proof.Archiver interface.

func (*AssetStore) HasProof added in v0.3.3

func (a *AssetStore) HasProof(ctx context.Context, locator proof.Locator) (bool,
	error)

HasProof returns true if the proof for the given locator exists. This is intended to be a performance optimized lookup compared to fetching a proof and checking for ErrProofNotFound.

func (*AssetStore) ImportProofs

ImportProofs attempts to store fully populated proofs on disk. The previous outpoint of the first state transition will be used as the Genesis point. The final resting place of the asset will be used as the script key itself.

NOTE: This implements the proof.ArchiveBackend interface.

func (*AssetStore) LeaseCoins added in v0.3.0

func (a *AssetStore) LeaseCoins(ctx context.Context, leaseOwner [32]byte,
	expiry time.Time, utxoOutpoints ...wire.OutPoint) error

LeaseCoins leases/locks/reserves coins for the given lease owner until the given expiry. This is used to prevent multiple concurrent coin selection attempts from selecting the same coin(s).

func (*AssetStore) ListEligibleCoins

func (a *AssetStore) ListEligibleCoins(ctx context.Context,
	constraints tapfreighter.CommitmentConstraints) (
	[]*tapfreighter.AnchoredCommitment, error)

ListEligibleCoins lists eligible commitments given a set of constraints.

NOTE: This implements the tapfreighter.CoinLister interface.

func (*AssetStore) LogAnchorTxConfirm added in v0.5.0

func (a *AssetStore) LogAnchorTxConfirm(ctx context.Context,
	conf *tapfreighter.AssetConfirmEvent,
	burns []*tapfreighter.AssetBurn) error

LogAnchorTxConfirm updates the send package state on disk to reflect the confirmation of the anchor transaction, ensuring the on-chain reference information is up to date.

func (*AssetStore) LogPendingParcel

func (a *AssetStore) LogPendingParcel(ctx context.Context,
	spend *tapfreighter.OutboundParcel, finalLeaseOwner [32]byte,
	finalLeaseExpiry time.Time) error

LogPendingParcel marks an outbound parcel as pending on disk. This commits the set of changes to disk (the pending inputs and outputs) but doesn't mark the batched spend as being finalized. The final lease owner and expiry are the lease parameters that are set on the input UTXOs, since we assume the parcel will be broadcast after this call. So we'll want to lock the input UTXOs for forever, which means the expiry should be far in the future.

func (*AssetStore) LogProofTransferAttempt added in v0.3.1

func (a *AssetStore) LogProofTransferAttempt(ctx context.Context,
	locator proof.Locator, transferType proof.TransferType) error

LogProofTransferAttempt logs a proof delivery attempt to disk.

func (*AssetStore) PendingParcels

func (a *AssetStore) PendingParcels(
	ctx context.Context) ([]*tapfreighter.OutboundParcel, error)

PendingParcels returns the set of parcels that have not yet been finalized. A parcel is considered finalized once the on-chain anchor transaction is included in a block, and all pending transfer output proofs have been delivered to their target peers.

NOTE: This can be used to query the set of unconfirmed transactions for re-broadcast and for the set of undelivered proofs.

func (*AssetStore) QueryAssetBalancesByGroup

func (a *AssetStore) QueryAssetBalancesByGroup(ctx context.Context,
	groupKey *btcec.PublicKey,
	includeLeased bool) (map[asset.SerializedKey]AssetGroupBalance,
	error)

QueryAssetBalancesByGroup queries the asset balances for asset groups or alternatively for a selected one that matches the passed filter.

func (*AssetStore) QueryBalancesByAsset

func (a *AssetStore) QueryBalancesByAsset(ctx context.Context,
	assetID *asset.ID,
	includeLeased bool) (map[asset.ID]AssetBalance, error)

QueryBalancesByAsset queries the balances for assets or alternatively for a selected one that matches the passed asset ID filter.

func (*AssetStore) QueryBurns added in v0.5.0

func (a *AssetStore) QueryBurns(ctx context.Context,
	filters QueryBurnsFilters) ([]*tapfreighter.AssetBurn, error)

QueryBurns queries burnt assets based on the passed filters.

func (*AssetStore) QueryParcels

func (a *AssetStore) QueryParcels(ctx context.Context,
	anchorTxHash *chainhash.Hash,
	pendingTransfersOnly bool) ([]*tapfreighter.OutboundParcel, error)

QueryParcels returns the set of confirmed or unconfirmed parcels.

func (*AssetStore) QueryProofTransferLog added in v0.3.1

func (a *AssetStore) QueryProofTransferLog(ctx context.Context,
	locator proof.Locator,
	transferType proof.TransferType) ([]time.Time, error)

QueryProofTransferLog returns timestamps which correspond to logged proof transfer attempts.

func (*AssetStore) RegisterSubscriber

func (a *AssetStore) RegisterSubscriber(
	receiver *fn.EventReceiver[proof.Blob],
	deliverExisting bool, deliverFrom []*proof.Locator) error

RegisterSubscriber adds a new subscriber for receiving events. The deliverExisting boolean indicates whether already existing items should be sent to the NewItemCreated channel when the subscription is started. An optional deliverFrom can be specified to indicate from which timestamp/index/ marker onward existing items should be delivered on startup. If deliverFrom is nil/zero/empty then all existing items will be delivered.

func (*AssetStore) ReleaseCoins added in v0.3.0

func (a *AssetStore) ReleaseCoins(ctx context.Context,
	utxoOutpoints ...wire.OutPoint) error

ReleaseCoins releases/unlocks coins that were previously leased and makes them available for coin selection again.

func (*AssetStore) RemoveSubscriber

func (a *AssetStore) RemoveSubscriber(
	subscriber *fn.EventReceiver[proof.Blob]) error

RemoveSubscriber removes the given subscriber and also stops it from processing events.

func (*AssetStore) TxHeight added in v0.4.0

func (a *AssetStore) TxHeight(ctx context.Context, txid chainhash.Hash) (uint32,
	error)

TxHeight returns the block height of a given transaction. This will only return the height if the transaction is known to the store, which is only the case for assets relevant to this node.

type AssetStoreTxOptions

type AssetStoreTxOptions struct {
	// contains filtered or unexported fields
}

AssetStoreTxOptions defines the set of db txn options the PendingAssetStore understands.

func NewAddrBookReadTx

func NewAddrBookReadTx() AssetStoreTxOptions

NewAddrBookReadTx creates a new read transaction option set.

func NewAssetStoreReadTx

func NewAssetStoreReadTx() AssetStoreTxOptions

NewAssetStoreReadTx creates a new read transaction option set.

func (*AssetStoreTxOptions) ReadOnly

func (r *AssetStoreTxOptions) ReadOnly() bool

ReadOnly returns true if the transaction should be read only.

NOTE: This implements the TxOptions

type AssetTransfer

type AssetTransfer = sqlc.AssetTransfer

AssetTransfer tracks an asset transfer.

type AssetTransferRow

type AssetTransferRow = sqlc.QueryAssetTransfersRow

AssetTransferRow wraps a single transfer row.

type AssetWitness

type AssetWitness = sqlc.FetchAssetWitnessesRow

AssetWitness is the full prev input for an asset that also couples along the asset ID that the witness belong to.

type BaseDB

type BaseDB struct {
	*sql.DB

	*sqlc.Queries
}

BaseDB is the base database struct that each implementation can embed to gain some common functionality.

func (*BaseDB) Backend added in v0.2.3

func (s *BaseDB) Backend() sqlc.BackendType

Backend returns the type of the database backend used.

func (*BaseDB) BeginTx

func (s *BaseDB) BeginTx(ctx context.Context, opts TxOptions) (*sql.Tx, error)

BeginTx wraps the normal sql specific BeginTx method with the TxOptions interface. This interface is then mapped to the concrete sql tx options struct.

type BaseMultiverseOptions added in v0.3.0

type BaseMultiverseOptions struct {
	// contains filtered or unexported fields
}

BaseMultiverseOptions is the set of options for multiverse queries.

func NewBaseMultiverseReadTx added in v0.3.0

func NewBaseMultiverseReadTx() BaseMultiverseOptions

NewBaseMultiverseReadTx creates a new read-only transaction for the multiverse.

func (*BaseMultiverseOptions) ReadOnly added in v0.3.0

func (b *BaseMultiverseOptions) ReadOnly() bool

ReadOnly returns true if the transaction is read-only.

type BaseMultiverseStore added in v0.3.0

type BaseMultiverseStore interface {
	BaseUniverseStore

	// UniverseRoots returns the set of active universe roots for a given
	// Multiverse type.
	UniverseRoots(ctx context.Context,
		params UniverseRootsParams) ([]BaseUniverseRoot, error)

	// QueryMultiverseLeaves is used to query for the set of leaves that
	// reside in a multiverse tree.
	QueryMultiverseLeaves(ctx context.Context,
		arg QueryMultiverseLeaves) ([]MultiverseLeaf, error)

	// FetchMultiverseRoot returns the root of the multiverse tree for a
	// given target namespace (proof type in this case).
	FetchMultiverseRoot(ctx context.Context,
		proofNamespace string) (MultiverseRoot, error)
}

BaseMultiverseStore is used to interact with a set of base universe roots, also known as a multiverse.

type BaseUniverseRoot

type BaseUniverseRoot = sqlc.UniverseRootsRow

BaseUniverseRoot is the type returned from the UniverseRoots query.

type BaseUniverseStore

type BaseUniverseStore interface {
	UpsertAssetStore

	TreeStore

	FetchGenesisStore

	GroupStore

	// QueryUniverseLeaves is used to query for the set of leaves that
	// reside in a universe tree.
	QueryUniverseLeaves(ctx context.Context,
		arg UniverseLeafQuery) ([]UniverseLeaf, error)

	// DeleteUniverseLeaves is used to delete leaves that reside in a
	// universe tree.
	DeleteUniverseLeaves(ctx context.Context, namespace string) error

	// DeleteUniverseRoot is used to delete the root of a universe tree.
	DeleteUniverseRoot(ctx context.Context, namespace string) error

	// DeleteUniverseEvents is used to delete a universe sync event.
	DeleteUniverseEvents(ctx context.Context, namespace string) error

	// FetchUniverseRoot fetches the root of a universe based on the
	// namespace key, which is a function of the asset ID and the group
	// key.
	FetchUniverseRoot(ctx context.Context,
		namespace string) (UniverseRoot, error)

	// UpsertUniverseLeaf upserts a Universe leaf in the database.
	UpsertUniverseLeaf(ctx context.Context, arg UpsertUniverseLeaf) error

	// UpsertUniverseRoot attempts to insert a universe root, returning the
	// existing primary key of the root if already exists.
	UpsertUniverseRoot(ctx context.Context, arg NewUniverseRoot) (int64,
		error)

	// FetchUniverseKeys fetches the set of keys that are currently stored
	// for a given namespace.
	FetchUniverseKeys(ctx context.Context,
		arg UniverseLeafKeysQuery) ([]UniverseKeys, error)

	// UpsertMultiverseRoot upserts a multiverse root in the database.
	UpsertMultiverseRoot(ctx context.Context,
		arg UpsertMultiverseRoot) (int64, error)

	// UpsertMultiverseLeaf upserts a multiverse leaf in the database.
	UpsertMultiverseLeaf(ctx context.Context,
		arg UpsertMultiverseLeaf) (int64, error)

	// DeleteMultiverseLeaf deletes a multiverse leaf from the database.
	DeleteMultiverseLeaf(ctx context.Context,
		arg DeleteMultiverseLeaf) error
}

BaseUniverseStore is the main interface for the Taproot Asset universe store. This is a composite of the capabilities to insert new asset genesis, update the SMT tree, and finally fetch a genesis. We then combine that with Universe specific information to implement all the required interaction.

type BaseUniverseStoreOptions

type BaseUniverseStoreOptions struct {
	// contains filtered or unexported fields
}

BaseUniverseStoreOptions is the set of options for universe tree queries.

func NewBaseUniverseReadTx

func NewBaseUniverseReadTx() BaseUniverseStoreOptions

NewBaseUniverseReadTx creates a new read-only transaction for the base universe.

func (*BaseUniverseStoreOptions) ReadOnly

func (b *BaseUniverseStoreOptions) ReadOnly() bool

ReadOnly returns true if the transaction is read-only.

type BaseUniverseTree

type BaseUniverseTree struct {
	// contains filtered or unexported fields
}

BaseUniverseTree implements the persistent storage for the Base universe for a given asset. The minting outpoints stored of the asset are used to key into the universe tree.

NOTE: This implements the universe.Base interface.

func NewBaseUniverseTree

func NewBaseUniverseTree(db BatchedUniverseTree,
	id universe.Identifier) *BaseUniverseTree

NewBaseUniverseTree creates a new base Universe tree.

func (*BaseUniverseTree) DeleteUniverse added in v0.2.1

func (b *BaseUniverseTree) DeleteUniverse(ctx context.Context) (string, error)

DeleteUniverse deletes the entire universe tree.

func (*BaseUniverseTree) FetchIssuanceProof

func (b *BaseUniverseTree) FetchIssuanceProof(ctx context.Context,
	universeKey universe.LeafKey) ([]*universe.Proof, error)

FetchIssuanceProof returns an issuance proof for the target key. If the key doesn't have a script key specified, then all the proofs for the minting outpoint will be returned. If neither are specified, then proofs for all the inserted leaves will be returned.

func (*BaseUniverseTree) MintingKeys

MintingKeys returns all the keys inserted in the universe.

func (*BaseUniverseTree) MintingLeaves

func (b *BaseUniverseTree) MintingLeaves(
	ctx context.Context) ([]universe.Leaf, error)

MintingLeaves returns all the minting leaves inserted into the universe.

func (*BaseUniverseTree) RegisterIssuance

func (b *BaseUniverseTree) RegisterIssuance(ctx context.Context,
	key universe.LeafKey, leaf *universe.Leaf,
	metaReveal *proof.MetaReveal) (*universe.Proof, error)

RegisterIssuance inserts a new minting leaf within the universe tree, stored at the base key.

func (*BaseUniverseTree) RootNode

func (b *BaseUniverseTree) RootNode(ctx context.Context) (mssmt.Node, string,
	error)

RootNode returns the root node of a universe tree.

type BatchChainUpdate

type BatchChainUpdate = sqlc.BindMintingBatchWithTxParams

BatchChainUpdate is used to update a batch with the minting transaction associated with it.

type BatchStateUpdate

type BatchStateUpdate = sqlc.UpdateMintingBatchStateParams

BatchStateUpdate holds the arguments to update the state of a batch.

type BatchTapSiblingUpdate added in v0.4.0

type BatchTapSiblingUpdate = sqlc.BindMintingBatchWithTapSiblingParams

BatchTapSiblingUpdate is used to update a batch with the root hash of a tapscript sibling associated with it.

type BatchedAddrBook

type BatchedAddrBook interface {
	AddrBook

	BatchedTx[AddrBook]
}

BatchedAddrBook is a version of the AddrBook that's capable of batched database operations.

type BatchedAssetStore

type BatchedAssetStore interface {
	ActiveAssetsStore

	BatchedTx[ActiveAssetsStore]
}

BatchedAssetStore combines the AssetStore interface with the BatchedTx interface, allowing for multiple queries to be executed in a single SQL transaction.

type BatchedKeyStore

type BatchedKeyStore interface {
	KeyStore

	// BatchedTx parametrizes the BatchedTx generic interface w/ KeyStore,
	// which allows us to perform operations to the key store in an atomic
	// transaction. Also add in the TxOptions interface which our defined
	// KeyStoreTxOptions satisfies.
	BatchedTx[KeyStore]
}

BatchedKeyStore is the main storage interface for the RootKeyStore. It supports all the basic queries as well as running the set of queries in a single database transaction.

TODO(roasbeef) use type params here to use slimmer interface instead of sqlc.Querier?

type BatchedMetaStore added in v0.5.0

type BatchedMetaStore interface {
	MetaStore

	BatchedTx[MetaStore]
}

BatchedMetaStore combines the MetaStore interface with the BatchedTx interface, allowing for multiple queries to be executed in a single SQL transaction.

type BatchedMultiverse added in v0.3.0

type BatchedMultiverse interface {
	BaseMultiverseStore

	BatchedTx[BaseMultiverseStore]
}

BatchedMultiverse is a wrapper around the base multiverse that allows us to perform batch transactional database queries with all the relevant query interfaces.

type BatchedPendingAssetStore

type BatchedPendingAssetStore interface {
	PendingAssetStore

	BatchedTx[PendingAssetStore]
}

BatchedPendingAssetStore combines the PendingAssetStore interface with the BatchedTx interface, allowing for multiple queries to be executed in a single SQL transaction.

type BatchedQuerier

type BatchedQuerier interface {
	// Querier is the underlying query source, this is in place so we can
	// pass a BatchedQuerier implementation directly into objects that
	// create a batched version of the normal methods they need.
	sqlc.Querier

	// BeginTx creates a new database transaction given the set of
	// transaction options.
	BeginTx(ctx context.Context, options TxOptions) (*sql.Tx, error)

	// Backend returns the type of the database backend used.
	Backend() sqlc.BackendType
}

BatchedQuerier is a generic interface that allows callers to create a new database transaction based on an abstract type that implements the TxOptions interface.

type BatchedTreeStore

type BatchedTreeStore interface {
	TreeStore

	BatchedTx[TreeStore]
}

BatchedTreeStore is a version of the AddrBook that's capable of batched database operations.

type BatchedTx

type BatchedTx[Q any] interface {
	// ExecTx will execute the passed txBody, operating upon generic
	// parameter Q (usually a storage interface) in a single transaction.
	// The set of TxOptions are passed in in order to allow the caller to
	// specify if a transaction should be read-only and optionally what
	// type of concurrency control should be used.
	ExecTx(ctx context.Context, txOptions TxOptions,
		txBody func(Q) error) error

	// Backend returns the type of the database backend used.
	Backend() sqlc.BackendType
}

BatchedTx is a generic interface that represents the ability to execute several operations to a given storage interface in a single atomic transaction. Typically, Q here will be some subset of the main sqlc.Querier interface allowing it to only depend on the routines it needs to implement any additional business logic.

type BatchedUniverseServerStore

type BatchedUniverseServerStore interface {
	UniverseServerStore

	BatchedTx[UniverseServerStore]
}

BatchedUniverseServerStore allows for batched DB transactions for the universe server store.

type BatchedUniverseStats

type BatchedUniverseStats interface {
	UniverseStatsStore

	BatchedTx[UniverseStatsStore]
}

BatchedUniverseStats is a wrapper around the set of UniverseSyncEvents that supports batched DB operations.

type BatchedUniverseTree

type BatchedUniverseTree interface {
	BaseUniverseStore

	BatchedTx[BaseUniverseStore]
}

BatchedUniverseTree is a wrapper around the base universe tree that allows us to perform batch queries with all the relevant query interfaces.

type ChainTx

type ChainTx = sqlc.ChainTxn

ChainTx is used to fetch a chain tx from disk.

type ChainTxConf

type ChainTxConf = sqlc.ConfirmChainTxParams

ChainTxConf is used to mark a chain tx as being confirmed.

type ChainTxParams

type ChainTxParams = sqlc.UpsertChainTxParams

ChainTxParams is used to insert a new chain tx on disk.

type ChildQuery

type ChildQuery = sqlc.FetchChildrenParams

ChildQuery wraps the args we need to fetch the children of a node.

type ConfirmedAsset

type ConfirmedAsset = sqlc.QueryAssetsRow

ConfirmedAsset is an asset that has been fully confirmed on chain.

type DelNode

type DelNode = sqlc.DeleteNodeParams

DelNode wraps the args we need to delete a node.

type DelUniverseServer

type DelUniverseServer = sqlc.DeleteUniverseServerParams

DelUniverseServer is used to delete a universe server.

type DeleteFedProofSyncLogParams added in v0.3.3

type DeleteFedProofSyncLogParams = sqlc.DeleteFederationProofSyncLogParams

DeleteFedProofSyncLogParams is used to delete proof sync log entries.

type DeleteMultiverseLeaf added in v0.4.0

type DeleteMultiverseLeaf = sqlc.DeleteMultiverseLeafParams

DeleteMultiverseLeaf is used to delete a multiverse leaf.

type ErrDeadlockError added in v0.4.0

type ErrDeadlockError struct {
	DbError error
}

ErrDeadlockError is an error type which represents a database agnostic error where transactions have led to cyclic dependencies in lock acquisition.

func (ErrDeadlockError) Error added in v0.4.0

func (e ErrDeadlockError) Error() string

Error returns the error message.

func (ErrDeadlockError) Unwrap added in v0.4.0

func (e ErrDeadlockError) Unwrap() error

Unwrap returns the wrapped error.

type ErrSchemaError added in v0.4.0

type ErrSchemaError struct {
	DbError error
}

ErrSchemaError is an error type which represents a database agnostic error that the schema of the database is incorrect for the given query.

func (ErrSchemaError) Error added in v0.4.0

func (e ErrSchemaError) Error() string

Error returns the error message.

func (ErrSchemaError) Unwrap added in v0.4.0

func (e ErrSchemaError) Unwrap() error

Unwrap returns the wrapped error.

type ErrSerializationError added in v0.2.1

type ErrSerializationError struct {
	DbError error
}

ErrSerializationError is an error type which represents a database agnostic error that a transaction couldn't be serialized with other concurrent db transactions.

func (ErrSerializationError) Error added in v0.2.1

func (e ErrSerializationError) Error() string

Error returns the error message.

func (ErrSerializationError) Unwrap added in v0.2.1

func (e ErrSerializationError) Unwrap() error

Unwrap returns the wrapped error.

type ErrSqlUniqueConstraintViolation

type ErrSqlUniqueConstraintViolation struct {
	DbError error
}

ErrSqlUniqueConstraintViolation is an error type which represents a database agnostic SQL unique constraint violation.

func (ErrSqlUniqueConstraintViolation) Error

type FedGlobalSyncConfig added in v0.3.0

type FedGlobalSyncConfig = sqlc.FederationGlobalSyncConfig

FedGlobalSyncConfig is the proof type specific global federation sync config returned from a query.

type FedUniSyncConfigs added in v0.3.0

type FedUniSyncConfigs = sqlc.FederationUniSyncConfig

FedUniSyncConfigs is the universe specific federation sync config returned from a query.

type FederationProofSyncLogStore added in v0.3.3

type FederationProofSyncLogStore interface {
	BaseUniverseStore

	// UpsertFederationProofSyncLog upserts a proof sync log entry for a
	// given proof leaf and server.
	UpsertFederationProofSyncLog(ctx context.Context,
		arg UpsertFedProofSyncLogParams) (int64, error)

	// QueryFederationProofSyncLog returns the set of proof sync logs for a
	// given proof leaf.
	QueryFederationProofSyncLog(ctx context.Context,
		arg QueryFedProofSyncLogParams) ([]ProofSyncLogEntry, error)

	// DeleteFederationProofSyncLog deletes proof sync log entries.
	DeleteFederationProofSyncLog(ctx context.Context,
		arg DeleteFedProofSyncLogParams) error
}

FederationProofSyncLogStore is used to log the sync status of individual universe proofs.

type FederationSyncConfigStore added in v0.3.0

type FederationSyncConfigStore interface {
	// UpsertFederationGlobalSyncConfig sets the global federation sync
	// config for a given proof type.
	UpsertFederationGlobalSyncConfig(ctx context.Context,
		arg UpsertFedGlobalSyncConfigParams) error

	// QueryFederationGlobalSyncConfigs returns all global federation sync
	// configurations.
	QueryFederationGlobalSyncConfigs(
		ctx context.Context) ([]FedGlobalSyncConfig, error)

	// UpsertFederationUniSyncConfig inserts or updates a universe specific
	// federation sync config.
	UpsertFederationUniSyncConfig(ctx context.Context,
		arg UpsertFedUniSyncConfigParams) error

	// QueryFederationUniSyncConfigs returns the set of universe specific
	// federation sync configs.
	QueryFederationUniSyncConfigs(ctx context.Context) ([]FedUniSyncConfigs,
		error)
}

FederationSyncConfigStore is used to manage the set of Universe servers as part of a federation.

type FetchAddrEventByOutpoint added in v0.4.0

type FetchAddrEventByOutpoint = sqlc.FetchAddrEventByAddrKeyAndOutpointParams

FetchAddrEventByOutpoint is a type alias for the params to fetch an address event by address and outpoint.

type FetchAssetID added in v0.4.0

type FetchAssetID = sqlc.FetchAssetIDParams

FetchAssetID is used to fetch the primary key ID of an asset, by outpoint and tweaked script key.

type FetchAssetProof added in v0.3.3

type FetchAssetProof = sqlc.FetchAssetProofParams

FetchAssetProof are the query parameters for fetching an asset proof.

type FetchGenesisStore

type FetchGenesisStore interface {
	// FetchGenesisByID returns a single genesis asset by its primary key
	// ID.
	FetchGenesisByID(ctx context.Context, assetID int64) (Genesis, error)
}

FetchGenesisStore houses the methods related to fetching genesis assets.

type FetchScriptKeyStore added in v0.4.0

type FetchScriptKeyStore interface {
	// FetchScriptKeyByTweakedKey attempts to fetch the script key and
	// corresponding internal key from the database.
	FetchScriptKeyByTweakedKey(ctx context.Context,
		tweakedScriptKey []byte) (ScriptKey, error)
}

FetchScriptKeyStore houses the methods related to fetching all information about a script key.

type Genesis

type Genesis = sqlc.FetchGenesisByIDRow

Genesis is a type alias for fetching the genesis asset information.

type GenesisAsset

type GenesisAsset = sqlc.UpsertGenesisAssetParams

GenesisAsset is used to insert the base information of an asset into the DB.

type GenesisPointAnchor

type GenesisPointAnchor = sqlc.AnchorGenesisPointParams

GenesisPointAnchor is used to update the genesis point with the final information w.r.t where it's confirmed on chain.

type GenesisTxUpdate

type GenesisTxUpdate = sqlc.UpdateBatchGenesisTxParams

GenesisTxUpdate is used to update the existing batch TX associated with a batch.

type GroupStore

type GroupStore interface {
	FetchGenesisStore

	// FetchGroupByGenesis fetches information on the asset group created
	// with the asset genesis referenced by a specific genesis ID.
	FetchGroupByGenesis(ctx context.Context,
		genesisID int64) (sqlc.FetchGroupByGenesisRow, error)

	// FetchGroupByGroupKey fetches information on the asset group with
	// a matching group key.
	FetchGroupByGroupKey(ctx context.Context,
		groupKey []byte) (sqlc.FetchGroupByGroupKeyRow, error)
}

GroupStore houses the methods related to fetching specific asset groups.

type InternalKey

type InternalKey = sqlc.UpsertInternalKeyParams

InternalKey holds the arguments to update an internal key.

type KeyLocator added in v0.4.0

type KeyLocator = sqlc.FetchInternalKeyLocatorRow

KeyLocator is a type alias for fetching the key locator information for an internal key.

type KeyStore

type KeyStore interface {
	// GetRootKey fetches the root key associated with the passed ID.
	GetRootKey(ctx context.Context, id []byte) (MacaroonRootKey, error)

	// InsertRootKey inserts a new (id, rootKey) tuple into the database.
	InsertRootKey(ctx context.Context, arg MacaroonID) error
}

KeyStore represents access to a persistence key store for macaroon root key IDs.

type KeyStoreTxOptions

type KeyStoreTxOptions struct {
	// contains filtered or unexported fields
}

KeyStoreTxOptions defines the set of db txn options the KeyStore understands.

func NewKeyStoreReadOpts

func NewKeyStoreReadOpts() *KeyStoreTxOptions

NewKeyStoreReadOpts returns a new KeyStoreTxOptions instance triggers a read transaction.

func (*KeyStoreTxOptions) ReadOnly

func (r *KeyStoreTxOptions) ReadOnly() bool

ReadOnly returns true if the transaction should be read only.

NOTE: This implements the TxOptions

type LogProofTransAttemptParams added in v0.3.1

type LogProofTransAttemptParams = sqlc.LogProofTransferAttemptParams

LogProofTransAttemptParams is a type alias for the params needed to log a proof transfer attempt.

type MacaroonID

type MacaroonID = sqlc.InsertRootKeyParams

MacaroonID is used to insert new (id, rootKey) into the database.

type MacaroonRootKey

type MacaroonRootKey = sqlc.Macaroon

MacaroonRootKey is a tuple of (id, rootKey) that is used to validate + create macaroons.

type ManagedUTXO

type ManagedUTXO struct {
	// OutPoint is the outpoint of the UTXO.
	OutPoint wire.OutPoint

	// OutputValue is the satoshi output value of the UTXO.
	OutputValue btcutil.Amount

	// InternalKey is the internal key that's used to anchor the commitment
	// in the outpoint.
	InternalKey keychain.KeyDescriptor

	// TaprootAssetRoot is the Taproot Asset commitment root hash committed
	// to by this outpoint.
	TaprootAssetRoot []byte

	// MerkleRoot is the Taproot merkle root hash committed to by this
	// outpoint. If there is no Tapscript sibling, this is equal to
	// TaprootAssetRoot.
	MerkleRoot []byte

	// TapscriptSibling is the serialized tapscript sibling preimage of
	// this asset. This will usually be blank.
	TapscriptSibling []byte

	// LeaseOwner is the identifier of the lease owner of this UTXO. If
	// blank, this UTXO isn't leased.
	LeaseOwner []byte

	// LeaseExpiry is the expiry time of the lease on this UTXO. If the
	// zero, then this UTXO isn't leased.
	LeaseExpiry time.Time
}

ManagedUTXO holds information about a given UTXO we manage.

type ManagedUTXORow

type ManagedUTXORow = sqlc.FetchManagedUTXOsRow

ManagedUTXORow wraps a managed UTXO listing row.

type MetaStore added in v0.5.0

type MetaStore interface {
	// AssetsDBSizeSqlite returns the total size of the taproot assets
	// sqlite database.
	AssetsDBSizeSqlite(ctx context.Context) (int32, error)

	// AssetsDBSizePostgres returns the total size of the taproot assets
	// postgres database.
	AssetsDBSizePostgres(ctx context.Context) (int64, error)
}

MetaStore is a sub-set of the main sqlc.Querier interface that contains methods related to metadata of the daemon.

type MigrateOpt added in v0.4.0

type MigrateOpt func(*migrateOptions)

MigrateOpt is a functional option that can be passed to migrate related methods to modify behavior.

func WithLatestVersion added in v0.4.0

func WithLatestVersion(version uint) MigrateOpt

WithLatestVersion allows callers to override the default latest version setting.

type MigrationTarget added in v0.4.0

type MigrationTarget func(mig *migrate.Migrate,
	currentDbVersion int, maxMigrationVersion uint) error

MigrationTarget is a functional option that can be passed to applyMigrations to specify a target version to migrate to. `currentDbVersion` is the current (migration) version of the database, or None if unknown. `maxMigrationVersion` is the maximum migration version known to the driver, or None if unknown.

type MintingBatchA

type MintingBatchA = sqlc.AllMintingBatchesRow

MintingBatchA is an alias for a minting batch returned when querying for all minting batches.

type MintingBatchF

type MintingBatchF = sqlc.FetchMintingBatchRow

MintingBatchF is an alias for a specific minting batch.

type MintingBatchI

MintingBatchI is an alias for a minting batch including the internal key info. This is used to query for batches where the state doesn't match a certain value.

type MintingBatchInit

type MintingBatchInit = sqlc.NewMintingBatchParams

MintingBatchInit is used to create a new minting batch.

type MintingBatchTuple

type MintingBatchTuple = sqlc.UpdateMintingBatchStateParams

MintingBatchTuple is used to update a batch state based on the raw key.

type MultiverseCacheConfig added in v0.5.0

type MultiverseCacheConfig struct {
	// ProofsPerUniverse is the number of proofs that are cached per
	// universe. This number needs to be multiplied by the total number of
	// universes to get the total number of proofs that are cached. There is
	// no limit to the number of universes that can hold cached keys, so a
	// cache is created for each universe that receives a request.
	ProofsPerUniverse uint64 `long:"proofs-per-universe" description:"The number of proofs that are cached per universe."`

	// LeavesNumCachedUniverses is the number of universes that can have a
	// cache of leaf keys. Each cached universe can have up to
	// LeavesPerUniverse keys cached. The total number of cached keys is
	// therefore LeavesNumCachedUniverses * LeavesPerUniverse.
	LeavesNumCachedUniverses uint64 `long:"leaves-num-cached-universes" description:"The number of universes that can have a cache of leaf keys."`

	// LeavesPerUniverse is the number of leaf keys that are cached per
	// universe. This number needs to be multiplied by
	// LeavesNumCachedUniverses to get the total number of leaf keys that
	// are cached.
	LeavesPerUniverse uint64 `long:"leaves-per-universe" description:"The number of leaf keys that are cached per cached universe."`

	// SyncerCacheEnabled is a flag that indicates if the syncer cache is
	// enabled. The syncer cache is used to cache the set of active root
	// nodes for the multiverse tree, which is specifically kept for the
	// universe sync.
	SyncerCacheEnabled bool `long:"syncer-cache-enabled" description:"If the syncer cache is enabled."`

	// SyncerCachePreAllocSize is the pre-allocated size of the syncer
	// cache.
	SyncerCachePreAllocSize uint64 `long:"syncer-cache-pre-alloc-size" description:"The pre-allocated size of the syncer cache."`

	// RootNodePageCacheSize is the size of the root node page cache that
	// serves all paginated queries for root nodes that use different
	// parameters than the syncer cache.
	RootNodePageCacheSize uint64 `` /* 140-byte string literal not displayed */
}

MultiverseCacheConfig is the configuration for the different multiverse caches that exist.

func DefaultMultiverseCacheConfig added in v0.5.0

func DefaultMultiverseCacheConfig() MultiverseCacheConfig

DefaultMultiverseCacheConfig returns the default configuration for the multiverse cache.

type MultiverseLeaf added in v0.4.0

type MultiverseLeaf = sqlc.QueryMultiverseLeavesRow

MultiverseLeaf is a leaf in a multiverse.

type MultiverseRoot added in v0.4.0

type MultiverseRoot = sqlc.FetchMultiverseRootRow

MultiverseRoot is the root of a multiverse tree. Two trees exist: issuance and transfers.

type MultiverseStore added in v0.3.0

type MultiverseStore struct {
	// contains filtered or unexported fields
}

MultiverseStore implements the persistent storage for a multiverse.

NOTE: This implements the universe.MultiverseArchive interface.

func NewMultiverseStore added in v0.3.0

func NewMultiverseStore(db BatchedMultiverse,
	cfg *MultiverseStoreConfig) *MultiverseStore

NewMultiverseStore creates a new multiverse DB store handle.

func (*MultiverseStore) DeleteUniverse added in v0.3.1

func (b *MultiverseStore) DeleteUniverse(ctx context.Context,
	id universe.Identifier) (string, error)

DeleteUniverse delete an entire universe sub-tree.

func (*MultiverseStore) FetchLeaves added in v0.4.0

func (b *MultiverseStore) FetchLeaves(ctx context.Context,
	universeTargets []universe.MultiverseLeafDesc,
	proofType universe.ProofType) ([]universe.MultiverseLeaf, error)

FetchLeaves returns the set of multiverse leaves for the given proof type, asset ID, and group key. If both asset ID and group key is nil, all leaves for the given proof type will be returned.

func (*MultiverseStore) FetchProof added in v0.3.3

func (b *MultiverseStore) FetchProof(ctx context.Context,
	originLocator proof.Locator) (proof.Blob, error)

FetchProof fetches a proof for an asset uniquely identified by the passed Locator. The returned blob contains the encoded full proof file, representing the complete provenance of the asset.

If a proof cannot be found, then ErrProofNotFound is returned.

NOTE: This is part of the proof.NotifyArchiver interface.

func (*MultiverseStore) FetchProofLeaf added in v0.3.0

func (b *MultiverseStore) FetchProofLeaf(ctx context.Context,
	id universe.Identifier,
	universeKey universe.LeafKey) ([]*universe.Proof, error)

FetchProofLeaf returns a proof leaf for the target key. If the key doesn't have a script key specified, then all the proof leafs for the outpoint will be returned. If neither are specified, then all inserted proof leafs will be returned.

func (*MultiverseStore) MultiverseRootNode added in v0.4.0

func (b *MultiverseStore) MultiverseRootNode(ctx context.Context,
	proofType universe.ProofType) (fn.Option[universe.MultiverseRoot],
	error)

MultiverseRootNode returns the root multiverse node for the given proof type.

func (*MultiverseStore) RegisterSubscriber added in v0.3.3

func (b *MultiverseStore) RegisterSubscriber(
	receiver *fn.EventReceiver[proof.Blob], deliverExisting bool,
	deliverFrom []*proof.Locator) error

RegisterSubscriber adds a new subscriber for receiving events. The deliverExisting boolean indicates whether already existing items should be sent to the NewItemCreated channel when the subscription is started. An optional deliverFrom can be specified to indicate from which timestamp/index/ marker onward existing items should be delivered on startup. If deliverFrom is nil/zero/empty then all existing items will be delivered.

func (*MultiverseStore) RemoveSubscriber added in v0.3.3

func (b *MultiverseStore) RemoveSubscriber(
	subscriber *fn.EventReceiver[proof.Blob]) error

RemoveSubscriber removes the given subscriber and also stops it from processing events.

func (*MultiverseStore) RootNodes added in v0.3.0

RootNodes returns the complete set of known base universe root nodes for the set of base universes tracked in the multiverse.

func (*MultiverseStore) UniverseLeafKeys added in v0.3.1

UniverseLeafKeys returns the set of leaf keys for the given universe.

func (*MultiverseStore) UniverseRootNode added in v0.3.1

func (b *MultiverseStore) UniverseRootNode(ctx context.Context,
	id universe.Identifier) (universe.Root, error)

UniverseRootNode returns the Universe root node for the given asset ID.

func (*MultiverseStore) UpsertProofLeaf added in v0.3.0

func (b *MultiverseStore) UpsertProofLeaf(ctx context.Context,
	id universe.Identifier, key universe.LeafKey, leaf *universe.Leaf,
	metaReveal *proof.MetaReveal) (*universe.Proof, error)

UpsertProofLeaf upserts a proof leaf within the multiverse tree and the universe tree that corresponds to the given key.

func (*MultiverseStore) UpsertProofLeafBatch added in v0.3.1

func (b *MultiverseStore) UpsertProofLeafBatch(ctx context.Context,
	items []*universe.Item) error

UpsertProofLeafBatch upserts a proof leaf batch within the multiverse tree and the universe tree that corresponds to the given key(s).

type MultiverseStoreConfig added in v0.5.0

type MultiverseStoreConfig struct {
	// Caches is the set of cache configurations for the multiverse store.
	Caches MultiverseCacheConfig
}

MultiverseStoreConfig is the set of configuration options for the multiverse store.

func DefaultMultiverseStoreConfig added in v0.5.0

func DefaultMultiverseStoreConfig() *MultiverseStoreConfig

DefaultMultiverseStoreConfig returns the default configuration for the multiverse store.

type NewAddr

type NewAddr = sqlc.InsertAddrParams

NewAddr is a type alias for the params to create a new address.

type NewAssetMeta

type NewAssetMeta = sqlc.UpsertAssetMetaParams

NewAssetMeta wraps the params needed to insert a new asset meta on disk.

type NewAssetTransfer

type NewAssetTransfer = sqlc.InsertAssetTransferParams

NewAssetTransfer wraps the params needed to insert a new asset transfer.

type NewBranch

type NewBranch = sqlc.InsertBranchParams

NewBranch is a type alias for the params to create a new mssmt branch node.

type NewCompactedLeaf

type NewCompactedLeaf = sqlc.InsertCompactedLeafParams

NewCompactedLeaf is a type alias for the params to create a new mssmt compacted leaf node.

type NewLeaf

type NewLeaf = sqlc.InsertLeafParams

NewLeaf is a type alias for the params to create a new mssmt leaf node.

type NewPassiveAsset

type NewPassiveAsset = sqlc.InsertPassiveAssetParams

NewPassiveAsset wraps the params needed to insert a new passive asset.

type NewProofEvent

type NewProofEvent = sqlc.InsertNewProofEventParams

NewProofEvent is used to create a new event that logs insertion of a new proof.

type NewScriptKey

type NewScriptKey = sqlc.UpsertScriptKeyParams

NewScriptKey wraps the params needed to insert a new script key on disk.

type NewSyncEvent

type NewSyncEvent = sqlc.InsertNewSyncEventParams

NewSyncEvent is used to create a new event that logs a new Universe leaf sync.

type NewTransferInput

type NewTransferInput = sqlc.InsertAssetTransferInputParams

NewTransferInput wraps the params needed to insert a new transfer input.

type NewTransferOutput

type NewTransferOutput = sqlc.InsertAssetTransferOutputParams

NewTransferOutput wraps the params needed to insert a new transfer output.

type NewUniverseRoot

type NewUniverseRoot = sqlc.UpsertUniverseRootParams

NewUniverseRoot is used to insert a new universe root.

type NewUniverseServer

type NewUniverseServer = sqlc.InsertUniverseServerParams

NewUniverseServer is used to create a new universe server.

type OptionalSeedlingFields added in v0.4.0

type OptionalSeedlingFields struct {
	GroupInternalKeyID sql.NullInt64
	GroupGenesisID     sql.NullInt64
	GroupAnchorID      sql.NullInt64
}

OptionalSeedlingFields contains database IDs for optional seedling fields that have been stored on disk.

type OutputProofDeliveryStatus added in v0.5.0

type OutputProofDeliveryStatus = sqlc.SetTransferOutputProofDeliveryStatusParams

OutputProofDeliveryStatus wraps the params needed to set the delivery status of a given output proof.

nolint: lll

type PassiveAsset

type PassiveAsset = sqlc.QueryPassiveAssetsRow

PassiveAsset tracks a passive asset.

type PendingAssetStore

type PendingAssetStore interface {
	// UpsertAssetStore houses the methods related to inserting/updating
	// assets.
	UpsertAssetStore

	// GroupStore houses the methods related to querying asset groups.
	GroupStore

	// FetchScriptKeyStore houses the methods related to fetching all
	// information about a script key.
	FetchScriptKeyStore

	// TapscriptTreeStore houses the methods related to storing, fetching,
	// and deleting tapscript trees.
	TapscriptTreeStore

	// NewMintingBatch creates a new minting batch.
	NewMintingBatch(ctx context.Context, arg MintingBatchInit) error

	// UpdateMintingBatchState updates the state of an existing minting
	// batch.
	UpdateMintingBatchState(ctx context.Context,
		arg BatchStateUpdate) error

	// InsertAssetSeedling inserts a new asset seedling (base description)
	// into the database.
	InsertAssetSeedling(ctx context.Context, arg AssetSeedlingShell) error

	// InsertAssetSeedlingIntoBatch inserts a new asset seedling into a
	// batch based on the batch key its included in.
	InsertAssetSeedlingIntoBatch(ctx context.Context,
		arg AssetSeedlingItem) error

	// AllMintingBatches is used to fetch all minting batches.
	AllMintingBatches(ctx context.Context) ([]MintingBatchA, error)

	// FetchMintingBatchesByInverseState is used to fetch minting batches
	// that don't have a particular state.
	FetchMintingBatchesByInverseState(ctx context.Context,
		batchState int16) ([]MintingBatchI, error)

	// FetchMintingBatch is used to fetch a single minting batch specified
	// by the batch key.
	FetchMintingBatch(ctx context.Context,
		rawKey []byte) (MintingBatchF, error)

	// FetchSeedlingsForBatch is used to fetch all the seedlings by the key
	// of the batch they're included in.
	FetchSeedlingsForBatch(ctx context.Context,
		rawKey []byte) ([]sqlc.FetchSeedlingsForBatchRow, error)

	// FetchSeedlingID is used to look up the ID of a specific seedling
	// in a batch.
	FetchSeedlingID(ctx context.Context, arg AssetSeedlingTuple) (int64,
		error)

	// FetchSeedlingByID is used to look up a specific seedling.
	FetchSeedlingByID(ctx context.Context,
		seedlingID int64) (AssetSeedling, error)

	// BindMintingBatchWithTapSibling adds a tapscript tree root hash to an
	// existing batch.
	BindMintingBatchWithTapSibling(ctx context.Context,
		arg BatchTapSiblingUpdate) error

	// BindMintingBatchWithTx adds the minting transaction to an existing
	// batch.
	BindMintingBatchWithTx(ctx context.Context, arg BatchChainUpdate) error

	// UpdateBatchGenesisTx updates the batch tx attached to an existing
	// batch.
	UpdateBatchGenesisTx(ctx context.Context, arg GenesisTxUpdate) error

	// UpsertManagedUTXO inserts a new or updates an existing managed UTXO
	// to disk and returns the primary key.
	UpsertManagedUTXO(ctx context.Context, arg RawManagedUTXO) (int64,
		error)

	// AnchorPendingAssets associated an asset on disk with the transaction
	// that once confirmed will mint the asset.
	AnchorPendingAssets(ctx context.Context, arg AssetAnchor) error

	// UpsertChainTx inserts a new or updates an existing chain tx into the
	// DB.
	UpsertChainTx(ctx context.Context, arg ChainTxParams) (int64, error)

	// ConfirmChainTx confirms an existing chain tx.
	ConfirmChainTx(ctx context.Context, arg ChainTxConf) error

	// FetchAssetsForBatch fetches all the assets created by a particular
	// batch.
	FetchAssetsForBatch(ctx context.Context, rawKey []byte) ([]AssetSprout,
		error)

	// FetchAssetID fetches the `asset_id` (primary key) from the assets
	// table for a given asset identified by `Outpoint` and
	// `TweakedScriptKey`.
	FetchAssetID(ctx context.Context, arg FetchAssetID) ([]int64, error)

	// UpsertAssetProofByID inserts a new or updates an existing asset
	// proof on disk.
	UpsertAssetProofByID(ctx context.Context, arg ProofUpdateByID) error

	// FetchAssetMetaForAsset fetches the asset meta for a given asset.
	FetchAssetMetaForAsset(ctx context.Context,
		assetID []byte) (sqlc.FetchAssetMetaForAssetRow, error)
}

PendingAssetStore is a sub-set of the main sqlc.Querier interface that contains only the methods needed to drive the process of batching and creating a new set of assets.

type PostgresConfig

type PostgresConfig struct {
	SkipMigrations     bool          `long:"skipmigrations" description:"Skip applying migrations on startup."`
	Host               string        `long:"host" description:"Database server hostname."`
	Port               int           `long:"port" description:"Database server port."`
	User               string        `long:"user" description:"Database user."`
	Password           string        `long:"password" description:"Database user's password."`
	DBName             string        `long:"dbname" description:"Database name to use."`
	MaxOpenConnections int           `long:"maxconnections" description:"Max open connections to keep alive to the database server."`
	MaxIdleConnections int           `long:"maxidleconnections" description:"Max number of idle connections to keep in the connection pool."`
	ConnMaxLifetime    time.Duration `` /* 139-byte string literal not displayed */
	ConnMaxIdleTime    time.Duration `` /* 137-byte string literal not displayed */
	RequireSSL         bool          `long:"requiressl" description:"Whether to require using SSL (mode: require) when connecting to the server."`
}

PostgresConfig holds the postgres database configuration.

nolint:lll

func (*PostgresConfig) DSN

func (s *PostgresConfig) DSN(hidePassword bool) string

DSN returns the dns to connect to the database.

type PostgresStore

type PostgresStore struct {
	*BaseDB
	// contains filtered or unexported fields
}

PostgresStore is a database store implementation that uses a Postgres backend.

func NewPostgresStore

func NewPostgresStore(cfg *PostgresConfig) (*PostgresStore, error)

NewPostgresStore creates a new store that is backed by a Postgres database backend.

func NewTestPostgresDB

func NewTestPostgresDB(t *testing.T) *PostgresStore

NewTestPostgresDB is a helper function that creates a Postgres database for testing.

func NewTestPostgresDBWithVersion added in v0.4.0

func NewTestPostgresDBWithVersion(t *testing.T, version uint) *PostgresStore

NewTestPostgresDBWithVersion is a helper function that creates a Postgres database for testing and migrates it to the given version.

func (*PostgresStore) ExecuteMigrations added in v0.4.0

func (s *PostgresStore) ExecuteMigrations(target MigrationTarget,
	optFuncs ...MigrateOpt) error

ExecuteMigrations runs migrations for the Postgres database, depending on the target given, either all migrations or up to a given version.

type PrevInput

type PrevInput = sqlc.UpsertAssetWitnessParams

PrevInput stores the full input information including the prev out, and also the witness information itself.

type ProofKey added in v0.3.1

type ProofKey [32]byte

ProofKey is used to uniquely identify a proof within a universe. This is used for the LRU cache for the proofs themselves, which are considered to be immutable.

func NewProofKey added in v0.3.1

func NewProofKey(id universe.Identifier, key universe.LeafKey) ProofKey

NewProofKey takes a universe identifier and leaf key, and returns a proof key.

type ProofSyncLogEntry added in v0.3.3

type ProofSyncLogEntry = sqlc.QueryFederationProofSyncLogRow

ProofSyncLogEntry is a single entry from the proof sync log.

type ProofUpdateByID added in v0.3.3

type ProofUpdateByID = sqlc.UpsertAssetProofByIDParams

ProofUpdateByID is used to update a proof file on disk by asset database ID.

type QueryAssetBalancesByAssetFilters added in v0.5.0

type QueryAssetBalancesByAssetFilters = sqlc.QueryAssetBalancesByAssetParams

QueryAssetBalancesByAssetFilters lets us query the asset balances for assets or alternatively for a selected one that matches the passed filter.

type QueryAssetBalancesByGroupFilters added in v0.5.0

type QueryAssetBalancesByGroupFilters = sqlc.QueryAssetBalancesByGroupParams

QueryAssetBalancesByGroupFilters lets us query the asset balances for asset groups or alternatively for a selected one that matches the passed filter.

type QueryAssetFilters

type QueryAssetFilters = sqlc.QueryAssetsParams

QueryAssetFilters lets us query assets in the database based on some set filters. This is useful to get the balance of a set of assets, or for things like coin selection.

type QueryBurnsFilters added in v0.5.0

type QueryBurnsFilters = sqlc.QueryBurnsParams

QueryBurnsFilters is a set of filters that is applied on the set of the returned burns.

type QueryCreator

type QueryCreator[Q any] func(*sql.Tx) Q

QueryCreator is a generic function that's used to create a Querier, which is a type of interface that implements storage related methods from a database transaction. This will be used to instantiate an object callers can use to apply multiple modifications to an object interface in a single atomic transaction.

type QueryFedProofSyncLogParams added in v0.3.3

type QueryFedProofSyncLogParams = sqlc.QueryFederationProofSyncLogParams

QueryFedProofSyncLogParams is used to query for federation proof sync logs.

type QueryMultiverseLeaves added in v0.4.0

type QueryMultiverseLeaves = sqlc.QueryMultiverseLeavesParams

QueryMultiverseLeaves is used to query for a set of leaves based on the proof type and asset ID (or group key)

type QueryProofTransAttemptsParams added in v0.3.1

type QueryProofTransAttemptsParams = sqlc.QueryProofTransferAttemptsParams

QueryProofTransAttemptsParams is a type alias for the params needed to query the proof transfer attempts log.

type QueryUniServersParams added in v0.3.3

type QueryUniServersParams = sqlc.QueryUniverseServersParams

QueryUniServersParams is used to query for universe servers.

type RawAssetBalance

type RawAssetBalance = sqlc.QueryAssetBalancesByAssetRow

RawAssetBalance holds a balance query result for a particular asset or all assets tracked by this daemon.

type RawAssetGroupBalance

type RawAssetGroupBalance = sqlc.QueryAssetBalancesByGroupRow

RawAssetGroupBalance holds a balance query result for a particular asset group or all asset groups tracked by this daemon.

type RawGroupedAsset

type RawGroupedAsset = sqlc.FetchGroupedAssetsRow

RawGroupedAsset holds the human-readable fields of a single asset with a non-nil group key.

type RawManagedUTXO

type RawManagedUTXO = sqlc.UpsertManagedUTXOParams

RawManagedUTXO is used to insert a new managed UTXO into the database.

type ReAnchorParams

type ReAnchorParams = sqlc.ReAnchorPassiveAssetsParams

ReAnchorParams wraps the params needed to re-anchor a passive asset.

type RootKeyStore

type RootKeyStore struct {
	// contains filtered or unexported fields
}

RootKeyStore is an implementation of the bakery.RootKeyStore interface that'll be used to store macaroons for the project. This uses the sql.Querier interface to have access to the set of storage routines we need to implement the interface.

func NewRootKeyStore

func NewRootKeyStore(db BatchedKeyStore) *RootKeyStore

NewRootKeyStore creates a new RKS from the passed querier interface.

func (*RootKeyStore) Get

func (r *RootKeyStore) Get(ctx context.Context, id []byte) ([]byte, error)

Get returns the root key for the given id. If the item is not there, it returns ErrNotFound.

NOTE: This implements the bakery.RootKeyStore interface.

func (*RootKeyStore) RootKey

func (r *RootKeyStore) RootKey(ctx context.Context) ([]byte, []byte, error)

RootKey returns the root key to be used for making a new macaroon, and an id that can be used to look it up later with the Get method.

NOTE: This implements the bakery.RootKeyStore interface.

type ScriptKey

ScriptKey is a type alias for fetching the script key information.

type SetAssetSpentParams

type SetAssetSpentParams = sqlc.SetAssetSpentParams

SetAssetSpentParams is used to mark an asset as spent.

type SqliteConfig

type SqliteConfig struct {
	// SkipMigrations if true, then all the tables will be created on start
	// up if they don't already exist.
	SkipMigrations bool `long:"skipmigrations" description:"Skip applying migrations on startup."`

	// SkipMigrationDbBackup if true, then a backup of the database will not
	// be created before applying migrations.
	SkipMigrationDbBackup bool `long:"skipmigrationdbbackup" description:"Skip creating a backup of the database before applying migrations."`

	// DatabaseFileName is the full file path where the database file can be
	// found.
	DatabaseFileName string `long:"dbfile" description:"The full path to the database."`
}

SqliteConfig holds all the config arguments needed to interact with our sqlite DB.

nolint: lll

type SqliteStore

type SqliteStore struct {
	*BaseDB
	// contains filtered or unexported fields
}

SqliteStore is a sqlite3 based database for the Taproot Asset daemon.

func NewSqliteStore

func NewSqliteStore(cfg *SqliteConfig) (*SqliteStore, error)

NewSqliteStore attempts to open a new sqlite database based on the passed config.

func NewTestDB

func NewTestDB(t *testing.T) *SqliteStore

NewTestDB is a helper function that creates an SQLite database for testing.

func NewTestDBWithVersion added in v0.4.0

func NewTestDBWithVersion(t *testing.T, version uint) *SqliteStore

NewTestDBWithVersion is a helper function that creates an SQLite database for testing and migrates it to the given version.

func NewTestDbHandleFromPath added in v0.4.0

func NewTestDbHandleFromPath(t *testing.T, dbPath string) *SqliteStore

NewTestDbHandleFromPath is a helper function that creates a new handle to an existing SQLite database for testing.

func NewTestSqliteDB

func NewTestSqliteDB(t *testing.T) *SqliteStore

NewTestSqliteDB is a helper function that creates an SQLite database for testing.

func NewTestSqliteDBWithVersion added in v0.4.0

func NewTestSqliteDBWithVersion(t *testing.T, version uint) *SqliteStore

NewTestSqliteDBWithVersion is a helper function that creates an SQLite database for testing and migrates it to the given version.

func NewTestSqliteDbHandleFromPath added in v0.4.0

func NewTestSqliteDbHandleFromPath(t *testing.T, dbPath string) *SqliteStore

NewTestSqliteDbHandleFromPath is a helper function that creates a SQLite database handle given a database file path.

func (*SqliteStore) ExecuteMigrations added in v0.4.0

func (s *SqliteStore) ExecuteMigrations(target MigrationTarget,
	optFuncs ...MigrateOpt) error

ExecuteMigrations runs migrations for the sqlite database, depending on the target given, either all migrations or up to a given version.

type StoredNode

type StoredNode = sqlc.FetchChildrenRow

StoredNode is a type alias for an arbitrary child of an mssmt branch.

type TapAddressBook

type TapAddressBook struct {
	// contains filtered or unexported fields
}

TapAddressBook represents a storage backend for all the Taproot Asset addresses a daemon has created.

func NewTapAddressBook

func NewTapAddressBook(db BatchedAddrBook, params *address.ChainParams,
	clock clock.Clock) *TapAddressBook

NewTapAddressBook creates a new TapAddressBook instance given a open BatchedAddrBook storage backend.

func (*TapAddressBook) AddrByTaprootOutput

func (t *TapAddressBook) AddrByTaprootOutput(ctx context.Context,
	key *btcec.PublicKey) (*address.AddrWithKeyInfo, error)

AddrByTaprootOutput returns a single address based on its Taproot output key or a sql.ErrNoRows error if no such address exists.

func (*TapAddressBook) CompleteEvent

func (t *TapAddressBook) CompleteEvent(ctx context.Context,
	event *address.Event, status address.Status,
	anchorPoint wire.OutPoint) error

CompleteEvent updates an address event as being complete and links it with the proof and asset that was imported/created for it.

func (*TapAddressBook) FetchAssetMetaByHash added in v0.5.0

func (t *TapAddressBook) FetchAssetMetaByHash(ctx context.Context,
	metaHash [asset.MetaHashLen]byte) (*proof.MetaReveal, error)

FetchAssetMetaByHash attempts to fetch an asset meta based on an asset hash.

func (*TapAddressBook) FetchAssetMetaForAsset added in v0.5.0

func (t *TapAddressBook) FetchAssetMetaForAsset(ctx context.Context,
	assetID asset.ID) (*proof.MetaReveal, error)

FetchAssetMetaForAsset attempts to fetch an asset meta based on an asset ID.

func (*TapAddressBook) FetchInternalKeyLocator added in v0.4.0

func (t *TapAddressBook) FetchInternalKeyLocator(ctx context.Context,
	rawKey *btcec.PublicKey) (keychain.KeyLocator, error)

FetchInternalKeyLocator attempts to fetch the key locator information for the given raw internal key. If the key cannot be found, then ErrInternalKeyNotFound is returned.

func (*TapAddressBook) FetchScriptKey

func (t *TapAddressBook) FetchScriptKey(ctx context.Context,
	tweakedScriptKey *btcec.PublicKey) (*asset.TweakedScriptKey, error)

FetchScriptKey attempts to fetch the full tweaked script key struct (including the key descriptor) for the given tweaked script key. If the key cannot be found, then ErrScriptKeyNotFound is returned.

func (*TapAddressBook) GetOrCreateEvent

func (t *TapAddressBook) GetOrCreateEvent(ctx context.Context,
	status address.Status, addr *address.AddrWithKeyInfo,
	walletTx *lndclient.Transaction, outputIdx uint32) (*address.Event,
	error)

GetOrCreateEvent creates a new address event for the given status, address and transaction. If an event for that address and transaction already exists, then the status and transaction information is updated instead.

func (*TapAddressBook) InsertAddrs

func (t *TapAddressBook) InsertAddrs(ctx context.Context,
	addrs ...address.AddrWithKeyInfo) error

InsertAddrs inserts a new address into the database.

func (*TapAddressBook) InsertAssetGen

func (t *TapAddressBook) InsertAssetGen(ctx context.Context,
	gen *asset.Genesis, group *asset.GroupKey) error

InsertAssetGen inserts a new asset genesis into the database. This is exported primarily for external tests so a genesis can be in place before addr insertion.

func (*TapAddressBook) InsertInternalKey

func (t *TapAddressBook) InsertInternalKey(ctx context.Context,
	keyDesc keychain.KeyDescriptor) error

InsertInternalKey inserts an internal key into the database to make sure it is identified as a local key later on when importing proofs. The key can be an internal key for an asset script key or the internal key of an anchor output.

func (*TapAddressBook) InsertScriptKey

func (t *TapAddressBook) InsertScriptKey(ctx context.Context,
	scriptKey asset.ScriptKey, declaredKnown bool) error

InsertScriptKey inserts an address related script key into the database, so it can be recognized as belonging to the wallet when a transfer comes in later on.

func (*TapAddressBook) QueryAddrEvents

func (t *TapAddressBook) QueryAddrEvents(
	ctx context.Context, params address.EventQueryParams) ([]*address.Event,
	error)

QueryAddrEvents returns a list of event that match the given query parameters.

func (*TapAddressBook) QueryAddrs

QueryAddrs attempts to query for the set of addresses on disk given the passed set of query params.

func (*TapAddressBook) QueryAssetGroup

func (t *TapAddressBook) QueryAssetGroup(ctx context.Context,
	assetID asset.ID) (*asset.AssetGroup, error)

QueryAssetGroup attempts to fetch an asset group by its asset ID. If the asset group cannot be found, then ErrAssetGroupUnknown is returned.

func (*TapAddressBook) QueryEvent added in v0.4.0

func (t *TapAddressBook) QueryEvent(ctx context.Context,
	addr *address.AddrWithKeyInfo, outpoint wire.OutPoint) (*address.Event,
	error)

QueryEvent returns a single address event by its address and outpoint.

func (*TapAddressBook) SetAddrManaged

func (t *TapAddressBook) SetAddrManaged(ctx context.Context,
	addr *address.AddrWithKeyInfo, managedFrom time.Time) error

SetAddrManaged sets an address as being managed by the internal wallet.

type TaprootAssetTreeStore

type TaprootAssetTreeStore struct {
	// contains filtered or unexported fields
}

TaprootAssetTreeStore is an persistent MS-SMT implementation backed by a live SQL database.

func NewTaprootAssetTreeStore

func NewTaprootAssetTreeStore(db BatchedTreeStore,
	namespace string) *TaprootAssetTreeStore

NewTaprootAssetTreeStore creates a new TaprootAssetTreeStore instance given an open BatchedTreeStore storage backend. The namespace argument is required, as it allow us to store several distinct trees on disk in the same table.

func (*TaprootAssetTreeStore) Update

func (t *TaprootAssetTreeStore) Update(ctx context.Context,
	update func(tx mssmt.TreeStoreUpdateTx) error) error

Update updates the persistent tree in the passed-in update closure using the update transaction.

func (*TaprootAssetTreeStore) View

func (t *TaprootAssetTreeStore) View(ctx context.Context,
	update func(tx mssmt.TreeStoreViewTx) error) error

View gives a view of the persistent tree in the passed view closure using the view transaction.

type TapscriptTreeEdge added in v0.4.0

type TapscriptTreeEdge = sqlc.UpsertTapscriptTreeEdgeParams

TapscriptTreeEdge is a type alias for the params needed to insert an edge that links a tapscript tree node to a root hash, and records the order of the node in the tapscript tree.

type TapscriptTreeNode added in v0.4.0

type TapscriptTreeNode = sqlc.FetchTapscriptTreeRow

TapscriptTreeNode is a type alias for a tapscript tree node returned when fetching a tapscript tree, which includes the serialized node and the node index in the tree.

type TapscriptTreeRootHash added in v0.4.0

type TapscriptTreeRootHash = sqlc.UpsertTapscriptTreeRootHashParams

TapscriptTreeRootHash is a type alias for the params needed to insert a tapscript tree root hash.

type TapscriptTreeStore added in v0.4.0

type TapscriptTreeStore interface {
	// UpsertTapscriptTreeRootHash inserts a new tapscript tree root hash.
	UpsertTapscriptTreeRootHash(ctx context.Context,
		rootHash TapscriptTreeRootHash) (int64, error)

	// UpsertTapscriptTreeEdge inserts a new tapscript tree edge that
	// references both a tapscript tree node and a root hash.
	UpsertTapscriptTreeEdge(ctx context.Context,
		edge TapscriptTreeEdge) (int64, error)

	// UpsertTapscriptTreeNode inserts a new tapscript tree node.
	UpsertTapscriptTreeNode(ctx context.Context, node []byte) (int64, error)

	// FetchTapscriptTree fetches all child nodes of a tapscript tree root
	// hash, which can be used to reassemble the tapscript tree.
	FetchTapscriptTree(ctx context.Context,
		rootHash []byte) ([]TapscriptTreeNode, error)

	// DeleteTapscriptTreeEdges deletes all edges that reference the given
	// root hash.
	DeleteTapscriptTreeEdges(ctx context.Context, rootHash []byte) error

	// DeleteTapscriptTreeNodes deletes all nodes that are not referenced by
	// any edge.
	DeleteTapscriptTreeNodes(ctx context.Context) error

	// DeleteTapscriptTreeRoot deletes a tapscript tree root hash.
	DeleteTapscriptTreeRoot(ctx context.Context, rootHash []byte) error
}

TapscriptTreeStore houses the methods related to storing, fetching, and deleting tapscript trees.

type TestPgFixture

type TestPgFixture struct {
	// contains filtered or unexported fields
}

TestPgFixture is a test fixture that starts a Postgres 11 instance in a docker container.

func NewTestPgFixture

func NewTestPgFixture(t *testing.T, expiry time.Duration,
	autoRemove bool) *TestPgFixture

NewTestPgFixture constructs a new TestPgFixture starting up a docker container running Postgres 11. The started container will expire in after the passed duration.

func (*TestPgFixture) ClearDB

func (f *TestPgFixture) ClearDB(t *testing.T)

ClearDB clears the database.

func (*TestPgFixture) GetConfig

func (f *TestPgFixture) GetConfig() *PostgresConfig

GetConfig returns the full config of the Postgres node.

func (*TestPgFixture) GetDSN

func (f *TestPgFixture) GetDSN() string

GetDSN returns the DSN (Data Source Name) for the started Postgres node.

func (*TestPgFixture) TearDown

func (f *TestPgFixture) TearDown(t *testing.T)

TearDown stops the underlying docker container.

type TransactionExecutor

type TransactionExecutor[Query any] struct {
	BatchedQuerier
	// contains filtered or unexported fields
}

TransactionExecutor is a generic struct that abstracts away from the type of query a type needs to run under a database transaction, and also the set of options for that transaction. The QueryCreator is used to create a query given a database transaction created by the BatchedQuerier.

func NewTransactionExecutor

func NewTransactionExecutor[Querier any](db BatchedQuerier,
	createQuery QueryCreator[Querier],
	opts ...TxExecutorOption) *TransactionExecutor[Querier]

NewTransactionExecutor creates a new instance of a TransactionExecutor given a Querier query object and a concrete type for the type of transactions the Querier understands.

func (*TransactionExecutor[Q]) Backend added in v0.2.3

func (t *TransactionExecutor[Q]) Backend() sqlc.BackendType

Backend returns the type of the database backend used.

func (*TransactionExecutor[Q]) ExecTx

func (t *TransactionExecutor[Q]) ExecTx(ctx context.Context,
	txOptions TxOptions, txBody func(Q) error) error

ExecTx is a wrapper for txBody to abstract the creation and commit of a db transaction. The db transaction is embedded in a `*Queries` that txBody needs to use when executing each one of the queries that need to be applied atomically. This can be used by other storage interfaces to parameterize the type of query and options run, in order to have access to batched operations related to a storage object.

type TransferInput

type TransferInput = sqlc.AssetTransferInput

TransferInput tracks the inputs to an asset transfer.

type TransferInputRow

type TransferInputRow = sqlc.FetchTransferInputsRow

TransferInputRow wraps a single transfer input row.

type TransferOutput

type TransferOutput = sqlc.AssetTransferOutput

TransferOutput tracks the outputs to an asset transfer.

type TransferOutputRow

type TransferOutputRow = sqlc.FetchTransferOutputsRow

TransferOutputRow wraps a single transfer output row.

type TransferQuery

type TransferQuery = sqlc.QueryAssetTransfersParams

TransferQuery allows callers to filter out the set of transfers based on set information.

type TreeStore

type TreeStore interface {
	// InsertBranch inserts a new branch to the store.
	InsertBranch(ctx context.Context, newNode NewBranch) error

	// InsertLeaf inserts a new leaf to the store.
	InsertLeaf(ctx context.Context, newNode NewLeaf) error

	// InsertCompactedLeaf inserts a new compacted leaf to the store.
	InsertCompactedLeaf(ctx context.Context, newNode NewCompactedLeaf) error

	// FetchChildren fetches the children (at most two currently) of the
	// passed branch hash key.
	FetchChildren(ctx context.Context, c ChildQuery) ([]StoredNode, error)

	// DeleteNode deletes a node (can be either branch, leaf of compacted
	// leaf) from the store.
	DeleteNode(ctx context.Context, n DelNode) (int64, error)

	// DeleteAllNodes deletes all nodes from the store.
	DeleteAllNodes(ctx context.Context, namespace string) (int64, error)

	// DeleteRoot deletes a root node from the store.
	DeleteRoot(ctx context.Context, namespace string) (int64, error)

	// FetchRootNode fetches the root node for the specified namespace.
	FetchRootNode(ctx context.Context,
		namespace string) (sqlc.MssmtNode, error)

	// UpsertRootNode allows us to update the root node in place for a
	// given namespace.
	UpsertRootNode(ctx context.Context, arg UpdateRoot) error
}

TreeStore is a sub-set of the main sqlc.Querier interface that contains only the methods needed to manipulate and query stored MSSMT trees.

type TreeStoreTxOptions

type TreeStoreTxOptions struct {
	// contains filtered or unexported fields
}

func NewTreeStoreReadTx

func NewTreeStoreReadTx() TreeStoreTxOptions

NewTreeStoreReadTx creates a new read transaction option set.

func (*TreeStoreTxOptions) ReadOnly

func (t *TreeStoreTxOptions) ReadOnly() bool

ReadOnly returns true if the transaction should be read only.

NOTE: This implements the TxOptions

type Tx

type Tx interface {
	// Commit commits the database transaction, an error should be returned
	// if the commit isn't possible.
	Commit() error

	// Rollback rolls back an incomplete database transaction.
	// Transactions that were able to be committed can still call this as a
	// noop.
	Rollback() error
}

Tx represents a database transaction that can be committed or rolled back.

type TxExecutorOption added in v0.2.1

type TxExecutorOption func(*txExecutorOptions)

TxExecutorOption is a functional option that allows us to pass in optional argument when creating the executor.

func WithTxRetries added in v0.2.1

func WithTxRetries(numRetries int) TxExecutorOption

WithTxRetries is a functional option that allows us to specify the number of times a transaction should be retried if it fails with a repeatable error.

func WithTxRetryDelay added in v0.2.1

func WithTxRetryDelay(delay time.Duration) TxExecutorOption

WithTxRetryDelay is a functional option that allows us to specify the delay to wait before a transaction is retried.

type TxOptions

type TxOptions interface {
	// ReadOnly returns true if the transaction should be read only.
	ReadOnly() bool
}

TxOptions represents a set of options one can use to control what type of database transaction is created. Transaction can wither be read or write.

type UniverseFederationDB

type UniverseFederationDB struct {
	// contains filtered or unexported fields
}

UniverseFederationDB is used to manage the set of universe servers by sub-systems that need to manage syncing and pushing new proofs amongst the federation set.

func NewUniverseFederationDB

func NewUniverseFederationDB(db BatchedUniverseServerStore,
	clock clock.Clock) *UniverseFederationDB

NewUniverseFederationDB makes a new Universe federation DB.

func (*UniverseFederationDB) AddServers

func (u *UniverseFederationDB) AddServers(ctx context.Context,
	addrs ...universe.ServerAddr) error

AddServers adds a slice of servers to the federation.

func (*UniverseFederationDB) DeleteProofsSyncLogEntries added in v0.3.3

func (u *UniverseFederationDB) DeleteProofsSyncLogEntries(ctx context.Context,
	servers ...universe.ServerAddr) error

DeleteProofsSyncLogEntries deletes a set of proof sync log entries.

func (*UniverseFederationDB) FetchPendingProofsSyncLog added in v0.3.3

func (u *UniverseFederationDB) FetchPendingProofsSyncLog(ctx context.Context,
	syncDirection *universe.SyncDirection) ([]*universe.ProofSyncLogEntry,
	error)

FetchPendingProofsSyncLog queries the federation proof sync log and returns all log entries with sync status pending.

func (*UniverseFederationDB) LogNewSyncs

func (u *UniverseFederationDB) LogNewSyncs(ctx context.Context,
	addrs ...universe.ServerAddr) error

LogNewSyncs logs a new sync event for each server. This can be used to keep track of the last time we synced with a remote server.

func (*UniverseFederationDB) QueryFederationProofSyncLog added in v0.3.3

func (u *UniverseFederationDB) QueryFederationProofSyncLog(
	ctx context.Context, uniID universe.Identifier,
	leafKey universe.LeafKey,
	syncDirection universe.SyncDirection,
	syncStatus universe.ProofSyncStatus) ([]*universe.ProofSyncLogEntry,
	error)

QueryFederationProofSyncLog queries the federation proof sync log and returns the log entries which correspond to the given universe proof leaf.

func (*UniverseFederationDB) QueryFederationSyncConfigs added in v0.3.0

func (u *UniverseFederationDB) QueryFederationSyncConfigs(
	ctx context.Context) ([]*universe.FedGlobalSyncConfig,
	[]*universe.FedUniSyncConfig, error)

QueryFederationSyncConfigs returns the global and universe specific federation sync configs.

func (*UniverseFederationDB) RemoveServers

func (u *UniverseFederationDB) RemoveServers(ctx context.Context,
	addrs ...universe.ServerAddr) error

RemoveServers removes a set of servers from the federation.

func (*UniverseFederationDB) UniverseServers

func (u *UniverseFederationDB) UniverseServers(
	ctx context.Context) ([]universe.ServerAddr, error)

UniverseServers returns the set of servers in the federation.

func (*UniverseFederationDB) UpsertFederationProofSyncLog added in v0.3.3

func (u *UniverseFederationDB) UpsertFederationProofSyncLog(
	ctx context.Context, uniID universe.Identifier,
	leafKey universe.LeafKey, addr universe.ServerAddr,
	syncDirection universe.SyncDirection,
	syncStatus universe.ProofSyncStatus,
	bumpSyncAttemptCounter bool) (int64, error)

UpsertFederationProofSyncLog upserts a federation proof sync log entry for a given universe server and proof.

func (*UniverseFederationDB) UpsertFederationSyncConfig added in v0.3.0

func (u *UniverseFederationDB) UpsertFederationSyncConfig(
	ctx context.Context, globalSyncConfigs []*universe.FedGlobalSyncConfig,
	uniSyncConfigs []*universe.FedUniSyncConfig) error

UpsertFederationSyncConfig upserts both the global and universe specific federation sync configs.

type UniverseFederationOptions

type UniverseFederationOptions struct {
	// contains filtered or unexported fields
}

UniverseFederationOptions is the database tx object for the universe server store.

func NewUniverseFederationReadTx

func NewUniverseFederationReadTx() UniverseFederationOptions

NewUniverseFederationReadTx returns a new read tx for the federation.

func (*UniverseFederationOptions) ReadOnly

func (b *UniverseFederationOptions) ReadOnly() bool

ReadOnly returns a new read only server.

type UniverseKeys

type UniverseKeys = sqlc.FetchUniverseKeysRow

UniverseKeys is the set of leaf keys inserted into a universe.

type UniverseLeaf

type UniverseLeaf = sqlc.QueryUniverseLeavesRow

UniverseLeaf is a universe leaf.

type UniverseLeafKeysQuery added in v0.3.1

type UniverseLeafKeysQuery = sqlc.FetchUniverseKeysParams

UniverseLeafKeysQuery is used to query for the set of keys that are currently stored for a given namespace.

type UniverseLeafQuery

type UniverseLeafQuery = sqlc.QueryUniverseLeavesParams

UniverseLeafQuery allows callers to query for a set of leaves based on the minting point or the script key.

type UniverseRoot

type UniverseRoot = sqlc.FetchUniverseRootRow

UniverseRoot is the root of a universe tree.

type UniverseRootsParams added in v0.3.1

type UniverseRootsParams = sqlc.UniverseRootsParams

UniverseRootsParams are the parameters for the UniverseRoots query.

type UniverseServerStore

type UniverseServerStore interface {
	FederationSyncConfigStore
	FederationProofSyncLogStore

	// InsertUniverseServer inserts a new universe server in to the DB.
	InsertUniverseServer(ctx context.Context, arg NewUniverseServer) error

	// DeleteUniverseServer removes a universe server from the store.
	DeleteUniverseServer(ctx context.Context, r DelUniverseServer) error

	// LogServerSync marks that a server was just synced in the DB.
	LogServerSync(ctx context.Context, arg sqlc.LogServerSyncParams) error

	// QueryUniverseServers returns a set of universe servers.
	QueryUniverseServers(ctx context.Context,
		arg sqlc.QueryUniverseServersParams) ([]sqlc.UniverseServer,
		error)
}

UniverseServerStore is used to manage the set of Universe servers as part of a federation.

type UniverseStats

type UniverseStats struct {
	// contains filtered or unexported fields
}

UniverseStats is an implementation of the universe.Telemetry interface that is backed by the on-disk Universe event and MS-SMT tree store.

func NewUniverseStats

func NewUniverseStats(db BatchedUniverseStats, clock clock.Clock,
	options ...UniverseStatsOption) *UniverseStats

NewUniverseStats creates a new instance of the UniverseStats backed by the database.

func (*UniverseStats) AggregateSyncStats

func (u *UniverseStats) AggregateSyncStats(
	ctx context.Context) (universe.AggregateStats, error)

AggregateSyncStats returns stats aggregated over all assets within the Universe.

func (*UniverseStats) LogNewProofEvent

func (u *UniverseStats) LogNewProofEvent(ctx context.Context,
	uniID universe.Identifier, key universe.LeafKey) error

LogNewProofEvent logs a new proof insertion event for the target universe.

func (*UniverseStats) LogNewProofEvents added in v0.3.0

func (u *UniverseStats) LogNewProofEvents(ctx context.Context,
	uniIDs ...universe.Identifier) error

LogNewProofEvents logs new proof insertion events for the target universe.

func (*UniverseStats) LogSyncEvent

func (u *UniverseStats) LogSyncEvent(ctx context.Context,
	uniID universe.Identifier, key universe.LeafKey) error

LogSyncEvent logs a sync event for the target universe.

func (*UniverseStats) LogSyncEvents added in v0.3.0

func (u *UniverseStats) LogSyncEvents(ctx context.Context,
	uniIDs ...universe.Identifier) error

LogSyncEvents logs sync events for the target universe.

func (*UniverseStats) QueryAssetStatsPerDay added in v0.2.3

func (u *UniverseStats) QueryAssetStatsPerDay(ctx context.Context,
	q universe.GroupedStatsQuery) ([]*universe.GroupedStats, error)

QueryAssetStatsPerDay returns the stats for all assets grouped by day.

func (*UniverseStats) QuerySyncStats

QuerySyncStats attempts to query the stats for the target universe. For a given asset ID, tag, or type, the set of universe stats is returned which lists information such as the total number of syncs and known proofs for a given Universe server instance.

type UniverseStatsOption added in v0.3.1

type UniverseStatsOption func(*statsOpts)

UniverseStatOption is a functional option that can be used to modify the way that the UniverseStats struct is created.

func WithStatsCacheDuration added in v0.3.1

func WithStatsCacheDuration(d time.Duration) UniverseStatsOption

WithStatsCacheDuration is a functional option that can be used to set the amount of time the stats are cached for.

type UniverseStatsOptions

type UniverseStatsOptions struct {
	// contains filtered or unexported fields
}

UniverseStatsOptions defines the set of txn options for the universe stats.

func NewUniverseStatsReadTx

func NewUniverseStatsReadTx() UniverseStatsOptions

NewUniverseStatsReadTx creates a new read-only transaction for the universe stats instance.

func (*UniverseStatsOptions) ReadOnly

func (u *UniverseStatsOptions) ReadOnly() bool

ReadOnly returns true if the transaction is read-only.

type UniverseStatsQuery

type UniverseStatsQuery = sqlc.QueryUniverseAssetStatsParams

UniverseStatsQuery is used to query the stats for a given universe.

type UniverseStatsResp

type UniverseStatsResp = sqlc.QueryUniverseAssetStatsRow

UniverseStatsResp is used to return the stats for a given universe.

type UniverseStatsStore

type UniverseStatsStore interface {
	// InsertNewProofEvent inserts a new proof event into the database.
	InsertNewProofEvent(ctx context.Context, arg NewProofEvent) error

	// InsertNewSyncEvent inserts a new sync event into the database.
	InsertNewSyncEvent(ctx context.Context, arg NewSyncEvent) error

	// QueryUniverseStats returns the aggregated stats for the entire
	QueryUniverseStats(ctx context.Context) (AggregateStats, error)

	// QueryUniverseAssetStats returns the stats for a given asset within a
	// universe/
	QueryUniverseAssetStats(ctx context.Context,
		arg UniverseStatsQuery) ([]UniverseStatsResp, error)

	// QueryAssetStatsPerDaySqlite returns the stats for a given asset
	// grouped by day in a SQLite specific format.
	QueryAssetStatsPerDaySqlite(ctx context.Context,
		q AssetStatsPerDayQuery) ([]AssetStatsPerDay, error)

	// QueryAssetStatsPerDayPostgres returns the stats for a given asset
	// grouped by day in a Postgres specific format.
	QueryAssetStatsPerDayPostgres(ctx context.Context,
		q AssetStatsPerDayQueryPg) ([]AssetStatsPerDayPg, error)
}

UniverseStatsStore is an interface that defines the methods required to implement the universe.Telemetry interface.

type UpdateRoot

type UpdateRoot = sqlc.UpsertRootNodeParams

UpdateRoot wraps the args we need to update a root node.

type UpdateUTXOLease added in v0.3.0

type UpdateUTXOLease = sqlc.UpdateUTXOLeaseParams

UpdateUTXOLease wraps the params needed to lease a managed UTXO.

type UpsertAddrEvent

type UpsertAddrEvent = sqlc.UpsertAddrEventParams

UpsertAddrEvent is a type alias for creating a new address event or updating an existing one.

type UpsertAssetStore

type UpsertAssetStore interface {
	// UpsertGenesisPoint inserts a new or updates an existing genesis point
	// on disk, and returns the primary key.
	UpsertGenesisPoint(ctx context.Context, prevOut []byte) (int64, error)

	// AnchorGenesisPoint associates a genesis point with the transaction
	// that mints the associated assets on disk.
	AnchorGenesisPoint(ctx context.Context, arg GenesisPointAnchor) error

	// UpsertChainTx inserts a new or updates an existing chain tx into the
	// DB.
	UpsertChainTx(ctx context.Context, arg ChainTxParams) (int64, error)

	// UpsertGenesisAsset inserts a new or updates an existing genesis asset
	// (the base asset info) in the DB, and returns the primary key.
	//
	// TODO(roasbeef): hybrid version of the main tx interface that an
	// accept two diff storage interfaces?
	//
	//  * or use a sort of mix-in type?
	UpsertGenesisAsset(ctx context.Context, arg GenesisAsset) (int64, error)

	// FetchGenesisID is used to fetch the database ID of asset genesis
	// information already in the DB.
	FetchGenesisID(ctx context.Context,
		arg sqlc.FetchGenesisIDParams) (int64, error)

	// FetchScriptKeyIDByTweakedKey determines the database ID of a script
	// key by querying it by the tweaked key.
	FetchScriptKeyIDByTweakedKey(ctx context.Context,
		tweakedScriptKey []byte) (int64, error)

	// UpsertInternalKey inserts a new or updates an existing internal key
	// into the database.
	UpsertInternalKey(ctx context.Context, arg InternalKey) (int64, error)

	// UpsertScriptKey inserts a new script key on disk into the DB.
	UpsertScriptKey(context.Context, NewScriptKey) (int64, error)

	// UpsertAssetGroupWitness inserts a new asset group witness into the DB.
	UpsertAssetGroupWitness(ctx context.Context,
		arg AssetGroupWitness) (int64, error)

	// UpsertAssetGroupKey inserts a new or updates an existing group key
	// on disk, and returns the primary key.
	UpsertAssetGroupKey(ctx context.Context, arg AssetGroupKey) (int64,
		error)

	// QueryAssets fetches a filtered set of fully confirmed assets.
	QueryAssets(context.Context, QueryAssetFilters) ([]ConfirmedAsset,
		error)

	// UpsertAsset inserts a new asset on disk, or returns the ID of the
	// existing asset if it already exists.
	UpsertAsset(ctx context.Context,
		arg sqlc.UpsertAssetParams) (int64, error)

	// UpsertAssetMeta inserts a new asset meta into the DB.
	UpsertAssetMeta(ctx context.Context, arg NewAssetMeta) (int64, error)

	// SetAssetSpent marks an asset as being spent in the database. The
	// updated asset's database ID is returned.
	SetAssetSpent(ctx context.Context, arg SetAssetSpentParams) (int64,
		error)
}

UpsertAssetStore is a sub-set of the main sqlc.Querier interface that contains methods related to inserting/updating assets.

type UpsertFedGlobalSyncConfigParams added in v0.3.0

type UpsertFedGlobalSyncConfigParams = sqlc.UpsertFederationGlobalSyncConfigParams

UpsertFedGlobalSyncConfigParams is used to set the global federation sync configuration for a given proof type.

type UpsertFedProofSyncLogParams added in v0.3.3

type UpsertFedProofSyncLogParams = sqlc.UpsertFederationProofSyncLogParams

UpsertFedProofSyncLogParams is used to upsert federation proof sync logs.

type UpsertFedUniSyncConfigParams added in v0.3.0

type UpsertFedUniSyncConfigParams = sqlc.UpsertFederationUniSyncConfigParams

UpsertFedUniSyncConfigParams is used to set the universe specific federation sync configuration.

type UpsertMultiverseLeaf added in v0.4.0

type UpsertMultiverseLeaf = sqlc.UpsertMultiverseLeafParams

UpsertMultiverseLeaf is used to upsert a multiverse leaf.

type UpsertMultiverseRoot added in v0.4.0

type UpsertMultiverseRoot = sqlc.UpsertMultiverseRootParams

UpsertMultiverseRoot is used to upsert a multiverse root.

type UpsertUniverseLeaf added in v0.3.0

type UpsertUniverseLeaf = sqlc.UpsertUniverseLeafParams

UpsertUniverseLeaf is used to upsert universe leaves.

type UtxoQuery

type UtxoQuery = sqlc.FetchManagedUTXOParams

UtxoQuery lets us query a managed UTXO by either the transaction it references, or the outpoint.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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