commit b080df9cff55675935ca3649c6aaa01e8e667b37
parent 4346d2fc765f40a9388108c06cf1ee132d663923
Author: SomberNight <somber.night@protonmail.com>
Date: Mon, 15 Feb 2021 09:20:31 +0100
wallet.bump_fee: (fix) make sure input signatures are removed
bump_fee was returning an invalid tx if its input was a
PartialTransaction that had signatures. It was relying on
line 1441 to remove signatures.
Relatedly, the WalletDB used to store such PartialTransactions as
PartialTransaction objects, but only until the program was restarted.
This is because serialising and de-serialising such a tx results in a
Transaction object.
So, combining these two, to reproduce a bug:
- create a tx, sign it, save as local
- bump fee, sign it, save as local
- bump fee --> tx already signed!? --> has old sigs, so it is invalid
Diffstat:
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/electrum/wallet.py b/electrum/wallet.py
@@ -1440,6 +1440,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
if not isinstance(tx, PartialTransaction):
tx = PartialTransaction.from_tx(tx)
assert isinstance(tx, PartialTransaction)
+ tx.remove_signatures()
if tx.is_final():
raise CannotBumpFee(_('Transaction is final'))
new_fee_rate = quantize_feerate(new_fee_rate) # strip excess precision
diff --git a/electrum/wallet_db.py b/electrum/wallet_db.py
@@ -968,6 +968,8 @@ class WalletDB(JsonDB):
assert isinstance(tx_hash, str)
assert isinstance(tx, Transaction), tx
# note that tx might be a PartialTransaction
+ # serialize and de-serialize tx now. this might e.g. convert a complete PartialTx to a Tx
+ tx = tx_from_any(str(tx))
if not tx_hash:
raise Exception("trying to add tx to db without txid")
if tx_hash != tx.txid():