Skip to content

Commit

Permalink
Namecoin: Refactor name_list to use listunspent
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Feb 17, 2020
1 parent 8dfeb7d commit 7557be0
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions electrum_nmc/electrum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,22 +330,15 @@ async def name_list(self, identifier=None, wallet: Abstract_Wallet = None):
"""List unspent name outputs. Returns the list of unspent name_anyupdate
outputs in your wallet."""

# TODO: Namecoin: Re-implement this using listunspent as a backend

l = copy.deepcopy(wallet.get_utxos())
coins = await self.listunspent(wallet)

result = []

for i in l:
txid = i["prevout_hash"]
tx = wallet.db.transactions[txid]

vout = i["prevout_n"]
o = tx.outputs()[vout]

if o.name_op is None:
for coin in coins:
if "name_op" not in coin:
continue
name_op = o.name_op

name_op = coin["name_op"]

if "name" not in name_op:
continue
Expand All @@ -359,10 +352,14 @@ async def name_list(self, identifier=None, wallet: Abstract_Wallet = None):
if identifier != name:
continue

chain_height = self.network.blockchain().height()
txid = coin["prevout_hash"]
vout = coin["prevout_n"]

address = coin["address"]

height = coin["height"]
chain_height = self.network.get_local_height()

address = i["address"]
height = i["height"]
expires_in = name_expires_in(height, chain_height)
expired = expires_in <= 0 if expires_in is not None else None

Expand All @@ -377,6 +374,7 @@ async def name_list(self, identifier=None, wallet: Abstract_Wallet = None):
"expired": expired,
}
result.append(result_item)

return result

@command('n')
Expand Down Expand Up @@ -1154,7 +1152,7 @@ async def updatequeuedtransactions(self, wallet: Abstract_Wallet = None):
trigger_name = send_when["name"]
trigger_depth = send_when["confirmations"]

chain_height = self.network.blockchain().height()
chain_height = self.network.get_local_height()

current_depth = 0

Expand Down

0 comments on commit 7557be0

Please sign in to comment.