@@ -336,11 +336,12 @@ class AddressSynchronizer(PrintError):
|
|||||||
|
|
||||||
def get_depending_transactions(self, tx_hash):
|
def get_depending_transactions(self, tx_hash):
|
||||||
"""Returns all (grand-)children of tx_hash in this wallet."""
|
"""Returns all (grand-)children of tx_hash in this wallet."""
|
||||||
children = set()
|
with self.transaction_lock:
|
||||||
for other_hash in self.spent_outpoints[tx_hash].values():
|
children = set()
|
||||||
children.add(other_hash)
|
for other_hash in self.spent_outpoints[tx_hash].values():
|
||||||
children |= self.get_depending_transactions(other_hash)
|
children.add(other_hash)
|
||||||
return children
|
children |= self.get_depending_transactions(other_hash)
|
||||||
|
return children
|
||||||
|
|
||||||
def receive_tx_callback(self, tx_hash, tx, tx_height):
|
def receive_tx_callback(self, tx_hash, tx, tx_height):
|
||||||
self.add_unverified_tx(tx_hash, tx_height)
|
self.add_unverified_tx(tx_hash, tx_height)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ from decimal import Decimal
|
|||||||
from typing import Optional, TYPE_CHECKING
|
from typing import Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from .import util, ecc
|
from .import util, ecc
|
||||||
from .util import bfh, bh2u, format_satoshis, json_decode, print_error, json_encode
|
from .util import bfh, bh2u, format_satoshis, json_decode, print_error, json_encode, is_hash256_str
|
||||||
from . import bitcoin
|
from . import bitcoin
|
||||||
from .bitcoin import is_address, hash_160, COIN, TYPE_ADDRESS
|
from .bitcoin import is_address, hash_160, COIN, TYPE_ADDRESS
|
||||||
from . import bip32
|
from . import bip32
|
||||||
@@ -46,6 +46,7 @@ from .synchronizer import Notifier
|
|||||||
from .storage import WalletStorage
|
from .storage import WalletStorage
|
||||||
from . import keystore
|
from . import keystore
|
||||||
from .wallet import Wallet, Imported_Wallet, Abstract_Wallet
|
from .wallet import Wallet, Imported_Wallet, Abstract_Wallet
|
||||||
|
from .address_synchronizer import TX_HEIGHT_LOCAL
|
||||||
from .mnemonic import Mnemonic
|
from .mnemonic import Mnemonic
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -763,6 +764,23 @@ class Commands:
|
|||||||
fee_level = Decimal(fee_level)
|
fee_level = Decimal(fee_level)
|
||||||
return self.config.fee_per_kb(dyn=dyn, mempool=mempool, fee_level=fee_level)
|
return self.config.fee_per_kb(dyn=dyn, mempool=mempool, fee_level=fee_level)
|
||||||
|
|
||||||
|
@command('w')
|
||||||
|
def removelocaltx(self, txid):
|
||||||
|
"""Remove a 'local' transaction from the wallet, and its dependent
|
||||||
|
transactions.
|
||||||
|
"""
|
||||||
|
if not is_hash256_str(txid):
|
||||||
|
raise Exception(f"{repr(txid)} is not a txid")
|
||||||
|
height = self.wallet.get_tx_height(txid).height
|
||||||
|
to_delete = {txid}
|
||||||
|
if height != TX_HEIGHT_LOCAL:
|
||||||
|
raise Exception(f'Only local transactions can be removed. '
|
||||||
|
f'This tx has height: {height} != {TX_HEIGHT_LOCAL}')
|
||||||
|
to_delete |= self.wallet.get_depending_transactions(txid)
|
||||||
|
for tx_hash in to_delete:
|
||||||
|
self.wallet.remove_transaction(tx_hash)
|
||||||
|
self.wallet.save_transactions(write=True)
|
||||||
|
|
||||||
@command('')
|
@command('')
|
||||||
def help(self):
|
def help(self):
|
||||||
# for the python console
|
# for the python console
|
||||||
|
|||||||
Reference in New Issue
Block a user