Skip to content

Commit

Permalink
Namecoin: Generate default label for name transactions.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Oct 1, 2018
1 parent d060326 commit eb2f962
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions electrum_nmc/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ def format_name_op(name_op):
return "\tName Update\n\t\t" + formatted_name + "\n\t\t" + formatted_value


def get_default_name_tx_label(tx):
for addr, v, name_op in tx.get_outputs():
if name_op is not None:
# TODO: Handle multiple atomic name ops.
# TODO: Include "name" field.
if name_op["op"] == OP_NAME_NEW:
return "Name Pre-Registration"
if name_op["op"] == OP_NAME_FIRSTUPDATE:
return "Name Registration"
if name_op["op"] == OP_NAME_UPDATE:
return "Name Update"
return None


from .bitcoin import push_script
from .transaction import match_decoded, opcodes, script_GetOp
from .util import bh2u
Expand Down
7 changes: 7 additions & 0 deletions electrum_nmc/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
from .paymentrequest import InvoiceStore
from .contacts import Contacts

from .names import get_default_name_tx_label

TX_STATUS = [
_('Unconfirmed'),
_('Unconfirmed parent'),
Expand Down Expand Up @@ -482,6 +484,11 @@ def get_label(self, tx_hash):
return label

def get_default_label(self, tx_hash):
# TODO: what happens if a name would have a non-empty default non-name label?
name_label = get_default_name_tx_label(self.transactions.get(tx_hash))
if name_label is not None:
return name_label

if self.txi.get(tx_hash) == {}:
d = self.txo.get(tx_hash, {})
labels = []
Expand Down

0 comments on commit eb2f962

Please sign in to comment.