queries

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	AssetID        string
	ControlAssetID sql.NullString
	Metadata       sql.NullString
}

type AssetVtxo

type AssetVtxo struct {
	VtxoTxid string
	VtxoVout int64
	AssetID  string
	Amount   int64
}

type AssetVtxoVw

type AssetVtxoVw struct {
	Txid            string
	Vout            int64
	Script          string
	Amount          int64
	CommitmentTxids string
	SpentBy         sql.NullString
	Spent           bool
	ExpiresAt       int64
	CreatedAt       int64
	Preconfirmed    bool
	Swept           bool
	SettledBy       sql.NullString
	Unrolled        bool
	ArkTxid         sql.NullString
	AssetID         sql.NullString
	AssetAmount     sql.NullInt64
}

type Contract added in v0.10.0

type Contract struct {
	Script    string
	Type      string
	Label     sql.NullString
	Address   string
	State     string
	CreatedAt int64
	Params    string
	KeyIndex  int64
	Metadata  sql.NullString
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DeleteUtxoParams

type DeleteUtxoParams struct {
	Txid string
	Vout int64
}

type GetVtxosParams added in v0.10.0

type GetVtxosParams struct {
	StatusFilter    sql.NullString
	AssetID         sql.NullString
	ScriptFilter    sql.NullString
	CursorCreatedAt sql.NullInt64
	CursorTxid      sql.NullString
	CursorVout      sql.NullInt64
	LimitPlusOne    int64
}

type InsertAssetVtxoParams

type InsertAssetVtxoParams struct {
	VtxoTxid string
	VtxoVout int64
	AssetID  string
	Amount   int64
}

type InsertContractParams added in v0.10.0

type InsertContractParams struct {
	Script    string
	Type      string
	Label     sql.NullString
	Address   string
	State     string
	CreatedAt int64
	Params    string
	KeyIndex  int64
	Metadata  sql.NullString
}

type InsertTxParams

type InsertTxParams struct {
	Txid        string
	TxidType    string
	Amount      int64
	Type        string
	CreatedAt   int64
	Hex         sql.NullString
	SettledBy   sql.NullString
	Settled     bool
	AssetPacket sql.NullString
}

type InsertUtxoParams

type InsertUtxoParams struct {
	Txid        string
	Vout        int64
	Script      string
	Amount      int64
	SpentBy     sql.NullString
	Spent       bool
	Tapscripts  sql.NullString
	SpendableAt sql.NullInt64
	CreatedAt   sql.NullInt64
	DelayValue  sql.NullInt64
	DelayType   sql.NullString
	Tx          sql.NullString
}

type InsertVtxoParams

type InsertVtxoParams struct {
	Txid            string
	Vout            int64
	Script          string
	Amount          int64
	CommitmentTxids string
	SpentBy         sql.NullString
	Spent           bool
	Preconfirmed    bool
	ExpiresAt       int64
	CreatedAt       int64
	Swept           bool
	Unrolled        bool
	SettledBy       sql.NullString
	ArkTxid         sql.NullString
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CleanAssetVtxos

func (q *Queries) CleanAssetVtxos(ctx context.Context) error

func (*Queries) CleanAssets

func (q *Queries) CleanAssets(ctx context.Context) error

func (*Queries) CleanContracts added in v0.10.0

func (q *Queries) CleanContracts(ctx context.Context) error

func (*Queries) CleanTxs

func (q *Queries) CleanTxs(ctx context.Context) error

func (*Queries) CleanUtxos

func (q *Queries) CleanUtxos(ctx context.Context) error

func (*Queries) CleanVtxos

func (q *Queries) CleanVtxos(ctx context.Context) error

func (*Queries) DeleteUtxo

func (q *Queries) DeleteUtxo(ctx context.Context, arg DeleteUtxoParams) error

func (*Queries) GetVtxos added in v0.10.0

func (q *Queries) GetVtxos(ctx context.Context, arg GetVtxosParams) ([]AssetVtxoVw, error)

Cursor-based keyset pagination over VTXOs. Two stages. Stage 1, page_keys CTE, scans the base vtxo table (one row per VTXO so LIMIT counts VTXOs not asset rows), applies status and asset filters, applies the cursor predicate, sorts by (created_at DESC, txid DESC, vout DESC) using the matching composite index for an O(log n + limit) scan, and LIMITs at the SQL layer. Stage 2 INNER JOINs the paged keys against asset_vtxo_vw to hydrate assets in one round-trip; applying LIMIT to the view directly would cut multi-asset VTXOs mid-way. The caller passes (user_limit + 1) as limit_plus_one. The extra row is a has-more sentinel; if SQL returns more than user_limit rows the caller trims the last one and uses its outpoint as the next cursor. status_filter accepts NULL (no filter), spendable (spent=false AND unrolled=false), or spent (spent=true OR unrolled=true). asset_id uses EXISTS rather than JOIN so the row count stays at VTXO count. script_filter filters by exact match on the vtxo.script column (NULL = no filter). The cursor predicate uses SQL row-value comparison which is the canonical composite-key keyset idiom. CAST wrappers around sqlc.narg are required so sqlc emits typed nullable Go args instead of interface{}. WARNING: do not put inline -- comments inside the query body below; sqlc's query splitter breaks downstream queries when the GetVtxos body contains inline comments. Keep all docs here in the header.

func (*Queries) InsertAssetVtxo

func (q *Queries) InsertAssetVtxo(ctx context.Context, arg InsertAssetVtxoParams) error

func (*Queries) InsertContract added in v0.10.0

func (q *Queries) InsertContract(ctx context.Context, arg InsertContractParams) error

func (*Queries) InsertTx

func (q *Queries) InsertTx(ctx context.Context, arg InsertTxParams) error

func (*Queries) InsertUtxo

func (q *Queries) InsertUtxo(ctx context.Context, arg InsertUtxoParams) error

func (*Queries) InsertVtxo

func (q *Queries) InsertVtxo(ctx context.Context, arg InsertVtxoParams) error

func (*Queries) ReplaceTx

func (q *Queries) ReplaceTx(ctx context.Context, arg ReplaceTxParams) error

func (*Queries) SelectActiveContractsByType added in v0.10.1

func (q *Queries) SelectActiveContractsByType(ctx context.Context, type_ string) ([]Contract, error)

func (*Queries) SelectAllContracts added in v0.10.0

func (q *Queries) SelectAllContracts(ctx context.Context) ([]Contract, error)

func (*Queries) SelectAllTxs

func (q *Queries) SelectAllTxs(ctx context.Context) ([]Tx, error)

func (*Queries) SelectAllUtxos

func (q *Queries) SelectAllUtxos(ctx context.Context) ([]Utxo, error)

func (*Queries) SelectAsset

func (q *Queries) SelectAsset(ctx context.Context, assetID string) (Asset, error)

func (*Queries) SelectContractsByScripts added in v0.10.0

func (q *Queries) SelectContractsByScripts(ctx context.Context, scripts []string) ([]Contract, error)

func (*Queries) SelectContractsByState added in v0.10.0

func (q *Queries) SelectContractsByState(ctx context.Context, state string) ([]Contract, error)

func (*Queries) SelectLatestActiveContractByType added in v0.10.1

func (q *Queries) SelectLatestActiveContractByType(ctx context.Context, contractType string) (Contract, error)

func (*Queries) SelectSpendableOrRecoverableVtxos added in v0.10.0

func (q *Queries) SelectSpendableOrRecoverableVtxos(ctx context.Context) ([]AssetVtxoVw, error)

func (*Queries) SelectTxs

func (q *Queries) SelectTxs(ctx context.Context, txids []string) ([]Tx, error)

func (*Queries) SelectUtxo

func (q *Queries) SelectUtxo(ctx context.Context, arg SelectUtxoParams) (Utxo, error)

func (*Queries) SelectUtxosByTxid added in v0.10.0

func (q *Queries) SelectUtxosByTxid(ctx context.Context, txid string) ([]Utxo, error)

func (*Queries) SelectVtxo

func (q *Queries) SelectVtxo(ctx context.Context, arg SelectVtxoParams) ([]AssetVtxoVw, error)

func (*Queries) SettleVtxo

func (q *Queries) SettleVtxo(ctx context.Context, arg SettleVtxoParams) error

func (*Queries) SpendVtxo

func (q *Queries) SpendVtxo(ctx context.Context, arg SpendVtxoParams) error

func (*Queries) SweepVtxo

func (q *Queries) SweepVtxo(ctx context.Context, arg SweepVtxoParams) error

func (*Queries) UnrollVtxo

func (q *Queries) UnrollVtxo(ctx context.Context, arg UnrollVtxoParams) error

func (*Queries) UpdateContractState added in v0.10.0

func (q *Queries) UpdateContractState(ctx context.Context, arg UpdateContractStateParams) (int64, error)

func (*Queries) UpdateTx

func (q *Queries) UpdateTx(ctx context.Context, arg UpdateTxParams) error

func (*Queries) UpdateUtxo

func (q *Queries) UpdateUtxo(ctx context.Context, arg UpdateUtxoParams) error

func (*Queries) UpsertAsset

func (q *Queries) UpsertAsset(ctx context.Context, arg UpsertAssetParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type ReplaceTxParams

type ReplaceTxParams struct {
	NewTxid   string
	TxidType  string
	Amount    int64
	Type      string
	SettledBy sql.NullString
	CreatedAt int64
	Hex       sql.NullString
	OldTxid   string
}

type SelectUtxoParams

type SelectUtxoParams struct {
	Txid string
	Vout int64
}

type SelectVtxoParams

type SelectVtxoParams struct {
	Txid string
	Vout int64
}

type SettleVtxoParams

type SettleVtxoParams struct {
	SpentBy   sql.NullString
	SettledBy sql.NullString
	Txid      string
	Vout      int64
}

type SpendVtxoParams

type SpendVtxoParams struct {
	SpentBy sql.NullString
	ArkTxid sql.NullString
	Txid    string
	Vout    int64
}

type SweepVtxoParams

type SweepVtxoParams struct {
	Txid string
	Vout int64
}

type Tx

type Tx struct {
	Txid        string
	TxidType    string
	Amount      int64
	Type        string
	Settled     bool
	CreatedAt   int64
	Hex         sql.NullString
	SettledBy   sql.NullString
	AssetPacket sql.NullString
}

type UnrollVtxoParams

type UnrollVtxoParams struct {
	Txid string
	Vout int64
}

type UpdateContractStateParams added in v0.10.0

type UpdateContractStateParams struct {
	State  string
	Script string
}

type UpdateTxParams

type UpdateTxParams struct {
	CreatedAt sql.NullInt64
	SettledBy interface{}
	Txid      string
}

type UpdateUtxoParams

type UpdateUtxoParams struct {
	Spent       interface{}
	SpentBy     sql.NullString
	CreatedAt   sql.NullInt64
	SpendableAt sql.NullInt64
	Txid        string
	Vout        int64
}

type UpsertAssetParams

type UpsertAssetParams struct {
	AssetID        string
	ControlAssetID sql.NullString
	Metadata       sql.NullString
}

type Utxo

type Utxo struct {
	Txid        string
	Vout        int64
	Script      string
	Amount      int64
	SpentBy     sql.NullString
	Spent       bool
	Tapscripts  sql.NullString
	SpendableAt sql.NullInt64
	CreatedAt   sql.NullInt64
	DelayValue  sql.NullInt64
	DelayType   sql.NullString
	Tx          sql.NullString
}

type Vtxo

type Vtxo struct {
	Txid            string
	Vout            int64
	Script          string
	Amount          int64
	CommitmentTxids string
	SpentBy         sql.NullString
	Spent           bool
	ExpiresAt       int64
	CreatedAt       int64
	Preconfirmed    bool
	Swept           bool
	SettledBy       sql.NullString
	Unrolled        bool
	ArkTxid         sql.NullString
}

Jump to

Keyboard shortcuts

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