From c4414e8c9c599f1778e87a245aae03d827d4cd5d Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Sat, 10 Feb 2024 18:28:34 +0200 Subject: [PATCH] Minor quality improvements in wallet code --- src/jmclient/wallet.py | 6 ++++-- src/jmclient/wallet_service.py | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/jmclient/wallet.py b/src/jmclient/wallet.py index dc2937a..4f29d08 100644 --- a/src/jmclient/wallet.py +++ b/src/jmclient/wallet.py @@ -765,7 +765,8 @@ class BaseWallet(object): 'address': self._ENGINE.script_to_address(spk)} return added_utxos - def add_utxo(self, txid, index, script, value, height=None): + def add_utxo(self, txid: bytes, index: int, script: bytes, value: int, + height: Optional[int] = None) -> None: assert isinstance(txid, bytes) assert isinstance(index, Integral) assert isinstance(script, bytes) @@ -2613,7 +2614,8 @@ class FidelityBondMixin(object): for timenumber in range(self.TIMENUMBER_COUNT): yield self.get_path(md, address_type, timenumber) - def add_utxo(self, txid, index, script, value, height=None): + def add_utxo(self, txid: bytes, index: int, script: bytes, value: int, + height: Optional[int] = None) -> None: super().add_utxo(txid, index, script, value, height) #dont use coin control freeze if wallet readonly if self._storage.read_only: diff --git a/src/jmclient/wallet_service.py b/src/jmclient/wallet_service.py index 10f3907..7a55c2c 100644 --- a/src/jmclient/wallet_service.py +++ b/src/jmclient/wallet_service.py @@ -867,19 +867,19 @@ class WalletService(Service): et = time.time() jlog.debug('bitcoind sync_unspent took ' + str((et - st)) + 'sec') - def _add_unspent_txo(self, utxo, height): + def _add_unspent_txo(self, utxo: dict, height: Optional[int]) -> None: """ Add a UTXO as returned by rpc's listunspent call to the wallet. Note that these are returned as little endian outpoint txids, so are converted. params: utxo: single utxo dict as returned by listunspent - current_blockheight: blockheight as integer, used to - set the block in which a confirmed utxo is included. + height: blockheight as integer, used to set the block in which + a confirmed utxo is included. """ txid = hextobin(utxo['txid']) script = hextobin(utxo['scriptPubKey']) - value = int(Decimal(str(utxo['amount'])) * Decimal('1e8')) + value = btc.btc_to_sat(utxo['amount']) self.add_utxo(txid, int(utxo['vout']), script, value, height) # if we start up with unconfirmed outputs, they must be # put into the transaction monitor state, so we can recognize