INNER CODE UNIT · Python
get_encoding_from_witness
demining/CryptoDeepTools · 17BTCRecoverCryptoGuide/lib/bitcoinlib/main.py:86
def get_encoding_from_witness(witness_type=None):
"""
Derive address encoding (base58 or bech32) from transaction witness type.
Returns 'base58' for legacy and p2sh-segwit witness type and 'bech32' for segwit
:param witness_type: Witness type: legacy, p2sh-segwit or segwit
:type witness_type: str
:return str:
"""
if witness_type == 'segwit':
return 'bech32'
elif witness_type in [None, 'legacy', 'p2sh-segwit']:
return 'base58'
else:
raise ValueError("Unknown witness type %s" % witness_type)