MwebAddr.fromString constructor
Parse s as an MWEB address for chain. The HRP must match
chain.mwebHrp. Throws FormatException on HRP mismatch, mixed case,
bad characters, or checksum failure.
Implementation
factory MwebAddr.fromString(String s, Chain chain) {
final expectedHrp = chain.mwebHrp;
if (expectedHrp == null) {
throw FormatException('Chain does not support MWEB addresses');
}
final (hrp, data) = _bech32DecodeRaw(s);
if (hrp != expectedHrp) {
throw FormatException('MWEB HRP mismatch: expected $expectedHrp, got $hrp');
}
return MwebAddr(hrp: hrp, payload: data);
}