1
0

Adding BumpFee command to the CLI (#7438)

closes https://github.com/spesmilo/electrum/issues/5791
This commit is contained in:
Siddhant Chawla
2021-08-11 17:00:26 +05:30
committed by GitHub
parent 9b774d3a5d
commit e9f08ef69e
2 changed files with 53 additions and 1 deletions

View File

@@ -50,7 +50,7 @@ from .transaction import (Transaction, multisig_script, TxOutput, PartialTransac
tx_from_any, PartialTxInput, TxOutpoint)
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
from .wallet import Abstract_Wallet, create_new_wallet, restore_wallet_from_text, Deterministic_Wallet, BumpFeeStrategy
from .address_synchronizer import TX_HEIGHT_LOCAL
from .mnemonic import Mnemonic
from .lnutil import SENT, RECEIVED
@@ -710,6 +710,37 @@ class Commands:
return json_normalize(wallet.get_detailed_history(**kwargs))
@command('wp')
async def bumpfee(self, tx, new_fee_rate, from_coins=None, strategies=None, password=None, unsigned=False, wallet: Abstract_Wallet = None):
""" Bump the Fee for an unconfirmed Transaction """
tx = Transaction(tx)
domain_coins = from_coins.split(',') if from_coins else None
coins = wallet.get_spendable_coins(None)
if domain_coins is not None:
coins = [coin for coin in coins if (coin.prevout.to_str() in domain_coins)]
strategies = strategies.split(',') if strategies else None
bumpfee_strategies = None
if strategies is not None:
bumpfee_strategies = []
for strategy in strategies:
if strategy == 'CoinChooser':
bumpfee_strategies.append(BumpFeeStrategy.COINCHOOSER)
elif strategy == 'DecreaseChange':
bumpfee_strategies.append(BumpFeeStrategy.DECREASE_CHANGE)
elif strategy == 'DecreasePayment':
bumpfee_strategies.append(BumpFeeStrategy.DECREASE_PAYMENT)
else:
raise Exception("Invalid Choice of Strategies")
new_tx = wallet.bump_fee(
tx=tx,
txid=tx.txid(),
coins=coins,
strategies=bumpfee_strategies,
new_fee_rate=new_fee_rate)
if not unsigned:
wallet.sign_transaction(new_tx, password)
return new_tx.serialize()
@command('wl')
async def lightning_history(self, show_fiat=False, wallet: Abstract_Wallet = None):
""" lightning history """
@@ -1302,6 +1333,8 @@ command_options = {
'iknowwhatimdoing': (None, "Acknowledge that I understand the full implications of what I am about to do"),
'gossip': (None, "Apply command to gossip node instead of wallet"),
'connection_string': (None, "Lightning network node ID or network address"),
'new_fee_rate': (None, "The Updated/Increased Transaction fee rate (in sat/byte)"),
'strategies': (None, "Select RBF any one or multiple RBF strategies in any order, separated by ','; Options : 'CoinChooser','DecreaseChange','DecreasePayment' "),
}