MCPcopy Create free account
hub / github.com/ElementsProject/elements / is_valid

Function is_valid

contrib/testgen/gen_key_io_test_vectors.py:113–126  ·  view source on GitHub ↗

Check vector v for validity

(v)

Source from the content-addressed store, hash-verified

111]
112
113def is_valid(v):
114 '''Check vector v for validity'''
115 if len(set(v) - set(b58chars)) > 0:
116 return is_valid_bech32(v)
117 result = b58decode_chk(v)
118 if result is None:
119 return is_valid_bech32(v)
120 for template in templates:
121 prefix = bytearray(template[0])
122 suffix = bytearray(template[2])
123 if result.startswith(prefix) and result.endswith(suffix):
124 if (len(result) - len(prefix) - len(suffix)) == template[1]:
125 return True
126 return is_valid_bech32(v)
127
128def is_valid_bech32(v):
129 '''Check vector v for bech32 validity'''

Callers 3

gen_valid_vectorsFunction · 0.85
gen_invalid_vectorsFunction · 0.85
CloseMethod · 0.85

Calls 2

b58decode_chkFunction · 0.90
is_valid_bech32Function · 0.85

Tested by

no test coverage detected