From 6f42c91aa4410b9b8fcc67c18b9bf62e66fa2b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Thu, 19 Oct 2023 09:25:10 +0200 Subject: [PATCH] Use potential inputs to satisfy collateral amount --- pycardano/txbuilder.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pycardano/txbuilder.py b/pycardano/txbuilder.py index 9aac15a3..c456936d 100644 --- a/pycardano/txbuilder.py +++ b/pycardano/txbuilder.py @@ -1133,6 +1133,13 @@ def _add_collateral_input(cur_total, candidate_inputs): ) _add_collateral_input(tmp_val, sorted_inputs) + if tmp_val.coin < collateral_amount: + sorted_inputs = sorted( + self.potential_inputs, + key=lambda i: (len(i.output.to_cbor_hex()), -i.output.amount.coin), + ) + _add_collateral_input(tmp_val, sorted_inputs) + if tmp_val.coin < collateral_amount: sorted_inputs = sorted( self.context.utxos(collateral_return_address),