mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +00:00
Also remove child transactions
This commit is contained in:
parent
887e06eebb
commit
fbcee9a6f6
2 changed files with 27 additions and 10 deletions
|
@ -182,19 +182,26 @@ class HistoryList(MyTreeWidget):
|
|||
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
|
||||
menu.exec_(self.viewport().mapToGlobal(position))
|
||||
|
||||
def remove_local_tx(self, tx_hash):
|
||||
answer = QMessageBox.question(self.parent,
|
||||
_("Please confirm"),
|
||||
_("Are you sure you want to remove this transaction?"),
|
||||
QMessageBox.Yes,
|
||||
QMessageBox.No)
|
||||
def remove_local_tx(self, delete_tx):
|
||||
to_delete = {delete_tx}
|
||||
to_delete |= self.wallet.get_depending_transactions(delete_tx)
|
||||
|
||||
question = _("Are you sure you want to remove this transaction?")
|
||||
if len(to_delete) > 1:
|
||||
question = _(
|
||||
"Are you sure you want to remove this transaction and {} child transactions?".format(len(to_delete) - 1)
|
||||
)
|
||||
|
||||
answer = QMessageBox.question(self.parent, _("Please confirm"), question, QMessageBox.Yes, QMessageBox.No)
|
||||
if answer == QMessageBox.No:
|
||||
return
|
||||
self.wallet.remove_transaction(tx_hash)
|
||||
for tx in to_delete:
|
||||
self.wallet.remove_transaction(tx)
|
||||
root = self.invisibleRootItem()
|
||||
child_count = root.childCount()
|
||||
_offset = 0
|
||||
for i in range(child_count):
|
||||
item = root.child(i)
|
||||
if item.data(0, Qt.UserRole) == tx_hash:
|
||||
item = root.child(i - _offset)
|
||||
if item.data(0, Qt.UserRole) in to_delete:
|
||||
root.removeChild(item)
|
||||
return
|
||||
_offset += 1
|
||||
|
|
|
@ -1377,6 +1377,16 @@ class Abstract_Wallet(PrintError):
|
|||
index = self.get_address_index(addr)
|
||||
return self.keystore.decrypt_message(index, message, password)
|
||||
|
||||
def get_depending_transactions(self, tx_hash):
|
||||
"""Returns all (grand-)children of tx_hash in this wallet."""
|
||||
children = set()
|
||||
for other_hash, tx in self.transactions.items():
|
||||
for input in (tx.inputs()):
|
||||
if input["prevout_hash"] == tx_hash:
|
||||
children.add(other_hash)
|
||||
children |= self.get_depending_transactions(other_hash)
|
||||
return children
|
||||
|
||||
|
||||
class Simple_Wallet(Abstract_Wallet):
|
||||
# wallet with a single keystore
|
||||
|
|
Loading…
Add table
Reference in a new issue