Example #1
0
 public function check($txid, $uid, $blockchain, $pw)
 {
     if (class_exists('bs_api') && $blockchain && $pw) {
         $api = new bs_api();
         $tx = $api->transaction(array('chain' => $blockchain, 'id' => $txid));
         if (isset($tx['outputs']) && is_array($tx['outputs']) && count($tx['outputs']) > 0) {
             foreach ($tx['outputs'] as $out_key => $output) {
                 if ($output['script_pub_key'] && !$output['pubkey_hash']) {
                     $msg = $this->hex2str($output['script_pub_key']);
                     if ($msg[3] == '{') {
                         $msg = json_decode(substr($msg, 3, strlen($msg)), true);
                     }
                     if (isset($msg['n']) && isset($msg['pw'])) {
                         $password = hash('sha256', $uid . hash('sha256', $pw));
                         if ($msg['pw'] == substr($password, 0, strlen($msg['pw']))) {
                             return $msg['n'];
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
Example #2
0
if (isset($_GET) && isset($_GET['chain'])) {
    $chain = $_GET['chain'];
}
if (isset($_GET) && isset($_GET['type'])) {
    $type = $_GET['type'];
}
if (isset($_GET) && isset($_GET['extension'])) {
    $file_extension = $_GET['extension'];
}
if (isset($_POST) && isset($_POST['password'])) {
    $password = $_POST['password'];
}
$typed_pw = $password;
$results = array('success' => false, 'url' => 'http://blockstrap.com', 'msg' => 'Unable to copy or delete file');
$api = new bs_api();
$tx = $api->transaction(array('chain' => $chain, 'id' => $txid));
if (isset($tx['time']) && isset($tx['outputs']) && isset($tx['outputs'][1]) && isset($tx['outputs'][1]['script_pub_key'])) {
    $pub_key = hex2str($tx['outputs'][1]['script_pub_key']);
    // TODO - WHY IS THIS FLAKEY...?
    $key_array = explode('jI', $pub_key);
    if (!isset($key_array[1])) {
        $key_array = explode('j:', $pub_key);
    }
    if (strpos($pub_key, '{') == 2) {
        $msg = json_decode(substr($pub_key, 2), true);
    } else {
        $msg = json_decode($key_array[1], true);
    }
    $pw = 'false';
    if (isset($msg['p'])) {
        $pw = $msg['p'];