Skip to content

Commit

Permalink
Namecoin: Fix name prefixes in _add_input_utxo_info
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Feb 17, 2020
1 parent 500c252 commit ccfd779
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions electrum_nmc/electrum/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1315,8 +1315,18 @@ def _add_input_utxo_info(self, txin: PartialTxInput, address: str) -> None:
received, spent = self.get_addr_io(address)
item = received.get(txin.prevout.to_str())
if item:
txin_value = item[1]
txin.witness_utxo = TxOutput.from_address_and_value(address, txin_value)
# TODO: Namecoin: Upstream Electrum constructs a TxOutput
# here with the assumption that the scriptpubkey can be
# derived from the address. This isn't true for Namecoin
# because doing so omits the name prefix. We should try to
# submit a PR to upstream Electrum that uses the original
# scriptpubkey instead. In the meantime, we do this stupid
# hack.
#txin_value = item[1]
#txin.witness_utxo = TxOutput.from_address_and_value(address, txin_value)
input_tx = self.get_input_tx(txin.prevout.txid.hex(), ignore_network_issues=True)
input_txout = input_tx.outputs()[txin.prevout.out_idx]
txin.witness_utxo = TxOutput(scriptpubkey=input_txout.scriptpubkey, value=input_txout.value)
else: # legacy input
if txin.utxo is None:
# note: for hw wallets, for legacy inputs, ignore_network_issues used to be False
Expand Down

0 comments on commit ccfd779

Please sign in to comment.