Pages:
Author

Topic: PHP address validator (non JSON-RPC) (Read 4624 times)

newbie
Activity: 52
Merit: 0
March 04, 2014, 04:22:12 AM
#21
What is the advantage in validator for PHP that works without a connection to bitcoind?
You don't have to install bitcoind.
member
Activity: 112
Merit: 12
March 04, 2014, 04:02:32 AM
#20
What is the advantage in validator for PHP that works without a connection to bitcoind?
administrator
Activity: 5222
Merit: 13032
March 03, 2014, 04:17:57 PM
#19
If you're using my checkAddress, do this:

Code:
if(!preg_match('/^[1-9A-HJ-NP-Za-km-z]{20,40}$/', $address) || !checkAddress($address) )
    invalid address

My checkAddress assumes that the input is valid base58.

The PHP should probably be rewritten to be more efficient.
donator
Activity: 848
Merit: 1078
March 03, 2014, 12:41:52 PM
#18
I found a couple more false positives with the validation code:

1Sq2Pb5pCfPBKZ3U4SFjHMlhvAbz8Vpjk
1C8UDzgYqlhFqduhYzuAjlMQZWBvYahvD1

Is there an updated version of the code somewhere? Thanks.

bump.

Any take on this? Those addresses seem valid to me??
hero member
Activity: 525
Merit: 531
December 25, 2013, 08:51:56 AM
#17
Sorry to revive this topic, but I wanted to update it to mention that I took the above script and quickly converted it to a class so we don't contaminate our name spaces so much...  Also added the TestNet address version.
http://pastebin.com/nvmQJBAm

maybe a generic address tester, like this:

Code:
abstract class CoinValidator {
 private $addressversion = "00"; //this is a hex byte
 abstract protected function getAddressVersion($testnet);

 public function __construct($testnet = false)
    {
        $this->addressversion = $this->getAddressVersion($testnet);
    }
 ...
}

class BitCoinValidator extends CoinValidator {
  protected function getAddressVersion($testnet) {
    return ($testnet) ? "6F" : "00"; //TestNet vs ProductionNet
  }
}

class LiteCoinValidator extends CoinValidator {
  protected function getAddressVersion($testnet) {
    return ($testnet) ? "6F" : "30"; //TestNet vs ProductionNet
  }
}

class FooCoinValidator extends CoinValidator {
  protected function getAddressVersion($testnet) {
    return ($testnet) ? "XX" : "XX"; //TestNet vs ProductionNet
  }
}
...

Elbandi
newbie
Activity: 8
Merit: 0
December 25, 2013, 07:52:30 AM
#16
Sorry to revive this topic, but I wanted to update it to mention that I took the above script and quickly converted it to a class so we don't contaminate our name spaces so much...  Also added the TestNet address version.
http://pastebin.com/nvmQJBAm
legendary
Activity: 1400
Merit: 1005
March 19, 2013, 11:44:51 AM
#15
Oooh, going to integrate this into one of my scripts as well.
hero member
Activity: 608
Merit: 502
March 19, 2013, 11:34:41 AM
#14
I found a couple more false positives with the validation code:

1Sq2Pb5pCfPBKZ3U4SFjHMlhvAbz8Vpjk
1C8UDzgYqlhFqduhYzuAjlMQZWBvYahvD1

Is there an updated version of the code somewhere? Thanks.
newbie
Activity: 47
Merit: 0
November 28, 2012, 04:29:30 AM
#13
I published this a long time ago, but few people seem to use it:
http://pastebin.com/vmRQC7ha

Thanks for posting this! It's the best one I've found so far... I've run about 50 public keys through using PhpUnit through so far and it correctly validated them :-)
administrator
Activity: 5222
Merit: 13032
August 15, 2012, 01:12:48 AM
#12
Oh, checkAddress actually says that that's valid. My web interfaces all check base58 validity before using checkAddress... I'll update it soon to fix this.
hero member
Activity: 742
Merit: 500
August 14, 2012, 11:47:48 PM
#11
It says that that address is invalid, which seems correct.
Nice. There was a similar validator showing it as valid :)
administrator
Activity: 5222
Merit: 13032
August 14, 2012, 10:26:03 PM
#10
Will it validate 17FSKMPAyXGR7EQziCqbVfwleGumRosQoh as correct or not ?

It says that that address is invalid, which seems correct.
hero member
Activity: 742
Merit: 500
August 14, 2012, 10:10:02 PM
#9
I published this a long time ago, but few people seem to use it:
http://pastebin.com/vmRQC7ha
Will it validate 17FSKMPAyXGR7EQziCqbVfwleGumRosQoh as correct or not ?
administrator
Activity: 5222
Merit: 13032
August 14, 2012, 07:04:19 PM
#8
I had a question, can I use it only for testing the validity of a BTC address or can the functions inside the script be used for other purposes as well?

You can use it for other things. The base58 functions can be used for working with other address formats, for example.
legendary
Activity: 1204
Merit: 1002
RUM AND CARROTS: A PIRATE LIFE FOR ME
August 14, 2012, 02:28:57 AM
#7
I just found this script and I find it really useful, so I wanted to say thanks as well!

I had a question, can I use it only for testing the validity of a BTC address or can the functions inside the script be used for other purposes as well?

thanks,
administrator
Activity: 5222
Merit: 13032
June 14, 2011, 11:40:01 PM
#6
Thanks!
full member
Activity: 154
Merit: 100
June 14, 2011, 11:13:24 PM
#5
It requires the bcmath PHP extension, which is usually included by default in binary releases of PHP. Nothing else is required.

Thanks, I'm sure an early member like you has a few coins already but I just sent you a tip. Very useful bit of code.
administrator
Activity: 5222
Merit: 13032
June 14, 2011, 11:48:57 AM
#4
It requires the bcmath PHP extension, which is usually included by default in binary releases of PHP. Nothing else is required.
full member
Activity: 154
Merit: 100
June 14, 2011, 08:44:38 AM
#3
I published this a long time ago, but few people seem to use it:
http://pastebin.com/vmRQC7ha

Thanks, that's just what I was looking for... What are the PHP requirements for this?

If I'm using PHP5, do I need to add anything else to the install?

Thanks.
administrator
Activity: 5222
Merit: 13032
June 14, 2011, 08:29:43 AM
#2
I published this a long time ago, but few people seem to use it:
http://pastebin.com/vmRQC7ha
Pages:
Jump to: