mirror of https://github.com/lightninglabs/loop
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
198 lines
4.0 KiB
Go
198 lines
4.0 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.25.0
|
|
// source: static_address_deposits.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
const allDeposits = `-- name: AllDeposits :many
|
|
SELECT
|
|
id, deposit_id, tx_hash, out_index, amount, confirmation_height, timeout_sweep_pk_script, expiry_sweep_txid
|
|
FROM
|
|
deposits
|
|
ORDER BY
|
|
id ASC
|
|
`
|
|
|
|
func (q *Queries) AllDeposits(ctx context.Context) ([]Deposit, error) {
|
|
rows, err := q.db.QueryContext(ctx, allDeposits)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Deposit
|
|
for rows.Next() {
|
|
var i Deposit
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.DepositID,
|
|
&i.TxHash,
|
|
&i.OutIndex,
|
|
&i.Amount,
|
|
&i.ConfirmationHeight,
|
|
&i.TimeoutSweepPkScript,
|
|
&i.ExpirySweepTxid,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const createDeposit = `-- name: CreateDeposit :exec
|
|
INSERT INTO deposits (
|
|
deposit_id,
|
|
tx_hash,
|
|
out_index,
|
|
amount,
|
|
confirmation_height,
|
|
timeout_sweep_pk_script,
|
|
expiry_sweep_txid
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7
|
|
)
|
|
`
|
|
|
|
type CreateDepositParams struct {
|
|
DepositID []byte
|
|
TxHash []byte
|
|
OutIndex int32
|
|
Amount int64
|
|
ConfirmationHeight int64
|
|
TimeoutSweepPkScript []byte
|
|
ExpirySweepTxid []byte
|
|
}
|
|
|
|
func (q *Queries) CreateDeposit(ctx context.Context, arg CreateDepositParams) error {
|
|
_, err := q.db.ExecContext(ctx, createDeposit,
|
|
arg.DepositID,
|
|
arg.TxHash,
|
|
arg.OutIndex,
|
|
arg.Amount,
|
|
arg.ConfirmationHeight,
|
|
arg.TimeoutSweepPkScript,
|
|
arg.ExpirySweepTxid,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getDeposit = `-- name: GetDeposit :one
|
|
SELECT
|
|
id, deposit_id, tx_hash, out_index, amount, confirmation_height, timeout_sweep_pk_script, expiry_sweep_txid
|
|
FROM
|
|
deposits
|
|
WHERE
|
|
deposit_id = $1
|
|
`
|
|
|
|
func (q *Queries) GetDeposit(ctx context.Context, depositID []byte) (Deposit, error) {
|
|
row := q.db.QueryRowContext(ctx, getDeposit, depositID)
|
|
var i Deposit
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.DepositID,
|
|
&i.TxHash,
|
|
&i.OutIndex,
|
|
&i.Amount,
|
|
&i.ConfirmationHeight,
|
|
&i.TimeoutSweepPkScript,
|
|
&i.ExpirySweepTxid,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getLatestDepositUpdate = `-- name: GetLatestDepositUpdate :one
|
|
SELECT
|
|
id, deposit_id, update_state, update_timestamp
|
|
FROM
|
|
deposit_updates
|
|
WHERE
|
|
deposit_id = $1
|
|
ORDER BY
|
|
update_timestamp DESC
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetLatestDepositUpdate(ctx context.Context, depositID []byte) (DepositUpdate, error) {
|
|
row := q.db.QueryRowContext(ctx, getLatestDepositUpdate, depositID)
|
|
var i DepositUpdate
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.DepositID,
|
|
&i.UpdateState,
|
|
&i.UpdateTimestamp,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertDepositUpdate = `-- name: InsertDepositUpdate :exec
|
|
INSERT INTO deposit_updates (
|
|
deposit_id,
|
|
update_state,
|
|
update_timestamp
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3
|
|
)
|
|
`
|
|
|
|
type InsertDepositUpdateParams struct {
|
|
DepositID []byte
|
|
UpdateState string
|
|
UpdateTimestamp time.Time
|
|
}
|
|
|
|
func (q *Queries) InsertDepositUpdate(ctx context.Context, arg InsertDepositUpdateParams) error {
|
|
_, err := q.db.ExecContext(ctx, insertDepositUpdate, arg.DepositID, arg.UpdateState, arg.UpdateTimestamp)
|
|
return err
|
|
}
|
|
|
|
const updateDeposit = `-- name: UpdateDeposit :exec
|
|
UPDATE deposits
|
|
SET
|
|
tx_hash = $2,
|
|
out_index = $3,
|
|
confirmation_height = $4,
|
|
expiry_sweep_txid = $5
|
|
WHERE
|
|
deposits.deposit_id = $1
|
|
`
|
|
|
|
type UpdateDepositParams struct {
|
|
DepositID []byte
|
|
TxHash []byte
|
|
OutIndex int32
|
|
ConfirmationHeight int64
|
|
ExpirySweepTxid []byte
|
|
}
|
|
|
|
func (q *Queries) UpdateDeposit(ctx context.Context, arg UpdateDepositParams) error {
|
|
_, err := q.db.ExecContext(ctx, updateDeposit,
|
|
arg.DepositID,
|
|
arg.TxHash,
|
|
arg.OutIndex,
|
|
arg.ConfirmationHeight,
|
|
arg.ExpirySweepTxid,
|
|
)
|
|
return err
|
|
}
|