Namecoin QT GUI Questions

brandonrobertz
Posts: 13
Joined: Thu Jun 25, 2015 8:02 am
os: linux
Contact:

Namecoin QT GUI Questions

Post by brandonrobertz »

I've been porting the old names management qt stuff from the old namecoin code to namecoin core and I came across an architecture decision I needed guidance on:

The old namecoin code replicated most of the name_* functionality in the QT section of the codebase. In other words, when you ran name_new, you hit different code for checks, bounds, sanity testing, etc, if you did it through the UI vs. the CLI.

Question: Should I be using code from (wallet/)rpcnames and converting to and from univalue to keep the code centralized? If not, what's a good alternative path so that when certain checks change in name_update, for example, that the ui code doesn't also need to significantly change?

cassini
Posts: 336
Joined: Sun May 26, 2013 6:36 pm

Re: Namecoin QT GUI Questions

Post by cassini »

One strategy that immediately springs to mind is to make use of the RPC architecture of Namecoin Core. In other words, you'd do exactly what nameGUI does, but rather than it being an external tool you'd create a much faster integral part of Core. Much faster because it doesn't need the networking bottleneck nameGUI has to deal with.

This way you get a clear standardized internal JSON interface, i.e. maximum isolation between the core functionality and the GUI, and at the same time you create inherently dry code.

brandonrobertz
Posts: 13
Joined: Thu Jun 25, 2015 8:02 am
os: linux
Contact:

Re: Namecoin QT GUI Questions

Post by brandonrobertz »

cassini wrote:One strategy that immediately springs to mind is to make use of the RPC architecture of Namecoin Core. In other words, you'd do exactly what nameGUI does, but rather than it being an external tool you'd create a much faster integral part of Core.
That's that the UniValue stuff is (https://github.com/jgarzik/univalue), C++ JSON library used internally. Unfortunately there's basically no documentation, but it's looking like that's the most sensible way to do this GUI. I want to make sure there aren't some gotchas I haven't considered that explain why the old client re-implemented a lot of the code.

cassini
Posts: 336
Joined: Sun May 26, 2013 6:36 pm

Re: Namecoin QT GUI Questions

Post by cassini »

brandonrobertz wrote:That's that the UniValue stuff is (https://github.com/jgarzik/univalue), C++ JSON library used internally. Unfortunately there's basically no documentation,
The only documentation you need in this case is the Bitcoin JSON API docs. You should be familiar with namecoin-cli and curl, obviously. If not, start with practising the use of curl commands containing getinfo, then settxfee, and then get your hands on the usual suspects such as curl ... name_new, name_update a.s.o.

Eventually your GUI modules simply compose JSON strings by concatenating variables and JSON elements in a way similar to
https://github.com/phelix/nameGUI/blob/ ... #L149-L177
You can skip the authentication part, of course, if you choose the optimal entry point. That single entry point could be something like JSONRequest::parse.

That said, I better leave it to domob or anyone else familiar with Boost, C++ and the intestines of Namecoin Core to make detailed recommendations.

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: Namecoin QT GUI Questions

Post by domob »

I also agree that you should be reusing the existing code rather than duplicating it. Using the RPC interface internally sounds good, as does calling the functions directly with values wrapped in UniValue. You can take a look at UniValue's header file, it should be straight-forward to use.

Also, note that the debug console already allows to query the RPC interface. Maybe take a look at how this works internally (I don't know).
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

brandonrobertz
Posts: 13
Joined: Thu Jun 25, 2015 8:02 am
os: linux
Contact:

Re: Namecoin QT GUI Questions

Post by brandonrobertz »

Got a good handle on UniValue now and that's the route I'm going. Thanks for the input everyone

biolizard89
Posts: 2001
Joined: Tue Jun 05, 2012 6:25 am
os: linux

Re: Namecoin QT GUI Questions

Post by biolizard89 »

I already discussed this with Brandon on IRC a couple days ago, but for the benefit of people not on IRC I'll post here too. We should be very careful to make sure that whatever architecture we end up using for the name management GUI is interoperable with the rest of the Bitcoin-Qt GUI feature set. The main example I'm thinking of is the Coin Control GUI. Users should be able to use the Coin Control GUI to choose which currency inputs are used for a name transaction, and it should preferably reuse the Bitcoin code for this wherever feasible.

As of a couple days ago, Brandon thought this was probably doable but needed to do some more checking. Coin Control is lower priority IMO than getting the 0.3.80 equivalent into Core, but paying attention to this early will probably lead to cleaner code in the end. And we all know what happened when the 0.3.x code got too messy a few years ago....
Jeremy Rand, Lead Namecoin Application Engineer
NameID: id/jeremy
DyName: Dynamic DNS update client for .bit domains.

Donations: BTC 1EcUWRa9H6ZuWPkF3BDj6k4k1vCgv41ab8 ; NMC NFqbaS7ReiQ9MBmsowwcDSmp4iDznjmEh5

brandonrobertz
Posts: 13
Joined: Thu Jun 25, 2015 8:02 am
os: linux
Contact:

Re: Namecoin QT GUI Questions

Post by brandonrobertz »

So, the GUI has all the core functionality, now (name_new, auto name_firstupdate, name_update). Now I'm tackling the smaller pieces with rendering the data.

I have a need to re-implement the GetNameOfTx function from namecoin legacy for rendering updates to name transactions as they are emitted from the core signals.

Does anyone know of a good path forward to getting the name(s) from only a txid? I'll also need to do some tests to make sure the tx contains a name_op.

UPDATE: I got it figured out for now. I'm iterating over CTransaction->vout then looking at each script for isNameScript. Then I'm extracting the name from there and causing a ui refresh based on that.

domob
Posts: 1129
Joined: Mon Jun 24, 2013 11:27 am
Contact:

Re: Namecoin QT GUI Questions

Post by domob »

brandonrobertz wrote:Does anyone know of a good path forward to getting the name(s) from only a txid? I'll also need to do some tests to make sure the tx contains a name_op.

UPDATE: I got it figured out for now. I'm iterating over CTransaction->vout then looking at each script for isNameScript. Then I'm extracting the name from there and causing a ui refresh based on that.
Exactly, that's what I would have suggested. ;)
BTC: 1domobKsPZ5cWk2kXssD8p8ES1qffGUCm | NMC: NCdomobcmcmVdxC5yxMitojQ4tvAtv99pY
BM-GtQnWM3vcdorfqpKXsmfHQ4rVYPG5pKS
Use your Namecoin identity as OpenID: https://nameid.org/

brandonrobertz
Posts: 13
Joined: Thu Jun 25, 2015 8:02 am
os: linux
Contact:

Re: Namecoin QT GUI Questions

Post by brandonrobertz »

Okay, so I've ported the old "manage names" page into Namecoin Core. I still need to go through and ensure I have a minimalistic patch against Namecoin Core (whitespace mostly).

One problem remains:

There are several locations, mostly in walletdb.cpp, where I need to do some wallet manipulations *if* we have the GUI enabled. An example is wallet/wallet.cpp:ReadKeyValue near line 600. I need to add a check for a "pending_firstupdate" strType and then restore it, so that it can be pushed out to the network at the appropriate time.

Question:

How to I include this if and only if the user is building the GUI? It looks like the old codebase used a GUI ifdef all over, which no longer exists.

Post Reply