From 301fc0889f7584d4e5c1498393d9328b388a4174 Mon Sep 17 00:00:00 2001 From: Leon Costa Date: Thu, 22 Aug 2024 18:46:15 +0200 Subject: [PATCH] Use embit to decode the raw transaction Because the decoderawtransaction RPC is not available in Spectrum and the tools to decode the raw transaction are already there. --- src/cryptoadvance/specter/wallet/wallet.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cryptoadvance/specter/wallet/wallet.py b/src/cryptoadvance/specter/wallet/wallet.py index ab0f375e0..8c9eff0c5 100644 --- a/src/cryptoadvance/specter/wallet/wallet.py +++ b/src/cryptoadvance/specter/wallet/wallet.py @@ -735,14 +735,10 @@ def check_utxo(self): raw_transaction = self.rpc.decoderawtransaction( raw_transaction_hex ) - searched_raw_vout = [ - _output - for _output in raw_transaction["vout"] - if _output["n"] == utxo_vout - ][0] - tx_copy["amount"] = searched_raw_vout["value"] - script_pubkey = searched_raw_vout["scriptPubKey"] - tx_copy["address"] = script_pubkey["address"] + parsed_transaction = self.TxCls.from_string(raw_transaction_hex) + out = parsed_transaction.vout[utxo_vout] + tx_copy["amount"] = round(out.value * 1e-8, 8) + tx_copy["address"] = out.script_pubkey.address(self.network) # Append the copy to the _full_utxo list _full_utxo.append(tx_copy)