From 7be1768c7de5999b4325c2ff83a8e2296841b5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=BCndler?= Date: Tue, 20 Feb 2024 14:15:33 +0100 Subject: [PATCH] Add a fee buffer to the transaction builder --- pycardano/txbuilder.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pycardano/txbuilder.py b/pycardano/txbuilder.py index e3e68471..96f2fcd1 100644 --- a/pycardano/txbuilder.py +++ b/pycardano/txbuilder.py @@ -88,6 +88,9 @@ class TransactionBuilder: execution_step_buffer: float = 0.2 """Additional amount of execution step (in ratio) that will be added on top of estimation""" + fee_buffer: Optional[int] = field(default=None) + """Additional amount of fee (in lovelace) that will be added on top of estimation.""" + ttl: Optional[int] = field(default=None) validity_start: Optional[int] = field(default=None) @@ -544,6 +547,9 @@ def _merge_changes(changes): # With changes included, we can estimate the fee more precisely self.fee = self._estimate_fee() + # Beyond this, the computed fee is not updated anymore so we can add the fee buffer + if self.fee_buffer is not None: + self.fee += self.fee_buffer if change_address: self._outputs = original_outputs @@ -872,6 +878,8 @@ def _estimate_fee(self): plutus_execution_units.steps, plutus_execution_units.mem, ) + if self.fee_buffer is not None: + estimated_fee += self.fee_buffer return estimated_fee