Skip to content

Commit ced70d8

Browse files
committed
loopdb: withdrawal table and queries
1 parent 8160efa commit ced70d8

File tree

6 files changed

+152
-0
lines changed

6 files changed

+152
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE IF EXISTS withdrawals;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- withdrawals stores finalized static address withdrawals.
2+
CREATE TABLE IF NOT EXISTS withdrawals (
3+
-- id is the auto-incrementing primary key for a withdrawal.
4+
id INTEGER PRIMARY KEY,
5+
6+
-- withdrawal_tx_id is the transaction tx id of the withdrawal.
7+
withdrawal_tx_id TEXT NOT NULL UNIQUE,
8+
9+
-- deposit_outpoints is a concatenated list of outpoints that are used for
10+
-- this withdrawal. The list has the format txid1:idx;txid2:idx;...
11+
deposit_outpoints TEXT NOT NULL,
12+
13+
-- total_deposit_amount is the total amount of the deposits in satoshis.
14+
total_deposit_amount BIGINT NOT NULL,
15+
16+
-- withdrawn_amount is the total amount of the withdrawal. It amounts
17+
-- to the total amount of the deposits minus the fees and optional change.
18+
withdrawn_amount BIGINT NOT NULL,
19+
20+
-- change_amount is the optional change that the user selected.
21+
change_amount BIGINT NOT NULL,
22+
23+
-- confirmation_height is the block height at which the withdrawal was
24+
-- first confirmed.
25+
confirmation_height BIGINT NOT NULL
26+
);

loopdb/sqlc/models.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loopdb/sqlc/querier.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- name: CreateWithdrawal :exec
2+
INSERT INTO withdrawals (
3+
withdrawal_tx_id,
4+
deposit_outpoints,
5+
total_deposit_amount,
6+
withdrawn_amount,
7+
change_amount,
8+
confirmation_height
9+
) VALUES (
10+
$1,
11+
$2,
12+
$3,
13+
$4,
14+
$5,
15+
$6
16+
);
17+
18+
-- name: AllWithdrawals :many
19+
SELECT
20+
*
21+
FROM
22+
withdrawals
23+
ORDER BY
24+
id ASC;

loopdb/sqlc/static_address_withdrawals.sql.go

Lines changed: 89 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)