diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b79afdd..9280c94f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Addded +- `/txs/{hash}/utxos` + - `consumed_by_tx` field - `/epochs/{number}/parameters` and `/epochs/latest/parameters` - `cost_models_raw` field, list variant of cost_models without name mapping diff --git a/src/sql/txs/txs_hash_utxos_2.sql b/src/sql/txs/txs_hash_utxos_2.sql index 417826a1..8bf54f6f 100644 --- a/src/sql/txs/txs_hash_utxos_2.sql +++ b/src/sql/txs/txs_hash_utxos_2.sql @@ -20,7 +20,11 @@ FROM ( encode(dat.bytes, 'hex') AS "inline_datum", false AS "collateral", encode(scr.hash, 'hex') AS "reference_script_hash", - txo.index AS "output_index" + txo.index AS "output_index", + ( + SELECT encode(tx.hash, 'hex') + FROM tx WHERE tx.id = txo.consumed_by_tx_id + ) AS "consumed_by_tx" FROM tx JOIN tx_out txo ON (txo.tx_id = tx.id) LEFT JOIN datum dat ON (txo.inline_datum_id = dat.id) @@ -35,7 +39,8 @@ FROM ( encode(dat.bytes, 'hex') AS "inline_datum", true AS "collateral", encode(scr.hash, 'hex') AS "reference_script_hash", - txo.index AS "output_index" + txo.index AS "output_index", + NULL as "consumed_by_tx" FROM tx JOIN collateral_tx_out txo ON (txo.tx_id = tx.id) LEFT JOIN datum dat ON (txo.inline_datum_id = dat.id)