Skip to content

Commit b2d74cc

Browse files
authored
Add a fee buffer to the transaction builder (#315)
1 parent 338f164 commit b2d74cc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pycardano/txbuilder.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class TransactionBuilder:
8888
execution_step_buffer: float = 0.2
8989
"""Additional amount of execution step (in ratio) that will be added on top of estimation"""
9090

91+
fee_buffer: Optional[int] = field(default=None)
92+
"""Additional amount of fee (in lovelace) that will be added on top of estimation."""
93+
9194
ttl: Optional[int] = field(default=None)
9295

9396
validity_start: Optional[int] = field(default=None)
@@ -587,6 +590,9 @@ def _merge_changes(changes):
587590

588591
# With changes included, we can estimate the fee more precisely
589592
self.fee = self._estimate_fee()
593+
# Beyond this, the computed fee is not updated anymore so we can add the fee buffer
594+
if self.fee_buffer is not None:
595+
self.fee += self.fee_buffer
590596

591597
if change_address:
592598
self._outputs = original_outputs
@@ -920,6 +926,8 @@ def _estimate_fee(self):
920926
plutus_execution_units.steps,
921927
plutus_execution_units.mem,
922928
)
929+
if self.fee_buffer is not None:
930+
estimated_fee += self.fee_buffer
923931

924932
return estimated_fee
925933

0 commit comments

Comments
 (0)