Exemplo n.º 1
0
 $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'];
                 $txid = $bitcoin->sendrawtransaction($raw_tx);
                 if ($txid) {
                     $results['success'] = true;
                     $results['txid'] = $txid;
                     $results['msg'] = '<p>Successfully sent ' . $amount_to_send / 100000000 . ' coins to ' . $address . '</p>';
                     $bc_chain = $chain;
                     if ($bc_chain == 'doget') {
                         $bc_chain = 'dogt';
                     }
                     if ($bc_chain == 'dasht') {
                         $bc_chain = 'drkt';
                     }
                     if ($bc_chain == 'dash') {
                         $bc_chain = 'drk';
                     }
                     $message = array('subject' => 'Blockstrap Verification', 'html' => $results['msg'] . '<p>TXID: <a href="http://blockchains.io/' . $bc_chain . '/transaction/' . $txid . '/">' . $txid . '</a></p>', 'from_email' => $app['email'], 'from_name' => $app['name'], 'to' => array(array('email' => $email, 'type' => 'to')), 'tags' => array('em_' . md5($email) . '_sent'));