Skip to content

Commit

Permalink
Namecoin: Allow name_update to use existing value if explicit value o…
Browse files Browse the repository at this point in the history
…mitted
  • Loading branch information
JeremyRand committed Oct 4, 2018
1 parent dd0fedc commit 5ecac39
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions electrum_nmc/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,27 @@ def name_firstupdate(self, identifier, rand, name_new_txid, value, destination=N
tx = self._mktx([], tx_fee, change_addr, domain, nocheck, unsigned, rbf, password, locktime, name_input_txids=[name_new_txid], name_outputs=[(destination, amount, name_op)])
return tx.as_dict()

@command('wp')
def name_update(self, identifier, value, destination=None, amount=0.0, fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, rbf=None, password=None, locktime=None):
@command('wpn')
def name_update(self, identifier, value=None, destination=None, amount=0.0, fee=None, from_addr=None, change_addr=None, nocheck=False, unsigned=False, rbf=None, password=None, locktime=None):
"""Create a name_update transaction. """

tx_fee = satoshis(fee)
domain = from_addr.split(',') if from_addr else None

# Allow renewing a name without any value changes by omitting the
# value.
if value is None:
list_results = self.name_list(identifier)[0]

# This check is in place to prevent an attack where an ElectrumX
# server supplies an unconfirmed name_update transaction with a
# malicious value and then tricks the wallet owner into signing a
# name renewal with that malicious value.
if list_results["expires_in"] > 36000 - 12:
raise Exception("Name was updated too recently to safely determine current value. Either wait or specify an explicit value.")

value = list_results["value"]

# TODO: support non-ASCII encodings
# TODO: enforce length limits on identifier and value
identifier_bytes = identifier.encode("ascii")
Expand Down Expand Up @@ -947,6 +961,7 @@ def help(self):
'allow_existing': (None, "Allow pre-registering a name that already is registered. Your registration fee will be forfeited until you can register the name after it expires."),
'allow_early': (None, "Allow submitting a name registration while its pre-registration is still pending. This increases the risk of an attacker stealing your name registration."),
'identifier': (None, "The requested name identifier"),
'value': (None, "The value to assign to the name"),
}


Expand Down

0 comments on commit 5ecac39

Please sign in to comment.