From eb9f19f7ec8d89ff197336e6a1604bc14f1fe3fd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 8 Nov 2024 17:50:16 -0800 Subject: [PATCH] tapdb: add new DeclareScriptKeyKnown query --- tapdb/sqlc/assets.sql.go | 11 +++++++++++ tapdb/sqlc/querier.go | 1 + tapdb/sqlc/queries/assets.sql | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/tapdb/sqlc/assets.sql.go b/tapdb/sqlc/assets.sql.go index 60b9aea95..e77eb0307 100644 --- a/tapdb/sqlc/assets.sql.go +++ b/tapdb/sqlc/assets.sql.go @@ -438,6 +438,17 @@ func (q *Queries) ConfirmChainTx(ctx context.Context, arg ConfirmChainTxParams) return err } +const declareScriptKeyKnown = `-- name: DeclareScriptKeyKnown :exec +UPDATE script_keys +SET declared_known = TRUE +WHERE tweaked_script_key = $1 +` + +func (q *Queries) DeclareScriptKeyKnown(ctx context.Context, tweakedScriptKey []byte) error { + _, err := q.db.ExecContext(ctx, declareScriptKeyKnown, tweakedScriptKey) + return err +} + const deleteExpiredUTXOLeases = `-- name: DeleteExpiredUTXOLeases :exec UPDATE managed_utxos SET lease_owner = NULL, lease_expiry = NULL diff --git a/tapdb/sqlc/querier.go b/tapdb/sqlc/querier.go index 62c213c34..eb075b488 100644 --- a/tapdb/sqlc/querier.go +++ b/tapdb/sqlc/querier.go @@ -25,6 +25,7 @@ type Querier interface { BindMintingBatchWithTx(ctx context.Context, arg BindMintingBatchWithTxParams) error ConfirmChainAnchorTx(ctx context.Context, arg ConfirmChainAnchorTxParams) error ConfirmChainTx(ctx context.Context, arg ConfirmChainTxParams) error + DeclareScriptKeyKnown(ctx context.Context, tweakedScriptKey []byte) error DeleteAllNodes(ctx context.Context, namespace string) (int64, error) DeleteAssetWitnesses(ctx context.Context, assetID int64) error DeleteExpiredUTXOLeases(ctx context.Context, now sql.NullTime) error diff --git a/tapdb/sqlc/queries/assets.sql b/tapdb/sqlc/queries/assets.sql index fe8276af8..d2eefa1e9 100644 --- a/tapdb/sqlc/queries/assets.sql +++ b/tapdb/sqlc/queries/assets.sql @@ -857,6 +857,10 @@ INSERT INTO script_keys ( DO UPDATE SET tweaked_script_key = EXCLUDED.tweaked_script_key RETURNING script_key_id; +-- name: DeclareScriptKeyKnown :exec +UPDATE script_keys +SET declared_known = TRUE +WHERE tweaked_script_key = $1; -- name: FetchScriptKeyIDByTweakedKey :one SELECT script_key_id FROM script_keys