Skip to content

Make use of spent_at and unspent flag #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pycardano/backend/ogmios.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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"]
Expand Down