Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to validate addresses via the API. #2180

Closed
KtorZ opened this issue Sep 24, 2020 · 2 comments
Closed

Provide a way to validate addresses via the API. #2180

KtorZ opened this issue Sep 24, 2020 · 2 comments
Assignees

Comments

@KtorZ
Copy link
Member

KtorZ commented Sep 24, 2020

Context

Exchanges prefer validating data before submission (even though the API will validate things upon submission). There's no easy to simply validate arbitrary string an know whether they are valid addresses or not. That feature exists in cardano-address but only available via command-line.

Decision

Make the API able to inspect addresses.

Acceptance Criteria

  1. There's a new API endpoint to validate addresses
  2. The validation is implemented using cardano-address 'inspect' method.

Development

QA

@KtorZ KtorZ self-assigned this Sep 24, 2020
iohk-bors bot added a commit that referenced this issue Sep 25, 2020
2138: Save intermediate state when restoring the Byron chain in the stake pools worker r=hasufell a=hasufell

This completely skips byron era for mainnet when syncing stake pools.

I extracted the first shelley block by looking at a fully synced stake pool DB and selecting the lowest `block_height` from the `pool_production` table.

For non-mainnet it will record the last byron block of a chunk from the node into the `byron_headers` table and read it out during `readPoolProductionCursor` if there are no stake pools and otherwise ignore it.

Remarks:

- the "genesis shelley header" is hardcoded, because the node currently does not have an endpoint to get this

2184: Allow address inspection via the API r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#2180 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- 2daae7e
  📍 **implement new stateless endpoint for inspecting addresses**
    It takes any arbitrary string as input and tries to deserialize it into some address information if possible, otherwise it fails with a proper error.

- 76d13ba
  📍 **add unit and integration tests for the new 'inspectAddress' function & endpoint**

# Comments

<!-- Additional comments or screenshots to attach if any -->

![Screenshot from 2020-09-24 18-52-44](https://user-images.githubusercontent.com/5680256/94175596-2b686480-fe97-11ea-8325-66fa41c5577e.png)


<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Julian Ospald <[email protected]>
Co-authored-by: KtorZ <[email protected]>
iohk-bors bot added a commit that referenced this issue Sep 25, 2020
2184: Allow address inspection via the API r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#2180 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- 2daae7e
  📍 **implement new stateless endpoint for inspecting addresses**
    It takes any arbitrary string as input and tries to deserialize it into some address information if possible, otherwise it fails with a proper error.

- 76d13ba
  📍 **add unit and integration tests for the new 'inspectAddress' function & endpoint**

# Comments

<!-- Additional comments or screenshots to attach if any -->

![Screenshot from 2020-09-24 18-52-44](https://user-images.githubusercontent.com/5680256/94175596-2b686480-fe97-11ea-8325-66fa41c5577e.png)


<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <[email protected]>
@piotr-iohk
Copy link
Contributor

Lgtm. However I wonder if there is a point of showing network_tag: null in case of Mainnet/Staging Byron random and Byron icarus addresses. Perhaps better not to show anything?

curl http://localhost:8092/v2/addresses/DdzFFzCqrhtBfCivoJApi19mydJT1ipghz72mqPPzmZZ1ULYxronKfB4HCYfXGoxEsvgsBKuTeF7ZAi2VytAA78sBT1EpXLk4CgoJQTK 
{
  "stake_reference": "none",
  "address_style": "Byron",
  "address_root": "f3ab6fc64a78c8b4873002c578dee136c062d340358b973a4be6dfbb",
  "derivation_path": "581cc17572ba517c7d2b68b598478ac15aedbb49a0bdfc960d33fb56d0fe",
  "network_tag": null <--------------------
}
curl http://localhost:8092/v2/addresses/Ae2tdPwUPEZCXHQ1b2RjVryp63eVAehJN4HPPYGH1fuddixeQRkzERCbEB6 

{
  "stake_reference": "none",
  "address_style": "Icarus",
  "address_root": "9d8157c18118e753486e3fc39754b2772aa187e5241a5e1a6d2f5b0f",
  "network_tag": null <--------------------
}

@KtorZ
Copy link
Member Author

KtorZ commented Sep 29, 2020

It'd rather be explicit about that one and show it. It's not that the information is not available (in which case not showing the key would make more sense), it's that, we know that there's no network tag. So that's a bit different and a null value is better suited for this IMO.

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

No branches or pull requests

2 participants