hsd icon indicating copy to clipboard operation
hsd copied to clipboard

Additional Node HTTP Endpoints

Open tynes opened this issue 6 years ago • 4 comments

Overview

edited 5/30/19

A high priority TODO is migrating the RPCs to HTTP to allow for more flexibility. This should be fairly straight forward to accomplish since most of the code has already been written and just needs to be adapted to using the HTTP resources instead of the RPC resources.

Proposal

Additional Endpoints to be added:

RPC HTTP
getnameinfo GET /name/:name
getnamebyhash GET /name/hash/:hash
getnameresource GET /resource/name/:name
getnameresourcebyhash GET /resource/hash/:hash
getnameproof GET /proof/name/:name
gtetnameproofbyhash GET /proof/hash/:hash
grindname GET /grind?size=int

sendrawclaim already is implemented as POST /claim

This work has been started here:

  • https://github.com/tynes/hsd/blob/node-http/lib/node/http.js
  • https://github.com/handshake-org/hsd/pull/168

Previous Issues mentioning this include https://github.com/handshake-org/hsd/issues/12, https://github.com/handshake-org/hsd/issues/126

tynes avatar Apr 10 '19 01:04 tynes

Quick Question!

This guy: getnamebyhash has route shaped like GET /name/hash/:hash

Top level resource being "name" feels right to me.

However, the other calls have a different shape!

  1. getnameinfo
    • GET /info/name/:name
    • "Info" top level
  2. getnameresource
    • GET /resource/name/:name
    • "Resource" top level
  3. getnameproof
    • GET /proof/name/:name
    • "Proof" top level

Would you be opposed to something more rest-ish? Like:

  1. getnameinfo
    • GET /name/info/:name
    • "Name" top level
    • Route param :name end of the path.
  2. getnameresource
    • GET /name/resource/:name
    • "Name" top level
    • Route param :name end of the path.
  3. getnameproof
    • GET /name/proof/:name
    • "Name" top level
    • Route param :name end of the path.
  4. grindname
    • GET /name/grind?size=int
    • "Name" top level
  5. getnamebyhash
    • GET /name/hash/:hash
    • "Name" top level
    • Route param :hash end of the path.
    • Hash is hex encoded.

wi-ski avatar May 04 '19 19:05 wi-ski

@wi-ski Thanks for your suggestions.

What do you think of the edits made to the original post? The API is being structured this way to keep it similar to the rest of the codebase.

See this endpoint:

https://github.com/handshake-org/hsd/blob/master/lib/node/http.js#L159

// UTXO by address
GET /coin/address/:address

Since a coin is synonymous with a UTXO, the resource being fetched is the top level resource and then how its being fetched is the next level resource. We would like to try to maintain consistency within the codebase.

tynes avatar May 31 '19 16:05 tynes

Yesss - gotcha. Makes sense, ill make those changes to https://github.com/handshake-org/hsd/pull/168

wi-ski avatar Jun 30 '19 22:06 wi-ski

Note: gtetnameproofbyhash => gettnameproofbyhash (spelling)

wi-ski avatar Jun 30 '19 23:06 wi-ski