Skip to content

Commit

Permalink
api: make valid_until_block configurable in TxBuilder (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
ixje authored Sep 16, 2024
1 parent 644388e commit e690aa6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions neo3/api/helpers/txbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ async def calculate_system_fee(self) -> None:
res = await self.client.invoke_script(self.tx.script, self.tx.signers)
self.tx.system_fee = res.gas_consumed

async def set_valid_until_block(self) -> None:
async def set_valid_until_block(self, blocks: int = 1500) -> None:
"""
Set maximum time the transaction is valid in the mempool. Defaults to about 24h for a network with 15s blocktime.
Args:
blocks: until how many blocks from the current chain height is the transaction valid. Defaults to ~24 hours.
"""
self.tx.valid_until_block = await self.client.get_block_count() + 1500
self.tx.valid_until_block = await self.client.get_block_count() + blocks

async def calculate_network_fee(self) -> None:
"""
Expand Down

0 comments on commit e690aa6

Please sign in to comment.