likl3sfuhjh (OP)
|
|
May 06, 2013, 11:41:21 PM |
|
I have a database of bitcoin addresses and i need to validate them. Please explain the process , i don't care if its an api or a script as long as its efficient.
|
Where do I get free bitcoins? www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
|
|
|
|
|
|
The Bitcoin software, network, and concept is called "Bitcoin" with a capitalized "B". Bitcoin currency units are called "bitcoins" with a lowercase "b" -- this is often abbreviated BTC.
|
|
|
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
|
|
minzie
|
|
May 06, 2013, 11:46:09 PM |
|
What do you mean by 'validate' exactly?
|
|
|
|
likl3sfuhjh (OP)
|
|
May 06, 2013, 11:47:18 PM |
|
to see if its a real address
|
Where do I get free bitcoins? www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
|
|
|
|
giantdragon
Legendary
Offline
Activity: 1582
Merit: 1002
|
|
May 07, 2013, 12:16:35 AM |
|
In PHP JSON-RPC you can use this code: $isvalid = $bitcoin->validateaddress($address); if($isvalid['isvalid']) { //Address valid }
|
|
|
|
likl3sfuhjh (OP)
|
|
May 07, 2013, 03:41:11 AM |
|
In PHP JSON-RPC you can use this code: $isvalid = $bitcoin->validateaddress($address); if($isvalid['isvalid']) { //Address valid } how can that be used in on a website that dosnt have access to the bitcoin client https://blockchain.info/api/json_rpc_apii guess i can use this right?
|
Where do I get free bitcoins? www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
|
|
|
kjj
Legendary
Offline
Activity: 1302
Merit: 1024
|
|
May 07, 2013, 03:52:07 AM |
|
You can do it without a bitcoind node.
Look up the base58check routines. There are several PHP implementations available. Basically, that is all a bitcoind node would do. (If the address belonged to a known key, it would provide other info too, but that doesn't matter.)
|
17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8 I routinely ignore posters with paid advertising in their sigs. You should too.
|
|
|
likl3sfuhjh (OP)
|
|
May 07, 2013, 04:29:58 AM |
|
someone explain to me how to use the json rpc, with blockchains api. There is little to no documentation i want to stop wasting my time with this. Just help me.
|
Where do I get free bitcoins? www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
|
|
|
robin0van0der0vliet
Newbie
Offline
Activity: 17
Merit: 0
|
|
May 07, 2013, 12:19:28 PM |
|
<?php
function checkAddress($address) { $origbase58 = $address; $dec = "0";
for ($i = 0; $i < strlen($address); $i++) { $dec = bcadd(bcmul($dec,"58",0),strpos("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",substr($address,$i,1)),0); }
$address = "";
while (bccomp($dec,0) == 1) { $dv = bcdiv($dec,"16",0); $rem = (integer)bcmod($dec,"16"); $dec = $dv; $address = $address.substr("0123456789ABCDEF",$rem,1); }
$address = strrev($address);
for ($i = 0; $i < strlen($origbase58) && substr($origbase58,$i,1) == "1"; $i++) { $address = "00".$address; }
if (strlen($address)%2 != 0) { $address = "0".$address; }
if (strlen($address) != 50) { return false; }
if (hexdec(substr($address,0,2)) > 0) { return false; }
return substr(strtoupper(hash("sha256",hash("sha256",pack("H*",substr($address,0,strlen($address)-8)),true))),0,8) == substr($address,strlen($address)-8); }
?> Here is a PHP function to validate a bitcoin address.
|
|
|
|
likl3sfuhjh (OP)
|
|
May 07, 2013, 09:42:53 PM |
|
thanks, i figured it out myself using the blockchain json rpc api. Ill try that code you took the time to post also thanks. <?php require_once('jsonrpcphp/includes/jsonRPCClient.php'); /** SIMPLE BITCOIN JSON RPC PHP**/ $btc_connect = array("user" => "", "pass" => "", "host" => "blockchain.info", "port" => 80); //create an array with connection settings $bitcoin = new jsonRPCClient("http://{$btc_connect['user']}:{$btc_connect['pass']}@{$btc_connect['host']}:{$btc_connect['port']}");
$address = 'bitcoinaddress'; $isvalid = $bitcoin->validateaddress($address); if($isvalid['isvalid']) { //Address valid } else{ echo '---------'.$address.'---------'; } ?>
|
Where do I get free bitcoins? www.bitcoinforest.com - Bitcoin faucet and survey site. Get .001 bitcoins for each survey, and .00001 for each captcha.
|
|
|
robin0van0der0vliet
Newbie
Offline
Activity: 17
Merit: 0
|
|
May 08, 2013, 08:42:59 PM |
|
thanks, i figured it out myself using the blockchain json rpc api. Ill try that code you took the time to post also thanks. <?php require_once('jsonrpcphp/includes/jsonRPCClient.php'); /** SIMPLE BITCOIN JSON RPC PHP**/ $btc_connect = array("user" => "", "pass" => "", "host" => "blockchain.info", "port" => 80); //create an array with connection settings $bitcoin = new jsonRPCClient("http://{$btc_connect['user']}:{$btc_connect['pass']}@{$btc_connect['host']}:{$btc_connect['port']}");
$address = 'bitcoinaddress'; $isvalid = $bitcoin->validateaddress($address); if($isvalid['isvalid']) { //Address valid } else{ echo '---------'.$address.'---------'; } ?>
The code I posted is much faster than this, and does not need to connect to any other server (such as blockchain.info).
|
|
|
|
minzie
|
|
May 09, 2013, 01:04:10 AM |
|
Sometimes speed is not an issue.
|
|
|
|
dave111223
Legendary
Offline
Activity: 1190
Merit: 1001
|
|
July 15, 2014, 04:28:44 PM |
|
The code I posted is much faster than this, and does not need to connect to any other server (such as blockchain.info). The code you posted does not work with multisig addresses
|
|
|
|
DeathAndTaxes
Donator
Legendary
Offline
Activity: 1218
Merit: 1079
Gerald Davis
|
|
July 15, 2014, 10:32:25 PM |
|
The code I posted is much faster than this, and does not need to connect to any other server (such as blockchain.info). The code you posted does not work with multisig P2SH addresses Minor correction. There actually is no "multisig addresses" just Pay2PubKeyHash addresses and Pay2ScriptHash addresses. The code provided only properly handles the former.
|
|
|
|
|