stacks-core icon indicating copy to clipboard operation
stacks-core copied to clipboard

Add additional GET RPC endpoints

Open wileyj opened this issue 1 year ago • 1 comments

Problem: the stacks blockchain RPC interface for GET requests is limited compared the data exposed in bitcoin/etc and the rich data in Hiro's API.

With recent changes to the HTTP interface (https://github.com/stacks-network/stacks-core/tree/master/stackslib/src/net/api), it should be much easier to add more RPC endpoints to expose some generic data. Initially, i'm thinking something like:

  • block data
  • tx data
  • address info

some comparable bitcoin-cli rpc commands: getblockhash getblock getrawtransaction gettxout

for the data exposed, i don't think it should be a requirement to be as detailed as the Hiro API - but i think should be enough to understand what is in a block, or what a tx is doing (as well as retrieving the block hash by a block height).

references: bitcoin RPC:

  • https://developer.bitcoin.org/reference/rpc/getblockhash.html
  • https://developer.bitcoin.org/reference/rpc/getblock.html
  • https://developer.bitcoin.org/reference/rpc/getaddressinfo.html
  • https://developer.bitcoin.org/reference/rpc/getrawtransaction.html
  • https://developer.bitcoin.org/reference/rpc/gettxout.html

Hiro API:

  • https://hirosystems.github.io/stacks-blockchain-api//#tag/Blocks/operation/get_block_by_hash
  • https://hirosystems.github.io/stacks-blockchain-api//#tag/Blocks/operation/get_block_by_height
  • https://hirosystems.github.io/stacks-blockchain-api//#tag/Blocks/operation/get_block_by_burn_block_hash
  • https://hirosystems.github.io/stacks-blockchain-api//#tag/Transactions/operation/get_transaction_by_id
  • https://hirosystems.github.io/stacks-blockchain-api//#tag/Transactions/operation/get_raw_transaction_by_id

wileyj avatar Feb 08 '24 21:02 wileyj

  • We have getblock via GET /v2/blocks/{index-block-hash}.
  • We have gettxout via GET /v2/accounts/{:address}

We can add an endpoint to get a sortition for a particular block height, which would be the equivalent of getblockhash.

We don't have our equivalent of txindex turned on by default, so getrawtransaction would be disabled by default. However, we could add this endpoint to serve whatever indexed transactions we have if the user enables txindex.

jcnelson avatar Feb 08 '24 22:02 jcnelson

@saralab Do you think this would be a good ticket for me to work on during my free cycles/after my current tickets are merged? If so, perhaps it could be further scoped with the help of @kantai and @jferrant to determine what would be most useful for Nakamoto.

8marz8 avatar Mar 05 '24 18:03 8marz8