{"id":"segwit-address-decode","version":"1.0.0","description":"Decode a native segwit address into witness version, program hex, and script pubkey.","supported_operations":["decode native segwit address","segwit address to witness program","parse bech32 witness address","parse bech32m witness address","read witness version from segwit address","segwit address to script pubkey","decode uppercase segwit address"],"unsupported_operations":["encode a witness program into an address","return a valid or invalid verdict without the program","hash or verify a key inside the program","locate a typo in the checksum"],"semantics":["expected_hrp must already be lowercase US-ASCII (code points 33..126 excluding 65..90). An uppercase expected_hrp such as BC is invalid_input with details.reason invalid_hrp and is not case-folded.","The address may be all-lowercase or all-uppercase. Mixed case is rejected. The decoded HRP is the lowercased address HRP and must equal expected_hrp exactly; a different HRP is invalid_input with details.reason hrp_mismatch.","Version 0 must use a valid Bech32 checksum and a 20-byte or 32-byte program. Versions 1 through 16 must use a valid Bech32m checksum and a program of 2 to 40 bytes. The other checksum constant is details.reason wrong_encoding, not a second acceptance.","Failure order after the lowercase expected_hrp check: character range, mixed case, separator, checksum, empty data, padding, program length, witness version, version-0 length, checksum variant, then HRP equality.","Address length above 90 characters, or expected_hrp length above 83 characters, is limit_exceeded before checksum work. The address limit is checked before the expected_hrp limit.","The program bytes are returned as given. They are not checked as a hash or a key. script_pubkey_hex is the BIP 141 witness script (OP_n plus a single-byte push).","Disclaimer: format transform only; provides no confidentiality, integrity, or authenticity."],"limits":{"max_address_chars":90,"max_hrp_chars":83},"pricing":{"status":"unpriced","charge_usd":null},"input_schema":{"type":"object","additionalProperties":false,"required":["address","expected_hrp"],"properties":{"address":{"type":"string","minLength":1,"maxLength":90},"expected_hrp":{"type":"string","minLength":1,"maxLength":83,"pattern":"^[\\x21-\\x40\\x5b-\\x7e]+$"}}},"output_schema":{"type":"object","additionalProperties":false,"required":["normalized_address","hrp","witness_version","program_hex","encoding","script_pubkey_hex"],"properties":{"normalized_address":{"type":"string","minLength":13,"maxLength":90,"pattern":"^[\\x21-\\x40\\x5b-\\x7e]{1,83}1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]+$"},"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}$"},"encoding":{"type":"string","enum":["bech32","bech32m"]},"script_pubkey_hex":{"type":"string","minLength":8,"maxLength":84,"pattern":"^(?:[0-9a-f]{2}){4,42}$"}}},"examples":[{"input":{"address":"BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4","expected_hrp":"bc"},"output":{"normalized_address":"bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4","hrp":"bc","witness_version":0,"program_hex":"751e76e8199196d454941c45d1b3a323f1433bd6","encoding":"bech32","script_pubkey_hex":"0014751e76e8199196d454941c45d1b3a323f1433bd6"}},{"input":{"address":"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7","expected_hrp":"tb"},"output":{"normalized_address":"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7","hrp":"tb","witness_version":0,"program_hex":"1863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262","encoding":"bech32","script_pubkey_hex":"00201863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262"}},{"input":{"address":"bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0","expected_hrp":"bc"},"output":{"normalized_address":"bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqzk5jj0","hrp":"bc","witness_version":1,"program_hex":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","encoding":"bech32m","script_pubkey_hex":"512079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"}}],"execute_url":"/v1/tools/segwit-address-decode/versions/1.0.0/execute"}