Skip to content

Commit

Permalink
Remove CPFP (child pays for parent)
Browse files Browse the repository at this point in the history
This feature is going away from BCH very soon with the May 15th 2021
network upgrade.  As such, we remove it now.  It hardly was used anyway
on BCH so nobody will miss it if it's simply gone right away without a
transition period.

Miners running BCHN 23.0.0 don't have CPFP code anymore anyway when
generating blocks so.. it's a good idea to remove this ASAP as well.
  • Loading branch information
cculianu committed Apr 16, 2021
1 parent af09280 commit c25a0e4
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 81 deletions.
21 changes: 0 additions & 21 deletions electroncash/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,27 +2221,6 @@ def address_is_old(self, address, age_limit=2):
break # ok, it's old. not need to keep looping
return age > age_limit

def cpfp(self, tx, fee, sign_schnorr=None):
''' sign_schnorr is a bool or None for auto '''
sign_schnorr = self.is_schnorr_enabled() if sign_schnorr is None else bool(sign_schnorr)
txid = tx.txid()
for i, o in enumerate(tx.outputs()):
otype, address, value = o
if otype == TYPE_ADDRESS and self.is_mine(address):
break
else:
return
coins = self.get_addr_utxo(address)
item = coins.get(txid+':%d'%i)
if not item:
return
self.add_input_info(item)
inputs = [item]
outputs = [(TYPE_ADDRESS, address, value - fee)]
locktime = self.get_local_height()
# note: no need to call tx.BIP_LI01_sort() here - single input/output
return Transaction.from_io(inputs, outputs, locktime=locktime, sign_schnorr=sign_schnorr)

def add_input_info(self, txin):
address = txin['address']
if self.is_mine(address):
Expand Down
4 changes: 0 additions & 4 deletions electroncash_gui/qt/history_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,6 @@ def create_menu(self, position):
lambda: self.currentItem() and self.editItem(self.currentItem(), column))
label = self.wallet.get_label(tx_hash) or None
menu.addAction(_("&Details"), lambda: self.parent.show_transaction(tx, label))
if is_unconfirmed and tx:
child_tx = self.wallet.cpfp(tx, 0)
if child_tx:
menu.addAction(_("Child pays for parent"), lambda: self.parent.cpfp(tx, child_tx))
if pr_key:
menu.addAction(self.invoiceIcon, _("View invoice"), lambda: self.parent.show_invoice(pr_key))
if tx_URL:
Expand Down
56 changes: 0 additions & 56 deletions electroncash_gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -4913,62 +4913,6 @@ def hardware_wallet_support(self):
d.exec_()
self.hardwarewalletdialog = None # allow python to GC

def cpfp(self, parent_tx, new_tx):
total_size = parent_tx.estimated_size() + new_tx.estimated_size()
d = WindowModalDialog(self.top_level_window(), _('Child Pays for Parent'))
vbox = QVBoxLayout(d)
msg = (
"A CPFP is a transaction that sends an unconfirmed output back to "
"yourself, with a high fee. The goal is to have miners confirm "
"the parent transaction in order to get the fee attached to the "
"child transaction.")
vbox.addWidget(WWLabel(_(msg)))
msg2 = ("The proposed fee is computed using your "
"fee/kB settings, applied to the total size of both child and "
"parent transactions. After you broadcast a CPFP transaction, "
"it is normal to see a new unconfirmed transaction in your history.")
vbox.addWidget(WWLabel(_(msg2)))
grid = QGridLayout()
grid.addWidget(QLabel(_('Total size') + ':'), 0, 0)
grid.addWidget(QLabel(_('{total_size} bytes').format(total_size=total_size)), 0, 1)
max_fee = new_tx.output_value()
grid.addWidget(QLabel(_('Input amount') + ':'), 1, 0)
grid.addWidget(QLabel(self.format_amount(max_fee) + ' ' + self.base_unit()), 1, 1)
output_amount = QLabel('')
grid.addWidget(QLabel(_('Output amount') + ':'), 2, 0)
grid.addWidget(output_amount, 2, 1)
fee_e = BTCAmountEdit(self.get_decimal_point)
def f(x):
a = max_fee - fee_e.get_amount()
output_amount.setText((self.format_amount(a) + ' ' + self.base_unit()) if a else '')
fee_e.textChanged.connect(f)
fee = self.config.fee_per_kb() * total_size / 1000
fee_e.setAmount(fee)
grid.addWidget(QLabel(_('Fee' + ':')), 3, 0)
grid.addWidget(fee_e, 3, 1)
def on_rate(dyn, pos, fee_rate):
fee = fee_rate * total_size / 1000
fee = min(max_fee, fee)
fee_e.setAmount(fee)
fee_slider = FeeSlider(self, self.config, on_rate)
fee_slider.update()
grid.addWidget(fee_slider, 4, 1)
vbox.addLayout(grid)
vbox.addLayout(Buttons(CancelButton(d), OkButton(d)))
result = d.exec_()
d.setParent(None) # So Python can GC
if not result:
return
fee = fee_e.get_amount()
if fee > max_fee:
self.show_error(_('Max fee exceeded'))
return
new_tx = self.wallet.cpfp(parent_tx, fee)
if new_tx is None:
self.show_error(_('CPFP no longer valid'))
return
self.show_transaction(new_tx)

def rebuild_history(self):
if self.gui_object.warn_if_no_network(self):
# Don't allow if offline mode.
Expand Down

0 comments on commit c25a0e4

Please sign in to comment.