From 9fb711a64aeff3bafa7cd22641ee02ed02eb65da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Sun, 16 Apr 2023 23:13:09 +0200 Subject: [PATCH 1/2] Make use of spent_at and unspent flag --- pycardano/backend/ogmios.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pycardano/backend/ogmios.py b/pycardano/backend/ogmios.py index 0696d40f..b166aa4f 100644 --- a/pycardano/backend/ogmios.py +++ b/pycardano/backend/ogmios.py @@ -258,7 +258,7 @@ def _utxos_kupo(self, address: str) -> List[UTxO]: "kupo_url object attribute has not been assigned properly." ) - kupo_utxo_url = self._kupo_url + "/matches/" + address + kupo_utxo_url = self._kupo_url + "/matches/" + address + "?unspent" results = requests.get(kupo_utxo_url).json() utxos = [] @@ -267,11 +267,7 @@ def _utxos_kupo(self, address: str) -> List[UTxO]: tx_id = result["transaction_id"] index = result["output_index"] - # Right now, all UTxOs of the address will be returned with Kupo, which requires Ogmios to - # validate if the UTxOs are spent with output reference. This feature is being considered to - # be added to Kupo to avoid extra API calls. - # See discussion here: https://github.com/CardanoSolutions/kupo/discussions/19. - if self._check_utxo_unspent(tx_id, index): + if result["spent_at"] is not None: tx_in = TransactionInput.from_primitive([tx_id, index]) lovelace_amount = result["value"]["coins"] From fd3ce34ecfe2a515c1b8d0ab90b188d7cdcbb16d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Mon, 17 Apr 2023 00:34:01 +0200 Subject: [PATCH 2/2] Fix actually filtering spent utxos out --- pycardano/backend/ogmios.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycardano/backend/ogmios.py b/pycardano/backend/ogmios.py index b166aa4f..8bb1e5b7 100644 --- a/pycardano/backend/ogmios.py +++ b/pycardano/backend/ogmios.py @@ -267,7 +267,7 @@ def _utxos_kupo(self, address: str) -> List[UTxO]: tx_id = result["transaction_id"] index = result["output_index"] - if result["spent_at"] is not None: + if result["spent_at"] is None: tx_in = TransactionInput.from_primitive([tx_id, index]) lovelace_amount = result["value"]["coins"]