1
0

commands: "bumpfee" to accept either a raw tx or a txid as its 1st arg

closes https://github.com/spesmilo/electrum/issues/8603
This commit is contained in:
SomberNight
2023-09-07 13:18:23 +00:00
parent a560841f3f
commit f29cd810e3
3 changed files with 33 additions and 9 deletions

View File

@@ -49,6 +49,7 @@ from .bip32 import BIP32Node
from .i18n import _
from .transaction import (Transaction, multisig_script, TxOutput, PartialTransaction, PartialTxOutput,
tx_from_any, PartialTxInput, TxOutpoint)
from . import transaction
from .invoices import PR_PAID, PR_UNPAID, PR_UNKNOWN, PR_EXPIRED
from .synchronizer import Notifier
from .wallet import Abstract_Wallet, create_new_wallet, restore_wallet_from_text, Deterministic_Wallet
@@ -779,8 +780,19 @@ class Commands:
@command('wp')
async def bumpfee(self, tx, new_fee_rate, from_coins=None, decrease_payment=False, password=None, unsigned=False, wallet: Abstract_Wallet = None):
""" Bump the Fee for an unconfirmed Transaction """
tx = Transaction(tx)
"""Bump the fee for an unconfirmed transaction.
'tx' can be either a raw hex tx or a txid. If txid, the corresponding tx must already be part of the wallet history.
"""
if is_hash256_str(tx): # txid
tx = wallet.db.get_transaction(tx)
if tx is None:
raise Exception("Transaction not in wallet.")
else: # raw tx
try:
tx = Transaction(tx)
tx.deserialize()
except transaction.SerializationError as e:
raise Exception(f"Failed to deserialize transaction: {e}") from e
domain_coins = from_coins.split(',') if from_coins else None
coins = wallet.get_spendable_coins(None)
if domain_coins is not None: