コード例 #1
0
ファイル: configure.py プロジェクト: AdamISZ/joinmarket_core
def validate_address(addr):
    try:
        ver = btc.get_version_byte(addr)
    except AssertionError:
        return False, 'Checksum wrong. Typo in address?'
    if ver != get_p2pk_vbyte() and ver != get_p2sh_vbyte():
        return False, 'Wrong address version. Testnet/mainnet confused?'
    if len(btc.b58check_to_bin(addr)) != 20:
        return False, "Address has correct checksum but wrong length."
    return True, 'address validated'
コード例 #2
0
def validate_address(addr):
    try:
        ver = btc.get_version_byte(addr)
    except AssertionError:
        return False, 'Checksum wrong. Typo in address?'
    if ver != get_p2pk_vbyte() and ver != get_p2sh_vbyte():
        return False, 'Wrong address version. Testnet/mainnet confused?'
    if len(btc.b58check_to_bin(addr)) != 20:
        return False, "Address has correct checksum but wrong length."
    return True, 'address validated'
コード例 #3
0
def validate_address(addr):
    try:
        assert len(addr) > 2
        if addr[:2].lower() in ['bc', 'tb']:
            #Enforce testnet/mainnet per config
            if get_network() == "testnet":
                hrpreq = 'tb'
            else:
                hrpreq = 'bc'
            if btc.bech32addr_decode(hrpreq, addr)[1]:
                return True, 'address validated'
            return False, 'Invalid bech32 address'
        #Not bech32; assume b58 from here
        ver = btc.get_version_byte(addr)
    except AssertionError:
        return False, 'Checksum wrong. Typo in address?'
    except Exception:
        return False, "Invalid bitcoin address"
    if ver != get_p2pk_vbyte() and ver != get_p2sh_vbyte():
        return False, 'Wrong address version. Testnet/mainnet confused?'
    if len(btc.b58check_to_bin(addr)) != 20:
        return False, "Address has correct checksum but wrong length."
    return True, 'address validated'