Skip to content

Commit

Permalink
Namecoin: Use tx.serialize() in name commands
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Feb 17, 2020
1 parent 08df0a6 commit 26dc31f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions electrum_nmc/electrum/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ async def name_new(self, identifier, destination=None, amount=0.0, fee=None, fee
password=password,
locktime=locktime,
name_outputs=[(destination, amount, name_op, memo)])
return {"tx": tx.as_dict(), "txid": tx.txid(), "rand": bh2u(rand)}
return {"tx": tx.serialize(), "txid": tx.txid(), "rand": bh2u(rand)}

@command('wp')
async def name_firstupdate(self, identifier, rand, name_new_txid, value, destination=None, amount=0.0, fee=None, feerate=None, from_addr=None, from_coins=None, change_addr=None, nocheck=False, unsigned=False, rbf=None, password=None, locktime=None, allow_early=False, wallet: Abstract_Wallet = None):
Expand Down Expand Up @@ -793,7 +793,7 @@ async def name_firstupdate(self, identifier, rand, name_new_txid, value, destina
locktime=locktime,
name_input_txids=[name_new_txid],
name_outputs=[(destination, amount, name_op, memo)])
return tx.as_dict()
return tx.serialize()

@command('wpn')
async def name_update(self, identifier, value=None, destination=None, amount=0.0, fee=None, feerate=None, from_addr=None, from_coins=None, change_addr=None, nocheck=False, unsigned=False, rbf=None, password=None, locktime=None, wallet: Abstract_Wallet = None):
Expand Down Expand Up @@ -847,7 +847,7 @@ async def name_update(self, identifier, value=None, destination=None, amount=0.0
locktime=locktime,
name_input_identifiers=[identifier_bytes],
name_outputs=[(destination, amount, name_op, memo)])
return tx.as_dict()
return tx.serialize()

@command('wpn')
async def name_autoregister(self, identifier, value, destination=None, amount=0.0, fee=None, feerate=None, from_addr=None, from_coins=None, change_addr=None, nocheck=False, rbf=None, password=None, locktime=None, allow_existing=False, wallet: Abstract_Wallet = None):
Expand All @@ -874,7 +874,7 @@ async def name_autoregister(self, identifier, value, destination=None, amount=0.
wallet=wallet)
new_txid = new_result["txid"]
new_rand = new_result["rand"]
new_tx = new_result["tx"]["hex"]
new_tx = new_result["tx"]

# We add the name_new transaction to the wallet explicitly because
# otherwise, the wallet will only learn about the name_new once the
Expand All @@ -891,7 +891,7 @@ async def name_autoregister(self, identifier, value, destination=None, amount=0.
break

try:
firstupdate_result = await self.name_firstupdate(identifier,
firstupdate_tx = await self.name_firstupdate(identifier,
new_rand,
new_txid,
value,
Expand All @@ -907,7 +907,6 @@ async def name_autoregister(self, identifier, value, destination=None, amount=0.
locktime=locktime,
allow_early=True,
wallet=wallet)
firstupdate_tx = firstupdate_result["hex"]
await self.queuetransaction(firstupdate_tx, 12, trigger_txid=new_txid, wallet=wallet)
except Exception as e:
await self.removelocaltx(new_txid, wallet=wallet)
Expand Down
2 changes: 1 addition & 1 deletion electrum_nmc/electrum/gui/qt/configure_name_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def update_and_broadcast(self, identifier, value, transfer_to):

try:
# TODO: support non-ASCII encodings
tx = name_update(identifier.decode('ascii'), value.decode('ascii'), destination=recipient_address, wallet=self.wallet)['hex']
tx = name_update(identifier.decode('ascii'), value.decode('ascii'), destination=recipient_address, wallet=self.wallet)
except (NotEnoughFunds, NoDynamicFeeEstimates) as e:
formatted_name = format_name_identifier(identifier)
self.main_window.show_message(_("Error creating update for ") + formatted_name + ": " + str(e))
Expand Down
2 changes: 1 addition & 1 deletion electrum_nmc/electrum/gui/qt/uno_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def renew_selected_items(self):

try:
# TODO: support non-ASCII encodings
tx = name_update(identifier.decode('ascii'), wallet=self.wallet)['hex']
tx = name_update(identifier.decode('ascii'), wallet=self.wallet)
except NameUpdatedTooRecentlyError:
# The name was recently updated, so skip it and don't renew.
continue
Expand Down

0 comments on commit 26dc31f

Please sign in to comment.