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.
111 lines
2.4 KiB
Go
111 lines
2.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.17.2
|
|
// source: static_addresses.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const allStaticAddresses = `-- name: AllStaticAddresses :many
|
|
SELECT id, client_pubkey, server_pubkey, expiry, client_key_family, client_key_index, pkscript, protocol_version FROM static_addresses
|
|
`
|
|
|
|
func (q *Queries) AllStaticAddresses(ctx context.Context) ([]StaticAddress, error) {
|
|
rows, err := q.db.QueryContext(ctx, allStaticAddresses)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []StaticAddress
|
|
for rows.Next() {
|
|
var i StaticAddress
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ClientPubkey,
|
|
&i.ServerPubkey,
|
|
&i.Expiry,
|
|
&i.ClientKeyFamily,
|
|
&i.ClientKeyIndex,
|
|
&i.Pkscript,
|
|
&i.ProtocolVersion,
|
|
); 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 createStaticAddress = `-- name: CreateStaticAddress :exec
|
|
INSERT INTO static_addresses (
|
|
client_pubkey,
|
|
server_pubkey,
|
|
expiry,
|
|
client_key_family,
|
|
client_key_index,
|
|
pkscript,
|
|
protocol_version
|
|
) VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7
|
|
)
|
|
`
|
|
|
|
type CreateStaticAddressParams struct {
|
|
ClientPubkey []byte
|
|
ServerPubkey []byte
|
|
Expiry int32
|
|
ClientKeyFamily int32
|
|
ClientKeyIndex int32
|
|
Pkscript []byte
|
|
ProtocolVersion int32
|
|
}
|
|
|
|
func (q *Queries) CreateStaticAddress(ctx context.Context, arg CreateStaticAddressParams) error {
|
|
_, err := q.db.ExecContext(ctx, createStaticAddress,
|
|
arg.ClientPubkey,
|
|
arg.ServerPubkey,
|
|
arg.Expiry,
|
|
arg.ClientKeyFamily,
|
|
arg.ClientKeyIndex,
|
|
arg.Pkscript,
|
|
arg.ProtocolVersion,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getStaticAddress = `-- name: GetStaticAddress :one
|
|
SELECT id, client_pubkey, server_pubkey, expiry, client_key_family, client_key_index, pkscript, protocol_version FROM static_addresses
|
|
WHERE pkscript=$1
|
|
`
|
|
|
|
func (q *Queries) GetStaticAddress(ctx context.Context, pkscript []byte) (StaticAddress, error) {
|
|
row := q.db.QueryRowContext(ctx, getStaticAddress, pkscript)
|
|
var i StaticAddress
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ClientPubkey,
|
|
&i.ServerPubkey,
|
|
&i.Expiry,
|
|
&i.ClientKeyFamily,
|
|
&i.ClientKeyIndex,
|
|
&i.Pkscript,
|
|
&i.ProtocolVersion,
|
|
)
|
|
return i, err
|
|
}
|