Skip to content

Commit

Permalink
Namecoin: Add "Configure DNS" dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyRand committed Nov 29, 2019
1 parent c9e4a9e commit 960a728
Show file tree
Hide file tree
Showing 5 changed files with 1,418 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ Run install (this should install dependencies)::
python3 -m pip install .[fast]


Compile the Qt UI:

sudo apt-get install pyqt5-dev-tools
for i in dnsdialog; do pyuic5 electrum_nmc/electrum/gui/qt/forms/$i.ui --execute --output=electrum_nmc/electrum/gui/qt/forms/$i.py; sed -i s/qvalidatedlineedit/.qvalidatedlineedit/ electrum_nmc/electrum/gui/qt/forms/$i.py; done

Compile the protobuf description file::

sudo apt-get install protobuf-compiler
Expand Down
52 changes: 52 additions & 0 deletions electrum_nmc/electrum/gui/qt/configure_dns_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env python
#
# Electrum-NMC - lightweight Namecoin client
# Copyright (C) 2012-2019 Namecoin Developers, Electrum Developers
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation files
# (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge,
# publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import sys
import traceback

from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

from .forms.dnsdialog import Ui_DNSDialog

dialogs = [] # Otherwise python randomly garbage collects the dialogs...

def show_configure_dns(value, parent):
d = ConfigureDNSDialog(value, parent)

dialogs.append(d)
d.show()

class ConfigureDNSDialog(QDialog):
def __init__(self, value, parent):
# We want to be a top-level window
QDialog.__init__(self, parent=None)

self.name_dialog = parent

self.ui = Ui_DNSDialog()
self.ui.setupUi(self)

26 changes: 24 additions & 2 deletions electrum_nmc/electrum/gui/qt/configure_name_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
from electrum.bitcoin import TYPE_ADDRESS
from electrum.commands import NameAlreadyExistsError
from electrum.i18n import _
from electrum.names import format_name_identifier
from electrum.names import format_name_identifier, identifier_to_namespace
from electrum.network import TxBroadcastError, BestEffortRequestFailed
from electrum.util import NotEnoughFunds, NoDynamicFeeEstimates
from electrum.wallet import InternalAddressCorruption

from .paytoedit import PayToEdit
from .configure_dns_dialog import show_configure_dns

dialogs = [] # Otherwise python randomly garbage collects the dialogs...

Expand Down Expand Up @@ -73,7 +74,27 @@ def __init__(self, identifier, value, parent, is_new):
self.dataEdit = QLineEdit()
# TODO: support non-ASCII encodings
self.dataEdit.setText(value.decode('ascii'))
form_layout.addRow(_("Data:"), self.dataEdit)

self.namespace = identifier_to_namespace(identifier)
self.namespace_is_dns = self.namespace in ["d", "dd"]

if self.namespace_is_dns:
self.dnsButton = QPushButton(_('DNS Editor...'))
self.dnsButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.dnsButton.setMinimumSize(150, 0)
# TODO: tooltip?
self.dnsButton.clicked.connect(lambda: show_configure_dns(self.dataEdit.text().encode('ascii'), self))

data_layout = QHBoxLayout()
data_layout.setContentsMargins(0, 0, 0, 0)
data_layout.addWidget(self.dataEdit)
if self.namespace_is_dns:
data_layout.addWidget(self.dnsButton)

self.data = QWidget()
self.data.setLayout(data_layout)

form_layout.addRow(_("Data:"), self.data)

self.transferTo = PayToEdit(self.main_window)
form_layout.addRow(_("Transfer to:"), self.transferTo)
Expand All @@ -91,6 +112,7 @@ def __init__(self, identifier, value, parent, is_new):
buttons.setLayout(buttons_hbox)

vbox = QVBoxLayout()

vbox.addWidget(form)
vbox.addWidget(buttons)
self.setLayout(vbox)
Expand Down

0 comments on commit 960a728

Please sign in to comment.