sqlc

package
v0.21.0-beta.rc2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 FailAttemptParams

type FailAttemptParams struct {
	AttemptIndex       int64
	ResolutionTime     time.Time
	ResolutionType     int32
	FailureSourceIndex sql.NullInt32
	HtlcFailReason     sql.NullInt32
	FailureMsg         []byte
}

type FailPaymentParams

type FailPaymentParams struct {
	FailReason        sql.NullInt32
	PaymentIdentifier []byte
}

type FetchAllInflightAttemptsParams

type FetchAllInflightAttemptsParams struct {
	AttemptIndex int64
	Limit        int32
}

type FetchHopsForAttemptsRow

type FetchHopsForAttemptsRow struct {
	ID                  int64
	HtlcAttemptIndex    int64
	HopIndex            int32
	PubKey              []byte
	Scid                string
	OutgoingTimeLock    int32
	AmtToForward        int64
	MetaData            []byte
	MppPaymentAddr      []byte
	MppTotalMsat        sql.NullInt64
	AmpRootShare        []byte
	AmpSetID            []byte
	AmpChildIndex       sql.NullInt32
	EncryptedData       []byte
	BlindingPoint       []byte
	BlindedPathTotalAmt sql.NullInt64
}

type FetchHtlcAttemptResolutionsForPaymentsRow

type FetchHtlcAttemptResolutionsForPaymentsRow struct {
	PaymentID      int64
	ResolutionType sql.NullInt32
}

type FetchHtlcAttemptsForPaymentsRow

type FetchHtlcAttemptsForPaymentsRow struct {
	ID                 int64
	AttemptIndex       int64
	PaymentID          int64
	SessionKey         []byte
	AttemptTime        time.Time
	PaymentHash        []byte
	FirstHopAmountMsat int64
	RouteTotalTimeLock int32
	RouteTotalAmount   int64
	RouteSourceKey     []byte
	ResolutionType     sql.NullInt32
	ResolutionTime     sql.NullTime
	FailureSourceIndex sql.NullInt32
	HtlcFailReason     sql.NullInt32
	FailureMsg         []byte
	SettlePreimage     []byte
}

type FetchPaymentRow

type FetchPaymentRow struct {
	Payment       Payment
	IntentType    sql.NullInt16
	IntentPayload []byte
}

func (FetchPaymentRow) GetPayment

func (r FetchPaymentRow) GetPayment() Payment

GetPayment returns the Payment associated with this interface.

NOTE: This method is part of the PaymentAndIntent interface.

func (FetchPaymentRow) GetPaymentIntent

func (r FetchPaymentRow) GetPaymentIntent() PaymentIntent

GetPaymentIntent returns the PaymentIntent associated with this payment. If the payment has no intent (IntentType is NULL), this returns a zero-value PaymentIntent.

NOTE: This method is part of the PaymentAndIntent interface.

type FetchPaymentsByIDsMigRow

type FetchPaymentsByIDsMigRow struct {
	ID                int64
	AmountMsat        int64
	CreatedAt         time.Time
	PaymentIdentifier []byte
	FailReason        sql.NullInt32
	HtlcAttemptCount  int64
}

type FetchPaymentsByIDsRow

type FetchPaymentsByIDsRow struct {
	ID                int64
	AmountMsat        int64
	CreatedAt         time.Time
	PaymentIdentifier []byte
	FailReason        sql.NullInt32
	IntentType        sql.NullInt16
	IntentPayload     []byte
}

func (FetchPaymentsByIDsRow) GetPayment

func (r FetchPaymentsByIDsRow) GetPayment() Payment

func (FetchPaymentsByIDsRow) GetPaymentIntent

func (r FetchPaymentsByIDsRow) GetPaymentIntent() PaymentIntent

type FilterPaymentsDescParams

type FilterPaymentsDescParams struct {
	IndexOffsetGet sql.NullInt64
	IndexOffsetLet sql.NullInt64
	CreatedAfter   time.Time
	CreatedBefore  time.Time
	IntentType     sql.NullInt16
	NumLimit       int32
}

type FilterPaymentsDescRow

type FilterPaymentsDescRow struct {
	Payment       Payment
	IntentType    sql.NullInt16
	IntentPayload []byte
}

type FilterPaymentsParams

type FilterPaymentsParams struct {
	IndexOffsetGet sql.NullInt64
	IndexOffsetLet sql.NullInt64
	CreatedAfter   time.Time
	CreatedBefore  time.Time
	IntentType     sql.NullInt16
	NumLimit       int32
}

type FilterPaymentsRow

type FilterPaymentsRow struct {
	Payment       Payment
	IntentType    sql.NullInt16
	IntentPayload []byte
}

func (FilterPaymentsRow) GetPayment

func (r FilterPaymentsRow) GetPayment() Payment

GetPayment returns the Payment associated with this interface.

NOTE: This method is part of the PaymentAndIntent interface.

func (FilterPaymentsRow) GetPaymentIntent

func (r FilterPaymentsRow) GetPaymentIntent() PaymentIntent

GetPaymentIntent returns the PaymentIntent associated with this payment. If the payment has no intent (IntentType is NULL), this returns a zero-value PaymentIntent.

NOTE: This method is part of the PaymentAndIntent interface.

type InsertHtlcAttemptParams

type InsertHtlcAttemptParams struct {
	PaymentID          int64
	AttemptIndex       int64
	SessionKey         []byte
	AttemptTime        time.Time
	PaymentHash        []byte
	FirstHopAmountMsat int64
	RouteTotalTimeLock int32
	RouteTotalAmount   int64
	RouteSourceKey     []byte
}

type InsertPaymentAttemptFirstHopCustomRecordParams

type InsertPaymentAttemptFirstHopCustomRecordParams struct {
	HtlcAttemptIndex int64
	Key              int64
	Value            []byte
}

type InsertPaymentDuplicateMigParams

type InsertPaymentDuplicateMigParams struct {
	PaymentID      int64
	AmountMsat     int64
	CreatedAt      time.Time
	FailReason     sql.NullInt32
	SettlePreimage []byte
	SettleTime     sql.NullTime
}

type InsertPaymentFirstHopCustomRecordParams

type InsertPaymentFirstHopCustomRecordParams struct {
	PaymentID int64
	Key       int64
	Value     []byte
}

type InsertPaymentHopCustomRecordParams

type InsertPaymentHopCustomRecordParams struct {
	HopID int64
	Key   int64
	Value []byte
}

type InsertPaymentIntentParams

type InsertPaymentIntentParams struct {
	PaymentID     int64
	IntentType    int16
	IntentPayload []byte
}

type InsertPaymentMigParams

type InsertPaymentMigParams struct {
	AmountMsat        int64
	CreatedAt         time.Time
	PaymentIdentifier []byte
	FailReason        sql.NullInt32
}

type InsertPaymentParams

type InsertPaymentParams struct {
	AmountMsat        int64
	CreatedAt         time.Time
	PaymentIdentifier []byte
}

type InsertRouteHopAmpParams

type InsertRouteHopAmpParams struct {
	HopID      int64
	RootShare  []byte
	SetID      []byte
	ChildIndex int32
}

type InsertRouteHopBlindedParams

type InsertRouteHopBlindedParams struct {
	HopID               int64
	EncryptedData       []byte
	BlindingPoint       []byte
	BlindedPathTotalAmt sql.NullInt64
}

type InsertRouteHopMppParams

type InsertRouteHopMppParams struct {
	HopID       int64
	PaymentAddr []byte
	TotalMsat   int64
}

type InsertRouteHopParams

type InsertRouteHopParams struct {
	HtlcAttemptIndex int64
	HopIndex         int32
	PubKey           []byte
	Scid             string
	OutgoingTimeLock int32
	AmtToForward     int64
	MetaData         []byte
}

type Payment

type Payment struct {
	ID                int64
	AmountMsat        int64
	CreatedAt         time.Time
	PaymentIdentifier []byte
	FailReason        sql.NullInt32
}

type PaymentAndIntent

type PaymentAndIntent interface {
	// GetPayment returns the Payment associated with this interface.
	GetPayment() Payment

	// GetPaymentIntent returns the PaymentIntent associated with this
	// payment.
	GetPaymentIntent() PaymentIntent
}

PaymentAndIntent is an interface that provides access to a payment and its associated payment intent.

type PaymentAttemptFirstHopCustomRecord

type PaymentAttemptFirstHopCustomRecord struct {
	ID               int64
	HtlcAttemptIndex int64
	Key              int64
	Value            []byte
}

type PaymentDuplicate

type PaymentDuplicate struct {
	ID             int64
	PaymentID      int64
	AmountMsat     int64
	CreatedAt      time.Time
	FailReason     sql.NullInt32
	SettlePreimage []byte
	SettleTime     sql.NullTime
}

type PaymentFirstHopCustomRecord

type PaymentFirstHopCustomRecord struct {
	ID        int64
	PaymentID int64
	Key       int64
	Value     []byte
}

type PaymentHopCustomRecord

type PaymentHopCustomRecord struct {
	ID    int64
	HopID int64
	Key   int64
	Value []byte
}

type PaymentHtlcAttempt

type PaymentHtlcAttempt struct {
	ID                 int64
	AttemptIndex       int64
	PaymentID          int64
	SessionKey         []byte
	AttemptTime        time.Time
	PaymentHash        []byte
	FirstHopAmountMsat int64
	RouteTotalTimeLock int32
	RouteTotalAmount   int64
	RouteSourceKey     []byte
}

type PaymentHtlcAttemptResolution

type PaymentHtlcAttemptResolution struct {
	AttemptIndex       int64
	ResolutionTime     time.Time
	ResolutionType     int32
	SettlePreimage     []byte
	FailureSourceIndex sql.NullInt32
	HtlcFailReason     sql.NullInt32
	FailureMsg         []byte
}

type PaymentIntent

type PaymentIntent struct {
	ID            int64
	PaymentID     int64
	IntentType    int16
	IntentPayload []byte
}

type PaymentRouteHop

type PaymentRouteHop struct {
	ID               int64
	HtlcAttemptIndex int64
	HopIndex         int32
	PubKey           []byte
	Scid             string
	OutgoingTimeLock int32
	AmtToForward     int64
	MetaData         []byte
}

type PaymentRouteHopAmp

type PaymentRouteHopAmp struct {
	HopID      int64
	RootShare  []byte
	SetID      []byte
	ChildIndex int32
}

type PaymentRouteHopBlinded

type PaymentRouteHopBlinded struct {
	HopID               int64
	EncryptedData       []byte
	BlindingPoint       []byte
	BlindedPathTotalAmt sql.NullInt64
}

type PaymentRouteHopMpp

type PaymentRouteHopMpp struct {
	HopID       int64
	PaymentAddr []byte
	TotalMsat   int64
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CountPayments

func (q *Queries) CountPayments(ctx context.Context) (int64, error)

func (*Queries) DeleteFailedAttempts

func (q *Queries) DeleteFailedAttempts(ctx context.Context, paymentID int64) error

Delete all failed HTLC attempts for the given payment. Resolution type 2 indicates a failed attempt.

func (*Queries) DeletePayment

func (q *Queries) DeletePayment(ctx context.Context, id int64) error

func (*Queries) FailAttempt

func (q *Queries) FailAttempt(ctx context.Context, arg FailAttemptParams) error

func (*Queries) FailPayment

func (q *Queries) FailPayment(ctx context.Context, arg FailPaymentParams) (sql.Result, error)

func (*Queries) FetchAllInflightAttempts

func (q *Queries) FetchAllInflightAttempts(ctx context.Context, arg FetchAllInflightAttemptsParams) ([]PaymentHtlcAttempt, error)

Fetch all inflight attempts with their payment data using pagination. Returns attempt data joined with payment and intent data to avoid separate queries.

func (*Queries) FetchHopLevelCustomRecords

func (q *Queries) FetchHopLevelCustomRecords(ctx context.Context, hopIds []int64) ([]PaymentHopCustomRecord, error)

func (*Queries) FetchHopsForAttempts

func (q *Queries) FetchHopsForAttempts(ctx context.Context, htlcAttemptIndices []int64) ([]FetchHopsForAttemptsRow, error)

func (*Queries) FetchHtlcAttemptResolutionsForPayments

func (q *Queries) FetchHtlcAttemptResolutionsForPayments(ctx context.Context, paymentIds []int64) ([]FetchHtlcAttemptResolutionsForPaymentsRow, error)

Batch query to fetch only HTLC resolution status for multiple payments. We don't need to order by payment_id and attempt_time because we will group the resolutions by payment_id in the background.

func (*Queries) FetchHtlcAttemptsForPayments

func (q *Queries) FetchHtlcAttemptsForPayments(ctx context.Context, paymentIds []int64) ([]FetchHtlcAttemptsForPaymentsRow, error)

func (*Queries) FetchPayment

func (q *Queries) FetchPayment(ctx context.Context, paymentIdentifier []byte) (FetchPaymentRow, error)

func (*Queries) FetchPaymentDuplicates

func (q *Queries) FetchPaymentDuplicates(ctx context.Context, paymentID int64) ([]PaymentDuplicate, error)

Fetch all duplicate payment records from the payment_duplicates table for a given payment ID.

func (*Queries) FetchPaymentLevelFirstHopCustomRecords

func (q *Queries) FetchPaymentLevelFirstHopCustomRecords(ctx context.Context, paymentIds []int64) ([]PaymentFirstHopCustomRecord, error)

func (*Queries) FetchPaymentsByIDs

func (q *Queries) FetchPaymentsByIDs(ctx context.Context, paymentIds []int64) ([]FetchPaymentsByIDsRow, error)

Batch fetch payment and intent data for a set of payment IDs. Used to avoid fetching redundant payment data when processing multiple attempts for the same payment.

func (*Queries) FetchPaymentsByIDsMig

func (q *Queries) FetchPaymentsByIDsMig(ctx context.Context, paymentIds []int64) ([]FetchPaymentsByIDsMigRow, error)

Migration-specific batch fetch that returns payment data along with HTLC attempt counts for structural validation during KV to SQL migration.

func (*Queries) FetchRouteLevelFirstHopCustomRecords

func (q *Queries) FetchRouteLevelFirstHopCustomRecords(ctx context.Context, htlcAttemptIndices []int64) ([]PaymentAttemptFirstHopCustomRecord, error)

func (*Queries) FilterPayments

func (q *Queries) FilterPayments(ctx context.Context, arg FilterPaymentsParams) ([]FilterPaymentsRow, error)

func (*Queries) FilterPaymentsDesc

func (q *Queries) FilterPaymentsDesc(ctx context.Context, arg FilterPaymentsDescParams) ([]FilterPaymentsDescRow, error)

func (*Queries) GetTx

func (q *Queries) GetTx() DBTX

GetTx returns the underlying DBTX (either *sql.DB or *sql.Tx) used by the Queries struct.

func (*Queries) InsertHtlcAttempt

func (q *Queries) InsertHtlcAttempt(ctx context.Context, arg InsertHtlcAttemptParams) (int64, error)

func (*Queries) InsertPayment

func (q *Queries) InsertPayment(ctx context.Context, arg InsertPaymentParams) (int64, error)

Insert a new payment and return its ID. When creating a payment we don't have a fail reason because we start the payment process.

func (*Queries) InsertPaymentAttemptFirstHopCustomRecord

func (q *Queries) InsertPaymentAttemptFirstHopCustomRecord(ctx context.Context, arg InsertPaymentAttemptFirstHopCustomRecordParams) error

func (*Queries) InsertPaymentDuplicateMig

func (q *Queries) InsertPaymentDuplicateMig(ctx context.Context, arg InsertPaymentDuplicateMigParams) (int64, error)

Insert a duplicate payment record into the payment_duplicates table and return its ID.

func (*Queries) InsertPaymentFirstHopCustomRecord

func (q *Queries) InsertPaymentFirstHopCustomRecord(ctx context.Context, arg InsertPaymentFirstHopCustomRecordParams) error

func (*Queries) InsertPaymentHopCustomRecord

func (q *Queries) InsertPaymentHopCustomRecord(ctx context.Context, arg InsertPaymentHopCustomRecordParams) error

func (*Queries) InsertPaymentIntent

func (q *Queries) InsertPaymentIntent(ctx context.Context, arg InsertPaymentIntentParams) (int64, error)

Insert a payment intent for a given payment and return its ID.

func (*Queries) InsertPaymentMig

func (q *Queries) InsertPaymentMig(ctx context.Context, arg InsertPaymentMigParams) (int64, error)

Migration-specific payment insert that allows setting fail_reason. Normal InsertPayment forces fail_reason to NULL since new payments aren't failed yet. During migration, we're inserting historical data that may already be failed.

func (*Queries) InsertRouteHop

func (q *Queries) InsertRouteHop(ctx context.Context, arg InsertRouteHopParams) (int64, error)

func (*Queries) InsertRouteHopAmp

func (q *Queries) InsertRouteHopAmp(ctx context.Context, arg InsertRouteHopAmpParams) error

func (*Queries) InsertRouteHopBlinded

func (q *Queries) InsertRouteHopBlinded(ctx context.Context, arg InsertRouteHopBlindedParams) error

func (*Queries) InsertRouteHopMpp

func (q *Queries) InsertRouteHopMpp(ctx context.Context, arg InsertRouteHopMppParams) error

func (*Queries) SettleAttempt

func (q *Queries) SettleAttempt(ctx context.Context, arg SettleAttemptParams) error

func (*Queries) WithTx

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

type SettleAttemptParams

type SettleAttemptParams struct {
	AttemptIndex   int64
	ResolutionTime time.Time
	ResolutionType int32
	SettlePreimage []byte
}

Jump to

Keyboard shortcuts

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