{"id":"segwit-address-validate","version":"1.0.0","description":"Validate a native segwit address and report which Bech32 or Bech32m rule failed.","supported_operations":["validate native segwit address","check segwit address checksum variant","check witness program length rules","is this segwit address well formed","detect mixed case segwit address","check segwit address against expected hrp","validate bech32m witness address"],"unsupported_operations":["return the witness program bytes","encode a new segwit address","prove the program is a key or a payment hash","repair an invalid 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.","A well-typed address inside the length limits returns {valid:false, reason} for a witness-rule failure and {valid:true, encoding, witness_version, program_length} for success. It does not return the program or the script pubkey.","Version 0 requires Bech32 and a 20-byte or 32-byte program. Versions 1 through 16 require Bech32m and a 2-to-40-byte program. The other checksum constant yields reason wrong_encoding.","Rule order for a verdict: character range, mixed case, separator, checksum, empty data, padding, program length, witness version, version-0 length, checksum variant, then exact HRP equality with expected_hrp.","Wrong types, unknown fields, an empty address, a lone surrogate, and a non-lowercase expected_hrp throw invalid_input. Address length above 90, or expected_hrp length above 83, throws limit_exceeded before those rules. The address limit is checked first.","Success does not mean the program is a hash, a public key, or a spendable output. The bytes are not inspected past the length rules.","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":["valid"],"properties":{"valid":{"type":"boolean"},"reason":{"type":"string","enum":["mixed_case","character_out_of_range","no_separator","empty_hrp","too_short_checksum","invalid_character","bad_checksum","empty_data","invalid_padding","invalid_program_length","invalid_witness_version","wrong_encoding","hrp_mismatch"]},"encoding":{"type":"string","enum":["bech32","bech32m"]},"witness_version":{"type":"integer","minimum":0,"maximum":16},"program_length":{"type":"integer","minimum":2,"maximum":40}},"oneOf":[{"type":"object","additionalProperties":false,"required":["valid","encoding","witness_version","program_length"],"properties":{"valid":{"const":true},"encoding":{"type":"string","enum":["bech32","bech32m"]},"witness_version":{"type":"integer","minimum":0,"maximum":16},"program_length":{"type":"integer","minimum":2,"maximum":40}}},{"type":"object","additionalProperties":false,"required":["valid","reason"],"properties":{"valid":{"const":false},"reason":{"type":"string","enum":["mixed_case","character_out_of_range","no_separator","empty_hrp","too_short_checksum","invalid_character","bad_checksum","empty_data","invalid_padding","invalid_program_length","invalid_witness_version","wrong_encoding","hrp_mismatch"]}}}]},"examples":[{"input":{"address":"BC1SW50QGDZ25J","expected_hrp":"bc"},"output":{"valid":true,"encoding":"bech32m","witness_version":16,"program_length":2}},{"input":{"address":"bc1p0xlxvlhemja6c4dqv22uapctqupfhlxm9h8z3k2e72q4k9hcz7vqh2y7hd","expected_hrp":"bc"},"output":{"valid":false,"reason":"wrong_encoding"}},{"input":{"address":"tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sL5k7","expected_hrp":"tb"},"output":{"valid":false,"reason":"mixed_case"}}],"execute_url":"/v1/tools/segwit-address-validate/versions/1.0.0/execute"}