Skip to content

Commit

Permalink
Use embit to decode the raw transaction
Browse files Browse the repository at this point in the history
Because the decoderawtransaction RPC is not available in Spectrum and
the tools to decode the raw transaction are already there.
  • Loading branch information
leon-costa committed Aug 22, 2024
1 parent ec5e1b2 commit 2efd56c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/cryptoadvance/specter/wallet/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,17 +732,10 @@ def check_utxo(self):
# It may be related to https://github.com/bitcoin/bitcoin/issues/28555
# In this case we decode the raw transaction to get the data we want.
raw_transaction_hex = tx_from_core["hex"]
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)
Expand Down

0 comments on commit 2efd56c

Please sign in to comment.