Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1/?] Static Loop-In Address - Create #642

Merged
merged 11 commits into from
Mar 4, 2024
Next Next commit
sqlc: static address migrations, models, queries
  • Loading branch information
hieblmi committed Mar 4, 2024
commit 8d216655cdebb6ecc88cb2353d8b0f6b83ad10fd
1 change: 1 addition & 0 deletions loopdb/sqlc/migrations/000007_static_address.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS static_addresses;
38 changes: 38 additions & 0 deletions loopdb/sqlc/migrations/000007_static_address.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- static_address stores the static loop-in addresses that clients
-- cooperatively created with the server.
CREATE TABLE IF NOT EXISTS static_addresses (
-- id is the auto-incrementing primary key for a static address.
id INTEGER PRIMARY KEY,

-- client_pubkey is the client side public taproot key that is used to
-- construct the 2-of-2 MuSig2 taproot output that represents the static
-- address.
client_pubkey BYTEA NOT NULL,

-- server_pubkey is the server side public taproot key that is used to
-- construct the 2-of-2 MuSig2 taproot output that represents the static
-- address.
server_pubkey BYTEA NOT NULL,

-- expiry denotes the CSV delay at which funds at a specific static address
-- can be swept back to the client.
expiry INT NOT NULL,

-- client_key_family is the key family of the client public key from the
-- client's lnd wallet.
client_key_family INT NOT NULL,

-- client_key_index is the key index of the client public key from the
-- client's lnd wallet.
client_key_index INT NOT NULL,

-- pkscript is the witness program that represents the static address. It is
-- unique amongst all static addresses.
pkscript BYTEA NOT NULL UNIQUE,

-- protocol_version is the protocol version that the swap was created with.
-- Note that this version is not upgraded if the client upgrades or
-- downgrades their protocol version for static address outputs already in
-- use.
protocol_version INTEGER NOT NULL
);
11 changes: 11 additions & 0 deletions loopdb/sqlc/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions loopdb/sqlc/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions loopdb/sqlc/queries/static_addresses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- name: AllStaticAddresses :many
SELECT * FROM static_addresses;

-- name: GetStaticAddress :one
SELECT * FROM static_addresses
WHERE pkscript=$1;

-- 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
);
110 changes: 110 additions & 0 deletions loopdb/sqlc/static_addresses.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.