Post
Topic
Board Announcements (Altcoins)
Re: [ANN][CLAM] CLAMs, Proof-Of-Chain, Proof-Of-Pearl
by
dooglus
on 04/03/2015, 18:11:49 UTC
does anybody know how to validate a CLAM address with PHP?

Probably your best bet is to use something like this to interface with clamd's RPC interface, and call "validateaddress".

Alternatively you can check an address by base58 decoding it, and making sure that the first byte of the result is (whatever it's meant to be, 0x85 I think) and that the last 4 bytes of the result are indeed the correct checksum for the rest of the result. Read about the format of addresses here:
  https://en.bitcoin.it/wiki/Base58Check_encoding

This is the regex to find/check an address
Code:
^[x][a-km-zA-HJ-NP-Z0-9]{26,33}$

Careful - that will tell you that
  xJDCLAMZ9rQ11tMf7JUw1Zzvjm5ShkryrV
is a valid address when it isn't.
  xJDCLAMZ9rQ11tMf7JUw1Zzvjm5ShkryrU
is valid. Note the U on the end.

The last few characters are a checksum to guard against typos. You can't validate the checksum using a regexp.