Skip to content
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

Add a fee buffer to the transaction builder #315

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Changes from all commits
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: 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 @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading