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

Valid address API endpoint #3

Open
olemis opened this issue Feb 21, 2019 · 0 comments
Open

Valid address API endpoint #3

olemis opened this issue Feb 21, 2019 · 0 comments
Assignees

Comments

@olemis
Copy link
Contributor

olemis commented Feb 21, 2019

Implement [GET] /api/addresses/{address}/validity

Should check and return address validity.

Should check and return wallet address validity

Response:

{
 // Flag, which indicates that the address is valid
“isValid”: boolean
}

Python implementation

def isValidAddress(address):
    """
    Validate Skycoin address.
    """
    addressObj = skycoin.cipher__Address()
    error = skycoin.SKY_cipher_DecodeBase58Address(
            address.encode(), addressObj)
    return error == 0


@api.route('/addresses/<string:address>/validity', methods=['GET'])
def address_valid(address):
    """
    Check if an address is valid
    A SKY address uses an alphanumeric base58 encoding, without 0, O, I or l.
    Important note: the last four bytes are a checksum check. They are the
    first four bytes of a double SHA-256 digest of the previous 21 bytes
    Read the first twenty-one bytes, compute the checksum, and
    check that it corresponds to the last four bytes.
    """
return jsonify({"isValid": isValidAddress(address)})
AntiD2ta pushed a commit to uhsimelo/skyxcommons that referenced this issue Feb 27, 2019
…- Add spec for endpoints /api/addresses/{address}/validity /api/transactions/history/to/{address}/observation /api/transactions/history/from/{address}/observation /api/transactions/history/from/{address}?take=integer&[afterHash=string]
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

3 participants