{"id":"segwit-address-encode","version":"1.0.0","description":"Encode a witness program as a native segwit address using Bech32 for v0 and Bech32m for v1-v16.","supported_operations":["encode native segwit address","witness program to bech32 address","witness program to bech32m address","create version 0 segwit address","create witness version 1 address","build segwit address from program hex","encode hrp and witness program"],"unsupported_operations":["decode a segwit address back into a program","hash a public key into a witness program","choose bc or tb from a network name","correct a mistyped address"],"semantics":["hrp must already be lowercase US-ASCII (code points 33..126 excluding 65..90). An uppercase hrp such as BC is invalid_input with details.reason invalid_hrp and is not case-folded.","witness version 0 is encoded with Bech32 (checksum constant 1). Versions 1 through 16 are encoded with Bech32m (checksum constant 0x2bc830a3). The output address is lowercase.","The witness program is 2 to 40 bytes. Version 0 additionally requires exactly 20 or 32 bytes. Any other byte string is rejected. The bytes are not checked as a hash or a public key.","Length limits are applied to the raw strings before hex parsing or checksum generation. hrp longer than 83 characters, or program_hex longer than 80 characters, is limit_exceeded.","When hrp and program_hex are inside those limits but the Bech32 string would exceed 90 characters, the result is limit_exceeded for max_address_chars. The length is hrp length + 1 separator + 1 version character + ceil(program_bytes * 8 / 5) + 6 checksum characters.","program_hex is lowercase even-length hex with no prefix and no separators. The script pubkey is OP_0 or OP_1..OP_16 followed by a single-byte push of the program (BIP 141).","Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity."],"limits":{"max_hrp_chars":83,"max_program_hex_chars":80,"max_program_bytes":40,"max_address_chars":90},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["hrp","witness_version","program_hex"],"properties":{"hrp":{"type":"string","minLength":1,"maxLength":83,"pattern":"^[\\x21-\\x40\\x5b-\\x7e]+$"},"witness_version":{"type":"integer","minimum":0,"maximum":16},"program_hex":{"type":"string","minLength":4,"maxLength":80,"pattern":"^(?:[0-9a-f]{2}){2,40}$"}}},"output_schema":{"type":"object","additionalProperties":false,"required":["address","encoding","script_pubkey_hex"],"properties":{"address":{"type":"string","minLength":13,"maxLength":90,"pattern":"^[\\x21-\\x40\\x5b-\\x7e]{1,83}1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]+$"},"encoding":{"type":"string","enum":["bech32","bech32m"]},"script_pubkey_hex":{"type":"string","minLength":8,"maxLength":84,"pattern":"^(?:[0-9a-f]{2}){4,42}$"}}},"examples":[{"input":{"hrp":"bc","witness_version":0,"program_hex":"751e76e8199196d454941c45d1b3a323f1433bd6"},"output":{"address":"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4","encoding":"bech32","script_pubkey_hex":"0014751e76e8199196d454941c45d1b3a323f1433bd6"}},{"input":{"hrp":"bc","witness_version":1,"program_hex":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"},"output":{"address":"bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0","encoding":"bech32m","script_pubkey_hex":"512079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"}},{"input":{"hrp":"bc","witness_version":16,"program_hex":"751e"},"output":{"address":"bc1sw50qgdz25j","encoding":"bech32m","script_pubkey_hex":"6002751e"}}],"execute_url":"/v1/tools/segwit-address-encode/versions/1.0.0/execute"}