1
0

txbatcher: if we raise NotEnoughFunds, remove

the largest output from the current tx and retry

In the unit test, this results in waiting until the current tx is mined.
This commit is contained in:
ThomasV
2025-05-19 12:05:31 +02:00
parent 9b24316915
commit 25dabf3105
2 changed files with 20 additions and 6 deletions

View File

@@ -439,10 +439,16 @@ class TxBatch(Logger):
to_sweep_now[k] = v
else:
self.wallet.add_future_tx(v, wanted_height)
if not to_pay and not to_sweep_now and not self._should_bump_fee(base_tx):
return
while True:
tx = self._create_batch_tx(base_tx, to_sweep_now, to_pay)
if not to_pay and not to_sweep_now and not self._should_bump_fee(base_tx):
return
try:
tx = self._create_batch_tx(base_tx, to_sweep_now, to_pay)
except NotEnoughFunds:
k = max(to_pay, key=lambda x: x.value)
self.logger.info(f'Not enough funds, removing output {k}')
to_pay.remove(k)
continue
# 100 kb max standardness rule
if tx.estimated_size() < 100_000:
break