Skip to content

Commit

Permalink
Allow bumpfee on transactions with a single output (#2433)
Browse files Browse the repository at this point in the history
Co-authored-by: k9ert <[email protected]>
  • Loading branch information
leon-costa and k9ert authored May 6, 2024
1 parent c56eff5 commit 9890d1e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/cryptoadvance/specter/wallet/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1734,18 +1734,24 @@ def bumpfee(self, txid, fee_rate):
raise SpecterError(
"Fee difference is too small to relay the RBF transaction"
)
# find change output
change_index = None
for i, out in enumerate(psbt.outputs):
if out.is_change:
change_index = i
break
if change_index is None:
raise SpecterError("Can't bump fee in a transaction without change outputs")
psbt.psbt.outputs[i].value -= round(fee_delta)
if psbt.psbt.outputs[i].value <= 0:
# if we went negative - just drop the change output
psbt.psbt.outputs.remove(psbt.psbt.outputs[i])
if len(psbt.outputs) == 1:
# On single-output transactions we just decrease the output value
psbt.psbt.outputs[0].value -= round(fee_delta)
else:
# find change output
change_index = None
for i, out in enumerate(psbt.outputs):
if out.is_change:
change_index = i
break
if change_index is None:
raise SpecterError(
"Can't bump fee in a transaction without change outputs"
)
psbt.psbt.outputs[i].value -= round(fee_delta)
if psbt.psbt.outputs[i].value <= 0:
# if we went negative - just drop the change output
psbt.psbt.outputs.remove(psbt.psbt.outputs[i])
self.save_pending_psbt(psbt)
return psbt.to_dict()

Expand Down

0 comments on commit 9890d1e

Please sign in to comment.