Exemplo n.º 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;
 }
Exemplo n.º 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'])) {
Exemplo n.º 3
0
     }
     if ($daily_sent >= $codes['daily'] && $codes['daily'] > 0) {
         $reason = 'Daily limit for this email address has been surpassed.';
     }
     $white_list = false;
     if ($reason != $original_reason && isset($codes['whitelist'])) {
         $white_list = explode(', ', $codes['whitelist']);
         foreach ($white_list as $key => $address) {
             if ($address === $email) {
                 $reason = $original_reason;
             }
         }
     }
 }
 if ($claim_code == $code && $reason == $original_reason) {
     $api = new bs_api();
     $address_obj = $api->address(array('id' => $addresses[$chain], 'chain' => $chain));
     $fee = $fees[$chain] * 100000000;
     $amount_to_send = $fee * 3;
     if ($sent) {
         $amount_to_send = $sent;
     }
     if (is_array($address_obj) && isset($address_obj['balance']) && $address_obj['balance'] >= $amount_to_send) {
         if (isset($keys[$chain]) && $tx) {
             try {
                 $bitcoin = new Bitcoin($usernames[$chain], $passwords[$chain], $hosts[$chain], $ports[$chain]);
                 $outputs = null;
                 $keys = [$keys[$chain]];
                 $raw_tx_results = $bitcoin->signrawtransaction($tx, $outputs, $keys);
                 if (is_array($raw_tx_results) && isset($raw_tx_results['hex'])) {
                     $raw_tx = $raw_tx_results['hex'];
Exemplo n.º 4
0
 *  All Work Released Under MIT License
 *
 *  -- Inclusion of core is required "blockstrap/blockstrap.php"
 *  -- Other modules extend the blockstrap class
 *  -- The API module requires the cache module
 *  
 */
// INCLUDE CORE CLASS
include_once dirname(__FILE__) . '/modules/blockstrap.php';
// INCLUDE ADDITIONAL COMPONENTS
include_once dirname(__FILE__) . '/modules/api.php';
include_once dirname(__FILE__) . '/modules/cache.php';
include_once dirname(__FILE__) . '/modules/dnkey.php';
include_once dirname(__FILE__) . '/modules/blockauth.php';
// INITIATE API
$api = new bs_api();
// SET DEFAULTS
$function = $api->get_var('function', 'address');
$chain = $api->get_var('chain', 'btc');
$id = $api->get_var('id', false);
$sample = '1JsoyFgFugGRRY7qkPGTHaKVQpeqf67VVb';
$link = '<a href="?function=address&chain=btc&id=' . $sample . '">' . $sample . '</a>';
$results = 'Waiting for Query ID. Try making an API call to the following Bitcoin address ' . $link . '.';
// DEFAULT EXAMPLE CONTENT AND STYLING
include_once dirname(__FILE__) . '/examples/console.php';
// CHECK FOR AND CALL FUNCTION
if (method_exists($api, $function) && ($function == 'dnkey' || $id)) {
    $results = $api->{$function}(array('chain' => $chain, 'id' => $id, 'debug' => true));
}
// DISPLAY RESULTS
$api->debug($results);