Skip to content

Commit b509918

Browse files
committed
loopdb: load static address params as part of deposits
1 parent 82da34b commit b509918

File tree

6 files changed

+220
-36
lines changed

6 files changed

+220
-36
lines changed

loopd/swapclient_server_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,12 @@ func (s *mockAddressStore) GetStaticAddress(_ context.Context, _ []byte) (
921921
return s.params[0], nil
922922
}
923923

924+
func (s *mockAddressStore) GetStaticAddressID(_ context.Context,
925+
_ []byte) (int32, error) {
926+
927+
return 1, nil
928+
}
929+
924930
func (s *mockAddressStore) GetAllStaticAddresses(_ context.Context) (
925931
[]*address.Parameters, error) {
926932

loopdb/sqlc/querier.go

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

loopdb/sqlc/queries/static_address_deposits.sql

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ INSERT INTO deposits (
77
confirmation_height,
88
timeout_sweep_pk_script,
99
expiry_sweep_txid,
10-
finalized_withdrawal_tx
10+
finalized_withdrawal_tx,
11+
static_address_id
12+
1113
) VALUES (
1214
$1,
1315
$2,
@@ -16,7 +18,8 @@ INSERT INTO deposits (
1618
$5,
1719
$6,
1820
$7,
19-
$8
21+
$8,
22+
$9
2023
);
2124

2225
-- name: UpdateDeposit :exec
@@ -43,29 +46,52 @@ INSERT INTO deposit_updates (
4346

4447
-- name: GetDeposit :one
4548
SELECT
46-
*
47-
FROM
48-
deposits
49+
d.*,
50+
sa.client_pubkey client_pubkey,
51+
sa.server_pubkey server_pubkey,
52+
sa.expiry expiry,
53+
sa.client_key_family client_key_family,
54+
sa.client_key_index client_key_index,
55+
sa.pkscript pkscript,
56+
sa.protocol_version protocol_version,
57+
sa.initiation_height initiation_height
58+
FROM deposits d
59+
LEFT JOIN static_addresses sa ON sa.id = d.static_address_id
4960
WHERE
5061
deposit_id = $1;
5162

5263
-- name: DepositForOutpoint :one
5364
SELECT
54-
*
55-
FROM
56-
deposits
65+
d.*,
66+
sa.client_pubkey client_pubkey,
67+
sa.server_pubkey server_pubkey,
68+
sa.expiry expiry,
69+
sa.client_key_family client_key_family,
70+
sa.client_key_index client_key_index,
71+
sa.pkscript pkscript,
72+
sa.protocol_version protocol_version,
73+
sa.initiation_height initiation_height
74+
FROM deposits d
75+
LEFT JOIN static_addresses sa ON sa.id = d.static_address_id
5776
WHERE
5877
tx_hash = $1
5978
AND
6079
out_index = $2;
6180

6281
-- name: AllDeposits :many
6382
SELECT
64-
*
65-
FROM
66-
deposits
67-
ORDER BY
68-
id ASC;
83+
d.*,
84+
sa.client_pubkey client_pubkey,
85+
sa.server_pubkey server_pubkey,
86+
sa.expiry expiry,
87+
sa.client_key_family client_key_family,
88+
sa.client_key_index client_key_index,
89+
sa.pkscript pkscript,
90+
sa.protocol_version protocol_version,
91+
sa.initiation_height initiation_height
92+
FROM deposits d
93+
LEFT JOIN static_addresses sa ON sa.id = d.static_address_id
94+
ORDER BY d.id ASC;
6995

7096
-- name: GetLatestDepositUpdate :one
7197
SELECT

loopdb/sqlc/queries/static_address_loopin.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,19 @@ WHERE
121121
-- name: DepositsForSwapHash :many
122122
SELECT
123123
d.*,
124+
sa.client_pubkey client_pubkey,
125+
sa.server_pubkey server_pubkey,
126+
sa.expiry expiry,
127+
sa.client_key_family client_key_family,
128+
sa.client_key_index client_key_index,
129+
sa.pkscript pkscript,
130+
sa.protocol_version protocol_version,
131+
sa.initiation_height initiation_height,
124132
u.update_state,
125133
u.update_timestamp
126134
FROM
127135
deposits d
136+
LEFT JOIN static_addresses sa ON sa.id = d.static_address_id
128137
LEFT JOIN
129138
deposit_updates u ON u.id = (
130139
SELECT id

loopdb/sqlc/static_address_deposits.sql.go

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

0 commit comments

Comments
 (0)