mirror of
https://github.com/Qortal/qortal.git
synced 2025-02-14 19:25:48 +00:00
Implemented address validation for Pirate Chain
This commit is contained in:
parent
380c742aad
commit
ab01dc5e54
@ -218,6 +218,24 @@ public class PirateChain extends Bitcoiny {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidAddress(String address) {
|
||||||
|
// Start with some simple checks
|
||||||
|
if (address == null || !address.toLowerCase().startsWith("zs") || address.length() != 78) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now try Bech32 decoding the address (which includes checksum verification)
|
||||||
|
try {
|
||||||
|
Bech32.Bech32Data decoded = Bech32.decode(address);
|
||||||
|
return (decoded != null && Objects.equals("zs", decoded.hrp));
|
||||||
|
}
|
||||||
|
catch (AddressFormatException e) {
|
||||||
|
// Invalid address, checksum failed, etc
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns P2SH address using passed redeem script. */
|
/** Returns P2SH address using passed redeem script. */
|
||||||
public String deriveP2shAddress(byte[] redeemScriptBytes) {
|
public String deriveP2shAddress(byte[] redeemScriptBytes) {
|
||||||
Context.propagate(bitcoinjContext);
|
Context.propagate(bitcoinjContext);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user