Skip to content

Commit

Permalink
feat: unstoppable domains (#1097)
Browse files Browse the repository at this point in the history
  • Loading branch information
amritkumarj authored Oct 21, 2022
1 parent 243d074 commit 92f671f
Show file tree
Hide file tree
Showing 50 changed files with 301 additions and 51 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ You can also check out this [Linux Wallet Video Tutorial](https://www.youtube.co
* [OS X Instructions](doc/build-osx.md)
* [Windows Instructions](doc/build-windows.md)
## Use [Unstoppable Domains](https://unstoppabledomains.com)
To use VERGE with Unstoppable Domains for sending coins using Web3 Domains (know more about [Unstoppable Domains here](https://unstoppabledomains.com)), use this command to start the app "./verge-qt --with-unstoppable".
## Developer Notes
The Easy Method:
Expand Down Expand Up @@ -302,3 +307,4 @@ Alternatively, if you would like to make a suggestion regarding a potential fix
### Security-related issues
Contact the developers privately by sending an e-mail to [email protected] with the details of the issue. Do not post the issue on github or anywhere else until the issue has been resolved.
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void SetupServerArgs()
std::vector<std::string> hidden_args = {"-rpcssl", "-benchmark", "-h", "-help", "-socks", "-tor", "-debugnet", "-whitelistalwaysrelay",
"-prematurewitness", "-walletprematurewitness", "-promiscuousmempoolflags", "-blockminsize", "-dbcrashratio", "-forcecompactdb", "-usehd",
// GUI args. These will be overwritten by SetupUIArgs for the GUI
"-allowselfsignedrootcertificates", "-choosedatadir", "-lang=<lang>", "-min", "-resetguisettings", "-rootcertificates=<file>", "-splash", "-uiplatform"};
"-allowselfsignedrootcertificates", "-choosedatadir", "-lang=<lang>", "-min", "-resetguisettings", "-rootcertificates=<file>", "-splash", "-uiplatform", "with-unstoppable"};

// Set all of the args and their help
// When adding new options to the categories, please keep and ensure alphabetical ordering.
Expand Down
4 changes: 4 additions & 0 deletions src/qt/guiconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ static const int MAX_URI_LENGTH = 255;
#define QAPP_APP_NAME_DEFAULT "verge-qt"
#define QAPP_APP_NAME_TESTNET "verge-qt-testnet"

#define UNS_API_KEY "Bearer e2bec832-7a87-41cc-bc67-1aac72e2e033"
#define UNS_API "http://resolve.unstoppabledomains.com/domains/"
#define UNS_XVG_RECORD "crypto.XVG.address"

#endif // VERGE_QT_GUICONSTANTS_H
62 changes: 60 additions & 2 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
#include <QThread>
#include <QMouseEvent>

#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QJsonObject>
#include <QJsonDocument>

#include <qt/guiconstants.h>

#if QT_VERSION < 0x050000
#include <QUrl>
#else
Expand Down Expand Up @@ -123,6 +131,51 @@ static std::string DummyAddress(const CChainParams &params)
return "";
}

QString resolveUnsDomain(QString domain)
{
if(!unsEnabled()) return domain;

bool isDomain = domain.contains(".");
if(isDomain){
QEventLoop eventLoop;

QNetworkAccessManager mgr;
QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));

QNetworkRequest req(QUrl(QString(UNS_API).append(domain)));

req.setRawHeader("Authorization", UNS_API_KEY);
QNetworkReply *reply = mgr.get(req);
eventLoop.exec();

if (reply->error() == QNetworkReply::NoError) {
//success

QByteArray result = reply->readAll();
QJsonDocument jsonResponse = QJsonDocument::fromJson(result);
QJsonObject mainObj = jsonResponse.object();
QJsonObject recordObj = mainObj["records"].toObject();

delete reply;

if(recordObj.contains(QString(UNS_XVG_RECORD))){
return QString(recordObj[QString(UNS_XVG_RECORD)].toString());
}
}
else {
//failure
delete reply;
}
}

return domain;
}


bool unsEnabled(){
return gArgs.GetBoolArg("-with-unstoppable", false);
}

void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
{
parent->setFocusProxy(widget);
Expand All @@ -131,8 +184,13 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
#if QT_VERSION >= 0x040700
// We don't want translators to use own addresses in translations
// and this is the only place, where this address is supplied.
widget->setPlaceholderText(QObject::tr("Enter a VERGE address (e.g. %1)").arg(
QString::fromStdString(DummyAddress(Params()))));
if(unsEnabled()){
widget->setPlaceholderText(QObject::tr("Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)").arg(
QString::fromStdString(DummyAddress(Params()))));
}else{
widget->setPlaceholderText(QObject::tr("Enter a VERGE address(e.g. %1)").arg(
QString::fromStdString(DummyAddress(Params()))));
}
#endif
widget->setValidator(new VERGEAddressEntryValidator(parent));
widget->setCheckValidator(new VERGEAddressCheckValidator(parent));
Expand Down
6 changes: 5 additions & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ namespace GUIUtil
// Return a monospace font
QFont fixedPitchFont();

//Unstoppable Domains
QString resolveUnsDomain(QString domain);
bool unsEnabled();

// Set up widget for address
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent);

// Parse "verge:" URI into recipient object, return true on successful parsing
bool parseVERGEURI(const QUrl &uri, SendCoinsRecipient *out);
bool parseVERGEURI(QString uri, SendCoinsRecipient *out);
bool parseVERGEURI(QString uri, SendCoinsRecipient *out);
QString formatVERGEURI(const SendCoinsRecipient &info);

// Returns true if given address+amount meets "dust" definition
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_af.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,11 @@
<translation>Bedrag</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Voer in 'n VERGE adres (bv. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Voer in 'n VERGE adres (bv. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,11 @@
<translation>Сума</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Въведете Биткойн адрес (например: %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Въведете Биткойн адрес (например: %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,11 @@
<translation>Import</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Introduïu una adreça de VERGE (p. ex. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Introduïu una adreça de VERGE (p. ex. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,11 @@
<translation>Import</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Introduïu una adreça de VERGE (p. ex. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Introduïu una adreça de VERGE (p. ex. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_ca_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,11 @@
<translation>Import</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Introduïu una adreça de VERGE (p. ex. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Introduïu una adreça de VERGE (p. ex. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,11 @@
<translation>Částka</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Zadej vergeovou adresu (např. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Zadej vergeovou adresu (např. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,11 @@
<translation>Beløb</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Indtast en verge-adresse (fx %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Indtast en verge-adresse (fx %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,11 @@
<translation>Betrag</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>verge-Adresse eingeben (z.B. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>verge-Adresse eingeben (z.B. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_el_GR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,11 @@
<translation>Ποσό</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Εισάγετε μια διεύθυνση VERGE (π.χ. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Εισάγετε μια διεύθυνση VERGE (π.χ. %1)</translation>
</message>
<message>
Expand Down
7 changes: 6 additions & 1 deletion src/qt/locale/verge_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1836,9 +1836,14 @@
</message>
<message>
<location filename="../guiutil.cpp" line="+130"/>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../guiutil.cpp" line="+130"/>
<source>Enter a VERGE address(e.g. %1)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+760"/>
<source>%1 d</source>
Expand Down
8 changes: 6 additions & 2 deletions src/qt/locale/verge_en_GB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,8 +1444,12 @@
<translation>Amount</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<translation>Enter a VERGE address (e.g. %1)</translation>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Enter a VERGE address(e.g. %1)</translation>
</message>
<message>
<source>%1 d</source>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,11 @@
<translation>Cantidad</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Introducir una dirección VERGE (p. ej. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Introducir una dirección VERGE (p. ej. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,11 @@
<translation>Cantidad</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Introducir una dirección VERGE (p. ej. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Introducir una dirección VERGE (p. ej. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,11 @@
<translation>مبلغ</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>یک آدرس بیت‌کوین وارد کنید (مثلاً %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>یک آدرس بیت‌کوین وارد کنید (مثلاً %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_fi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,11 @@
<translation>Määrä</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Syötä VERGE-osoite (esim. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Syötä VERGE-osoite (esim. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,11 @@
<translation>Montant</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Saisir une adresse VERGE (p. ex. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Saisir une adresse VERGE (p. ex. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_fr_FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,11 @@
<translation>Montant</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Entrer une adresse VERGE (e.g. %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Entrer une adresse VERGE (e.g. %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_he.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,11 @@
<translation>כמות</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>נא להזין כתובת ביטקוין (למשל: %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>נא להזין כתובת ביטקוין (למשל: %1)</translation>
</message>
<message>
Expand Down
6 changes: 5 additions & 1 deletion src/qt/locale/verge_hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,11 @@ Kérem a kulcsmondatban használjon &lt;b&gt; tíz vagy több véletlenszerű ka
<translation>Összeg</translation>
</message>
<message>
<source>Enter a VERGE address (e.g. %1)</source>
<source>Enter a VERGE address or Web3 Domain(e.g. %1 or sandy.nft)</source>
<translation>Ad meg egy VERGE címet (pl: %1)</translation>
</message>
<message>
<source>Enter a VERGE address(e.g. %1)</source>
<translation>Ad meg egy VERGE címet (pl: %1)</translation>
</message>
<message>
Expand Down
Loading

0 comments on commit 92f671f

Please sign in to comment.