namecoin / namecoin-core

Namecoin full node + wallet based on the current Bitcoin Core codebase.
https://www.namecoin.org/
MIT License
454 stars 146 forks source link

RPC for certain users to generate certain data according to standards #474

Open yanmaani opened 2 years ago

yanmaani commented 2 years ago

In #365, a RPC interface to validate certain information was proposed. This would take encoded data and return information about its relation to the specification.

Recent discussion regarding PR #436 and generation of names according to delegation seem to create the need for at least two additional RPCs:

  1. Take Namecoin data and parse it to obtain certain information (possibly a duplicate of #365)
  2. Take non-Namecoin data (e.g. ["példány", "rootdomain"], ["delegated", "delegatorvalue"]) and encode this according to Namecoin specs (e.g. d/xn--pldny-zqa7c, {"import":"dd/delegated"})

In the review of #436, I said:

I think I'd prefer to have two RPCs for manipulating names (parse name, serialize name), and two RPCs for manipulating values (decode value, encode value). Then you could factor out "find name by appending random digits" into a RPC call, and then just put the parts together in the GUI.

So these two RPCs could be four, if you'd split it like "name to namecoin", "name from namecoin", "value to namecoin", "value from namecoin". I still think that would be slightly preferable.

@JeremyRand, I think you may have strong feelings on this.

domob1812 commented 2 years ago

Sounds good to me, and as long as the code is separated into its own set of RPC methods, I don't really mind adding this. Regarding "name to/from namecoin" specifically, though, isn't that just straight-forward IDN encoding? Is that something that the RPC interface needs to expose? I think users should just use their IDN library of choice or the idn CLI instead of expecting Namecoin to do it for them.

yanmaani commented 2 years ago

That's a fair point, but if the feature is to be in Namecoin (see discussion in #385), I think it's strongly preferable that it be its own RPC. Also, I think Namecoin might have special considerations with regard to homoglyph attacks, because it's not nationally bound. That might cause for it to have special rules on encoding, e.g. encoding "россия.bit" as "pocc" (Latin letters) + "ия" (Cyrillic), or giving some kind of warning on mixed stuff like "nаmесоіп.bit". There's a whole literature on best practices out there I'm pretty sure.

Anyway, I think the idea is to use it for the GUI while registering names, which broadly seems like a good idea, and since you can't really put complexity in the GUI code because it's untestable, you have to put it in its own RPC if you want to test it. So you'll need at least some of this functionality for that.