fibercrypto / fibercrypto/skyxcommons
Valid address API endpoint
- Dominant language
- No language data
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Implement [GET] /api/addresses/{address}/validity
Should check and return address validity.
Should check and return wallet address validity
Response:
```js
{
// Flag, which indicates that the address is valid
“isValid”: boolean
}
```
Python implementation
```py
def isValidAddress(address):
"""
Validate Skycoin address.
"""
addressObj = skycoin.cipher__Address()
error = skycoin.SKY_cipher_DecodeBase58Address(
address.encode(), addressObj)
return error == 0
@api.route('/addresses//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)})
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.