1

I am using python-sdk to perform stellar operations. Now I need to validate a stellar address. I know that the JS sdk has got a function StrKey.isValidEd25519PublicKey(address); however I cannot find the same in Python SDK.

Any idea, how I can do this?

3

check this out: https://github.com/StellarCN/py-stellar-base/blob/6329db3658c9b646a69c567019d95b41b7363eee/stellar_base/utils.py#L251

def is_valid_address(address):
try:
    return decode_check('account', address)
except (DecodeError, TypeError):
    raise StellarAddressInvalidError('Invalid Stellar Address: {}'.format(address))
| improve this answer | |
0

Thats how i have done it:

from stellar_sdk.exceptions import Ed25519PublicKeyInvalidError

def check_stellar_address(address):
    try:
        Account(account_id=address, sequence=0)
        return True

    except Ed25519PublicKeyInvalidError:
        return False
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.