Also remove child transactions
This commit is contained in:
@@ -182,19 +182,26 @@ class HistoryList(MyTreeWidget):
|
|||||||
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
|
menu.addAction(_("View on block explorer"), lambda: webbrowser.open(tx_URL))
|
||||||
menu.exec_(self.viewport().mapToGlobal(position))
|
menu.exec_(self.viewport().mapToGlobal(position))
|
||||||
|
|
||||||
def remove_local_tx(self, tx_hash):
|
def remove_local_tx(self, delete_tx):
|
||||||
answer = QMessageBox.question(self.parent,
|
to_delete = {delete_tx}
|
||||||
_("Please confirm"),
|
to_delete |= self.wallet.get_depending_transactions(delete_tx)
|
||||||
_("Are you sure you want to remove this transaction?"),
|
|
||||||
QMessageBox.Yes,
|
question = _("Are you sure you want to remove this transaction?")
|
||||||
QMessageBox.No)
|
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:
|
if answer == QMessageBox.No:
|
||||||
return
|
return
|
||||||
self.wallet.remove_transaction(tx_hash)
|
for tx in to_delete:
|
||||||
|
self.wallet.remove_transaction(tx)
|
||||||
root = self.invisibleRootItem()
|
root = self.invisibleRootItem()
|
||||||
child_count = root.childCount()
|
child_count = root.childCount()
|
||||||
|
_offset = 0
|
||||||
for i in range(child_count):
|
for i in range(child_count):
|
||||||
item = root.child(i)
|
item = root.child(i - _offset)
|
||||||
if item.data(0, Qt.UserRole) == tx_hash:
|
if item.data(0, Qt.UserRole) in to_delete:
|
||||||
root.removeChild(item)
|
root.removeChild(item)
|
||||||
return
|
_offset += 1
|
||||||
|
|||||||
@@ -1377,6 +1377,16 @@ class Abstract_Wallet(PrintError):
|
|||||||
index = self.get_address_index(addr)
|
index = self.get_address_index(addr)
|
||||||
return self.keystore.decrypt_message(index, message, password)
|
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):
|
class Simple_Wallet(Abstract_Wallet):
|
||||||
# wallet with a single keystore
|
# wallet with a single keystore
|
||||||
|
|||||||
Reference in New Issue
Block a user