Skip to content

Overhauled the Buy Names Page with the Electrum-NMC version#558

Open
junekomeiji wants to merge 1 commit intonamecoin:masterfrom
junekomeiji:domainforms
Open

Overhauled the Buy Names Page with the Electrum-NMC version#558
junekomeiji wants to merge 1 commit intonamecoin:masterfrom
junekomeiji:domainforms

Conversation

@junekomeiji
Copy link

@junekomeiji junekomeiji commented Nov 17, 2024

Overhauled the Buy Names Page with the Electrum-NMC version and added error boxes for invalid domain names.

<resources>
<include location="../bitcoin.qrc"/>
</resources>
<resources/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an Electrum-ism, we already have a (non-empty) resources element (above).

@JeremyRand
Copy link
Member

OK so initial reaction: the XML form changes here are really hard to review because there's too much happening in a single commit. For example, the text Use &lt;strong&gt;d/&lt;/strong&gt; prefix for domain names. shows up in both the old and new XML forms, but the diff is complicated enough that Git can't tell that those two lines correspond.

I think one way to improve this would be to split the XML form diff into two commits: one that exclusively tweaks whitespace on existing lines, and one that adds/removes lines. This should make it a lot easier for Git to tell which lines correspond in the diff.

@junekomeiji junekomeiji force-pushed the domainforms branch 2 times, most recently from 8fb3d7f to 7c1b67d Compare May 26, 2025 18:31
@junekomeiji
Copy link
Author

@domob1812 Updated the codebase.

@junekomeiji junekomeiji changed the title (WIP) Overhauled the Buy Names Page with the Electrum-NMC version Overhauled the Buy Names Page with the Electrum-NMC version May 31, 2025
@domob1812
Copy link

I'd like @JeremyRand to review this, as he is the one who did the Qt code and I'm not really proficient with it.

return v.write(0,0);
}

//remind me to write test cases for them
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this comment is no longer relevant?

Comment on lines 16 to 18
#include <string>
#include <algorithm>
#include <exception>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are we using from these three headers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(To be clear, I'm not saying they are definitely superfluous, I'm just asking for info.)

return NameTableModel::asciiToHex(name);
}

void BuyNamesPage::availableError()
Copy link
Member

@JeremyRand JeremyRand Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this function has the same name as a variable inside it. The function name is also a bit confusing (it could be interpreted as something that you call when there's an error).

Can we rename this function to refreshAvailableError or something similar?

Comment on lines 149 to 150


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we have two blank lines here rather than one?

}
else
{
ui->statusLabel->setText(tr("%1 is not a valid Namecoin domain!").arg(name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth putting %1 inside double-quotes so that it's a bit less ambiguous. Also can we make the text a bit more helpful? Is this just checking for the .bit suffix? If so, maybe say in the error text that the .bit suffix is expected?

@JeremyRand
Copy link
Member

Based on code review of 7c1b67d, only a few small issues (see review above). Also please change the commit message to something more descriptive.

I'll do a final round of testing in the next 24 hours but I'm not expecting to see any major problems there.

@junekomeiji
Copy link
Author

Should I fix the issues highlighted above now, or is it better if I wait for your final checks on the PR?

@JeremyRand
Copy link
Member

Should I fix the issues highlighted above now, or is it better if I wait for your final checks on the PR?

@junekomeiji Feel free to fix them now.

{
return QString::fromStdString(ASCIIFromDomain(name.toStdString()));
}
else return QString("");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else isn't needed here, since the then clause of this if statement will always return before we reach this point. Please remove else and add a blank line between the if statement and the return.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change here isn't correct -- return is still needed, just not else.

{
return QString::fromStdString(DescFromName(DecodeName(name.toStdString(), NameEncoding::ASCII), NameNamespace::Domain));
}
else return QString("");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change here isn't correct -- return is still needed, just not else.


const QString availableError = name_available(name);
QString BuyNamesPage::DomainToASCII(const QString &name){

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally think this blank line can be removed, but if it's not removed, at least remove the spaces from this line.

}

bool
IsPurportedNamecoinDomain (const std::string& domain){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs fix?

}

std::string
ASCIIFromDomain(const std::string& domain){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs fix?

return;

const QString availableError = name_available(name);
QString BuyNamesPage::DomainToASCII(const QString &name){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.

}


QString BuyNamesPage::ASCIIToDomain(const QString &name){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.

}


QString BuyNamesPage::HexToASCII(const QString &name){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.

}


QString BuyNamesPage::ASCIIToHex(const QString &name){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.


}

void BuyNamesPage::onDomainNameEdited(const QString &name){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a space between the close-parenthesis and the open-brace.

}
catch(InvalidNameString &e)
{
ui->statusLabel->setText(tr("Not a valid entry!"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe say hex entry instead of entry for consistency with the ASCII codepath?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you missed this one?

if (!walletModel)
return;

QString input, name;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think input is unused here?

Since it's unused, and name is the only remaining variable being declared here, I think the next line (initializing name) can be combined with this line.

}

if (availableError == "")
void BuyNamesPage::refreshAvailableError()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the Developer Notes docs, please name this method via UpperCamelCase.

@JeremyRand
Copy link
Member

Quite a few of the added lines have trailing whitespace. If you run git diff fe2ff395aa25387f1acfefd1722b3e10f199d21e..b035e5ca2b382e46a946a55e1806e02e3bb0baf4, it'll show a diff of your PR; trailing whitespace in the added lines will be highlighted with a red background, which should make it easy for you to find and fix them.

@JeremyRand
Copy link
Member

Tested b035e5c, all functionality works fine for me. Just some small code style issues (see review above).

@junekomeiji
Copy link
Author

Responded to the review above.

if (!walletModel)
return;

try{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please either put the brace on a separate line, or add a space between try and the brace.

@JeremyRand
Copy link
Member

Quite a few of the added lines have trailing whitespace. If you run git diff fe2ff395aa25387f1acfefd1722b3e10f199d21e..b035e5ca2b382e46a946a55e1806e02e3bb0baf4, it'll show a diff of your PR; trailing whitespace in the added lines will be highlighted with a red background, which should make it easy for you to find and fix them.

There's still one in buynamespage.h

@junekomeiji junekomeiji force-pushed the domainforms branch 2 times, most recently from 8e50de5 to c73cc2e Compare June 9, 2025 17:18
@JeremyRand
Copy link
Member

ACK 558bad4. Code review looks OK to me, unit tests pass, and manual testing of the GUI doesn't show any problems.

@JeremyRand
Copy link
Member

@domob1812 Feel free to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments