mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
169 lines
3.8 KiB
Go
169 lines
3.8 KiB
Go
|
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
|
// versions:
|
||
|
|
// sqlc v1.25.0
|
||
|
|
// source: static_address_withdrawals.sql
|
||
|
|
|
||
|
|
package sqlc
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"database/sql"
|
||
|
|
"time"
|
||
|
|
)
|
||
|
|
|
||
|
|
const createWithdrawal = `-- name: CreateWithdrawal :exec
|
||
|
|
INSERT INTO withdrawals (
|
||
|
|
withdrawal_id,
|
||
|
|
total_deposit_amount,
|
||
|
|
initiation_time
|
||
|
|
) VALUES (
|
||
|
|
$1, $2, $3
|
||
|
|
)
|
||
|
|
`
|
||
|
|
|
||
|
|
type CreateWithdrawalParams struct {
|
||
|
|
WithdrawalID []byte
|
||
|
|
TotalDepositAmount int64
|
||
|
|
InitiationTime time.Time
|
||
|
|
}
|
||
|
|
|
||
|
|
func (q *Queries) CreateWithdrawal(ctx context.Context, arg CreateWithdrawalParams) error {
|
||
|
|
_, err := q.db.ExecContext(ctx, createWithdrawal, arg.WithdrawalID, arg.TotalDepositAmount, arg.InitiationTime)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
const createWithdrawalDeposit = `-- name: CreateWithdrawalDeposit :exec
|
||
|
|
INSERT INTO withdrawal_deposits (
|
||
|
|
withdrawal_id,
|
||
|
|
deposit_id
|
||
|
|
) VALUES (
|
||
|
|
$1, $2
|
||
|
|
)
|
||
|
|
`
|
||
|
|
|
||
|
|
type CreateWithdrawalDepositParams struct {
|
||
|
|
WithdrawalID []byte
|
||
|
|
DepositID []byte
|
||
|
|
}
|
||
|
|
|
||
|
|
func (q *Queries) CreateWithdrawalDeposit(ctx context.Context, arg CreateWithdrawalDepositParams) error {
|
||
|
|
_, err := q.db.ExecContext(ctx, createWithdrawalDeposit, arg.WithdrawalID, arg.DepositID)
|
||
|
|
return err
|
||
|
|
}
|
||
|
|
|
||
|
|
const getAllWithdrawals = `-- name: GetAllWithdrawals :many
|
||
|
|
SELECT
|
||
|
|
id, withdrawal_id, withdrawal_tx_id, total_deposit_amount, withdrawn_amount, change_amount, initiation_time, confirmation_height
|
||
|
|
FROM
|
||
|
|
withdrawals
|
||
|
|
ORDER BY
|
||
|
|
initiation_time DESC
|
||
|
|
`
|
||
|
|
|
||
|
|
func (q *Queries) GetAllWithdrawals(ctx context.Context) ([]Withdrawal, error) {
|
||
|
|
rows, err := q.db.QueryContext(ctx, getAllWithdrawals)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
defer rows.Close()
|
||
|
|
var items []Withdrawal
|
||
|
|
for rows.Next() {
|
||
|
|
var i Withdrawal
|
||
|
|
if err := rows.Scan(
|
||
|
|
&i.ID,
|
||
|
|
&i.WithdrawalID,
|
||
|
|
&i.WithdrawalTxID,
|
||
|
|
&i.TotalDepositAmount,
|
||
|
|
&i.WithdrawnAmount,
|
||
|
|
&i.ChangeAmount,
|
||
|
|
&i.InitiationTime,
|
||
|
|
&i.ConfirmationHeight,
|
||
|
|
); 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 getWithdrawalDeposits = `-- name: GetWithdrawalDeposits :many
|
||
|
|
SELECT
|
||
|
|
deposit_id
|
||
|
|
FROM
|
||
|
|
withdrawal_deposits
|
||
|
|
WHERE
|
||
|
|
withdrawal_id = $1
|
||
|
|
`
|
||
|
|
|
||
|
|
func (q *Queries) GetWithdrawalDeposits(ctx context.Context, withdrawalID []byte) ([][]byte, error) {
|
||
|
|
rows, err := q.db.QueryContext(ctx, getWithdrawalDeposits, withdrawalID)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
defer rows.Close()
|
||
|
|
var items [][]byte
|
||
|
|
for rows.Next() {
|
||
|
|
var deposit_id []byte
|
||
|
|
if err := rows.Scan(&deposit_id); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
items = append(items, deposit_id)
|
||
|
|
}
|
||
|
|
if err := rows.Close(); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
if err := rows.Err(); err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
return items, nil
|
||
|
|
}
|
||
|
|
|
||
|
|
const getWithdrawalIDByDepositID = `-- name: GetWithdrawalIDByDepositID :one
|
||
|
|
SELECT withdrawal_id
|
||
|
|
FROM withdrawal_deposits
|
||
|
|
WHERE deposit_id = $1
|
||
|
|
`
|
||
|
|
|
||
|
|
func (q *Queries) GetWithdrawalIDByDepositID(ctx context.Context, depositID []byte) ([]byte, error) {
|
||
|
|
row := q.db.QueryRowContext(ctx, getWithdrawalIDByDepositID, depositID)
|
||
|
|
var withdrawal_id []byte
|
||
|
|
err := row.Scan(&withdrawal_id)
|
||
|
|
return withdrawal_id, err
|
||
|
|
}
|
||
|
|
|
||
|
|
const updateWithdrawal = `-- name: UpdateWithdrawal :exec
|
||
|
|
UPDATE withdrawals
|
||
|
|
SET
|
||
|
|
withdrawal_tx_id = $2,
|
||
|
|
withdrawn_amount = $3,
|
||
|
|
change_amount = $4,
|
||
|
|
confirmation_height = $5
|
||
|
|
WHERE
|
||
|
|
withdrawal_id = $1
|
||
|
|
`
|
||
|
|
|
||
|
|
type UpdateWithdrawalParams struct {
|
||
|
|
WithdrawalID []byte
|
||
|
|
WithdrawalTxID sql.NullString
|
||
|
|
WithdrawnAmount sql.NullInt64
|
||
|
|
ChangeAmount sql.NullInt64
|
||
|
|
ConfirmationHeight sql.NullInt64
|
||
|
|
}
|
||
|
|
|
||
|
|
func (q *Queries) UpdateWithdrawal(ctx context.Context, arg UpdateWithdrawalParams) error {
|
||
|
|
_, err := q.db.ExecContext(ctx, updateWithdrawal,
|
||
|
|
arg.WithdrawalID,
|
||
|
|
arg.WithdrawalTxID,
|
||
|
|
arg.WithdrawnAmount,
|
||
|
|
arg.ChangeAmount,
|
||
|
|
arg.ConfirmationHeight,
|
||
|
|
)
|
||
|
|
return err
|
||
|
|
}
|