Skip to content

Commit

Permalink
Namecoin: Deprioritize "trusted addresses" in PartialTxInput
Browse files Browse the repository at this point in the history
They interfere with name prefixes.
  • Loading branch information
JeremyRand committed Feb 17, 2020
1 parent ccfd779 commit 2612c6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions electrum_nmc/electrum/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,13 +1299,18 @@ def name_op(self) -> Optional[dict]:

@property
def scriptpubkey(self) -> Optional[bytes]:
if self._trusted_address is not None:
return bfh(bitcoin.address_to_script(self._trusted_address))
# TODO: Namecoin: Upstream Electrum assumes that a scriptpubkey can
# always be derived from an address. This is false for Namecoin
# because of the name prefix. For Namecoin we currently deprioritize
# the "trusted address" feature here, but we should submit a PR to
# upstream Electrum that makes it use a "trusted scriptpubkey" instead.
if self.utxo:
out_idx = self.prevout.out_idx
return self.utxo.outputs()[out_idx].scriptpubkey
if self.witness_utxo:
return self.witness_utxo.scriptpubkey
if self._trusted_address is not None:
return bfh(bitcoin.address_to_script(self._trusted_address))
return None

def is_complete(self) -> bool:
Expand Down

0 comments on commit 2612c6b

Please sign in to comment.