Skip to content

Commit 98edcb4

Browse files
committed
sqlc: add query FetchUnspentSupplyPreCommits
Introduce query to fetch unspent supply pre-commitment outputs. Each output originates from a mint anchor transaction and corresponds to an asset issuance where a peer node, not the local node, acted as the issuer. This differs from FetchUnspentMintSupplyPreCommits, which only returns pre-commitments minted by the local node.
1 parent 8682cb5 commit 98edcb4

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

tapdb/sqlc/querier.go

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

tapdb/sqlc/queries/supply_commit.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,23 @@ WHERE transition_id = @transition_id;
194194
DELETE FROM supply_update_events
195195
WHERE transition_id = @transition_id;
196196

197+
-- name: FetchUnspentSupplyPreCommits :many
198+
-- Fetch unspent supply pre-commitment outputs. Each pre-commitment output
199+
-- comes from a mint anchor transaction and relates to an asset issuance
200+
-- where a peer node acted as the issuer. Rows in this table do not relate to an
201+
-- issuance where the local node acted as the issuer.
202+
SELECT
203+
chain_txns.block_height,
204+
chain_txns.raw_tx,
205+
pre_commit.outpoint,
206+
pre_commit.taproot_internal_key,
207+
pre_commit.group_key
208+
FROM supply_pre_commits pre_commit
209+
JOIN chain_txns ON pre_commit.chain_txn_db_id = chain_txns.txn_id
210+
WHERE
211+
pre_commit.group_key = @group_key AND
212+
pre_commit.spent_by IS NULL;
213+
197214
-- name: FetchUnspentMintSupplyPreCommits :many
198215
-- Fetch unspent supply pre-commitment outputs. Each pre-commitment output
199216
-- comes from a mint anchor transaction and relates to an asset issuance

tapdb/sqlc/supply_commit.sql.go

Lines changed: 55 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)