Bitcoin Forum

Bitcoin => Project Development => Topic started by: joepie91 on June 21, 2011, 04:19:07 AM



Title: [PHP] BlockExplorer Track following script
Post by: joepie91 on June 21, 2011, 04:19:07 AM
Posting this for a friend... he does not have sufficient posts to post in here yet.

It basically searches back through the blockchain (using Block Explorer) to find the earliest trace of an address (by following the first address link on every page).

Code:
<?php
/*
            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
                    Version 2, December 2004 

         Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 

  0. You just DO WHAT THE FUCK YOU WANT TO. 
*/

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */

/* Questions? ask Skullby <skullby@hush.com> */

error_reporting(0);
ini_set('display_errors','Off');

//$startHash = "166inTrZD3G9SMKRcsaRnvFcCbeSrKoyxL"; 
$startHash "18ukPi1oAcLau91YfpTkXY1EuZrYxZyUBx"// a hash I found, and wanted to trace backward in time. :)

getNext($startHash);

function 
getNext($hash) {
if (
$hash == "") {
  echo 
"\ndone\n";
  die;
}
$handle fopen("http://blockexplorer.com/address/".$hash,"r");
$contents ''
while (!
feof($handle)) {
  
$contents .= fread($handle8192);
}
fclose($handle);

$lines split("\n",$contents);

foreach (
$lines as $key=>$line) {
 if (
$line == "<td>Received: Address</td>") {
      
$found 1;
 }

 if (
$found == && strstr($line,"<li><a href=")) {
    
preg_match('/<li><a href="\/address\/(.*)">/',$line,$matches);
    echo 
$matches[1]."\n";
    
sleep(2);
    
getNext($matches[1]);
 }


}
 
}
?>


Title: Re: [PHP] BlockExplorer Track following script
Post by: Chick on June 21, 2011, 05:00:08 AM
Posting this for a friend... he does not have sufficient posts to post in here yet.

It basically searches back through the blockchain (using Block Explorer) to find the earliest trace of an address (by following the first address link on every page).

Code:
<?php
/*
            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
                    Version 2, December 2004 

         Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 

  0. You just DO WHAT THE FUCK YOU WANT TO. 
*/

/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */

/* Questions? ask Skullby <skullby@hush.com> */

error_reporting(0);
ini_set('display_errors','Off');

//$startHash = "166inTrZD3G9SMKRcsaRnvFcCbeSrKoyxL"; 
$startHash "18ukPi1oAcLau91YfpTkXY1EuZrYxZyUBx"// a hash I found, and wanted to trace backward in time. :)

getNext($startHash);

function 
getNext($hash) {
if (
$hash == "") {
  echo 
"\ndone\n";
  die;
}
$handle fopen("http://blockexplorer.com/address/".$hash,"r");
$contents ''
while (!
feof($handle)) {
  
$contents .= fread($handle8192);
}
fclose($handle);

$lines split("\n",$contents);

foreach (
$lines as $key=>$line) {
 if (
$line == "<td>Received: Address</td>") {
      
$found 1;
 }

 if (
$found == && strstr($line,"<li><a href=")) {
    
preg_match('/<li><a href="\/address\/(.*)">/',$line,$matches);
    echo 
$matches[1]."\n";
    
sleep(2);
    
getNext($matches[1]);
 }


}
 
}
?>

Ahahahah, I shouldn't run into any problems with that license. :)


Title: Re: [PHP] BlockExplorer Track following script
Post by: bitlotto on July 12, 2011, 03:41:54 PM
OR
https://blockexplorer.com/q/addressfirstseen/(putaddresshere)


Title: Re: [PHP] BlockExplorer Track following script
Post by: joepie91 on July 12, 2011, 11:24:25 PM
OR
https://blockexplorer.com/q/addressfirstseen/(putaddresshere)
Um, no.

This script traces back an address, to find where a specific transaction originated (in this case someone was branching off 0.04 every time and who wrote it wanted to figure out where that originated).

What you linked just gives the first seen date for a specific address (aka the first transaction).

Entirely different things.


Title: Re: [PHP] BlockExplorer Track following script
Post by: bitlotto on July 12, 2011, 11:29:51 PM
OR
https://blockexplorer.com/q/addressfirstseen/(putaddresshere)
Um, no.

This script traces back an address, to find where a specific transaction originated (in this case someone was branching off 0.04 every time and who wrote it wanted to figure out where that originated).

What you linked just gives the first seen date for a specific address (aka the first transaction).

Entirely different things.
ohhhh I mis-read what it does.  :-[ Cool!