From 2860c4fc9fa254771228547bdb90fe762a994def Mon Sep 17 00:00:00 2001 From: chris-belcher Date: Fri, 15 May 2020 17:47:41 +0100 Subject: [PATCH] Freeze timelocked UTXOs with locktimes in future Previously timelocked UTXOs would be returned by calls like select_utxo() and get_utxos_by_mixdepth(). This caused annoyances if trying to burn a single UTXO. It could also cause recently- unlocked coins to accidently get spent, perhaps co-spent with other coins. This commit fixes that by freezing UTXOs with the coin control feature whenever the wallet is sync'd. When the timelock of a coin passes the user must explicitly use coin control to spend it. --- jmclient/jmclient/wallet.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jmclient/jmclient/wallet.py b/jmclient/jmclient/wallet.py index 9a2d6f8..94122f7 100644 --- a/jmclient/jmclient/wallet.py +++ b/jmclient/jmclient/wallet.py @@ -1728,6 +1728,19 @@ class FidelityBondMixin(object): script = self.get_script_from_path(path) self._script_map[script] = path + def add_utxo(self, txid, index, script, value, height=None): + super(FidelityBondMixin, self).add_utxo(txid, index, script, value, + height) + #dont use coin control freeze if wallet readonly + if self._storage.read_only: + return + path = self.script_to_path(script) + if not self.is_timelocked_path(path): + return + if datetime.utcfromtimestamp(path[-1]) > datetime.now(): + #freeze utxo if its timelock is in the future + self.disable_utxo(txid, index, disable=True) + def get_bip32_pub_export(self, mixdepth=None, address_type=None): bip32_pub = super(FidelityBondMixin, self).get_bip32_pub_export(mixdepth, address_type) if address_type == None and mixdepth == self.FIDELITY_BOND_MIXDEPTH: