-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
32 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
CREATE OR REPLACE FUNCTION grest.script_info(_script_hashes text [], _extended boolean DEFAULT false) | ||
RETURNS TABLE ( | ||
script_hash text, | ||
type text, | ||
value jsonb, | ||
bytes text, | ||
size word31type | ||
) | ||
LANGUAGE plpgsql | ||
AS $$ | ||
DECLARE | ||
_script_hashes_encoded varchar[]; | ||
BEGIN | ||
SELECT INTO _script_hashes_encoded ARRAY_AGG(DECODE(s_hash, 'hex')) | ||
FROM UNNEST(_script_hashes) AS s_hash; | ||
RETURN QUERY | ||
SELECT | ||
ENCODE(s.hash, 'hex')::text AS script_hash, | ||
s.type::text AS type, | ||
s.json AS value, | ||
ENCODE(s.bytes,'hex')::text AS bytes, | ||
s.serialised_size AS size | ||
FROM script AS s | ||
WHERE s.hash = ANY(_script_hashes_encoded) | ||
; | ||
END; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.script_utxos IS 'Get information about a given script FROM hashes.'; -- noqa: LT01 |