Skip to content

Commit

Permalink
Add a fee buffer to the transaction builder (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Feb 20, 2024
1 parent 338f164 commit b2d74cc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pycardano/txbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -587,6 +590,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
Expand Down Expand Up @@ -920,6 +926,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

Expand Down

0 comments on commit b2d74cc

Please sign in to comment.