Example #1
0
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('hash160', $json)) {
         $this->hash160 = $json['hash160'];
     }
     if (array_key_exists('address', $json)) {
         $this->address = $json['address'];
     }
     if (array_key_exists('n_tx', $json)) {
         $this->n_tx = $json['n_tx'];
     }
     if (array_key_exists('total_received', $json)) {
         $this->total_received = \Blockchain\Conversion\Conversion::BTC_int2str($json['total_received']);
     }
     if (array_key_exists('total_sent', $json)) {
         $this->total_sent = \Blockchain\Conversion\Conversion::BTC_int2str($json['total_sent']);
     }
     if (array_key_exists('final_balance', $json)) {
         $this->final_balance = \Blockchain\Conversion\Conversion::BTC_int2str($json['final_balance']);
     }
     if (array_key_exists('txs', $json)) {
         foreach ($json['txs'] as $txn) {
             $this->transactions[] = new Transaction($txn);
         }
     }
 }
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('tx_hash', $json)) {
         $this->tx_hash_le = $json['tx_hash'];
     }
     if (array_key_exists('tx_hash_big_endian', $json)) {
         $this->tx_hash = $json['tx_hash_big_endian'];
     }
     if (array_key_exists('tx_index', $json)) {
         $this->tx_index = $json['tx_index'];
     }
     if (array_key_exists('tx_output_n', $json)) {
         $this->tx_output_n = $json['tx_output_n'];
     }
     if (array_key_exists('script', $json)) {
         $this->script = $json['script'];
     }
     if (array_key_exists('value', $json)) {
         $this->value = \Blockchain\Conversion\Conversion::BTC_int2str($json['value']);
     }
     if (array_key_exists('value_hex', $json)) {
         $this->value_hex = $json['value_hex'];
     }
     if (array_key_exists('confirmations', $json)) {
         $this->confirmations = $json['confirmations'];
     }
 }
Example #3
0
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('n', $json)) {
         $this->n = $json['n'];
     }
     if (array_key_exists('value', $json)) {
         $this->value = \Blockchain\Conversion\Conversion::BTC_int2str($json['value']);
     }
     if (array_key_exists('addr', $json)) {
         $this->address = $json['addr'];
     }
     if (array_key_exists('tx_index', $json)) {
         $this->tx_index = $json['tx_index'];
     }
     if (array_key_exists('script', $json)) {
         $this->script = $json['script'];
     }
     if (array_key_exists('spent', $json)) {
         $this->spent = $json['spent'];
     }
     if (array_key_exists('addr_tag', $json)) {
         $this->address_tag = $json['addr_tag'];
     }
     if (array_key_exists('addr_tag_link', $json)) {
         $this->address_tag_link = $json['addr_tag_link'];
     }
 }
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('balance', $json)) {
         $this->balance = \Blockchain\Conversion\Conversion::BTC_int2str($json['balance']);
     }
     if (array_key_exists('address', $json)) {
         $this->address = $json['address'];
     }
     if (array_key_exists('label', $json)) {
         $this->label = $json['label'];
     }
     if (array_key_exists('total_received', $json)) {
         $this->total_received = $json['total_received'];
     }
 }
Example #5
0
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('sequence', $json)) {
         $this->sequence = $json['sequence'];
     }
     if (array_key_exists('script', $json)) {
         $this->script_sig = $json['script'];
     }
     if (array_key_exists('prev_out', $json)) {
         $this->coinbase = false;
         $P = $json['prev_out'];
         if (array_key_exists('n', $P)) {
             $this->n = $P['n'];
         }
         if (array_key_exists('value', $P)) {
             $this->value = \Blockchain\Conversion\Conversion::BTC_int2str($P['value']);
         }
         if (array_key_exists('addr', $P)) {
             $this->address = $P['addr'];
         }
         if (array_key_exists('tx_index', $P)) {
             $this->tx_index = $P['tx_index'];
         }
         if (array_key_exists('type', $P)) {
             $this->type = $P['type'];
         }
         if (array_key_exists('script', $P)) {
             $this->script = $P['script'];
         }
         if (array_key_exists('addr_tag', $P)) {
             $this->address_tag = $P['addr_tag'];
         }
         if (array_key_exists('addr_tag_link', $P)) {
             $this->address_tag_link = $P['addr_tag_link'];
         }
     }
 }
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('blocks_size', $json)) {
         $this->blocks_size = $json['blocks_size'];
     }
     if (array_key_exists('difficulty', $json)) {
         $this->difficulty = $json['difficulty'];
     }
     if (array_key_exists('estimated_btc_sent', $json)) {
         $this->estimated_btc_sent = \Blockchain\Conversion\Conversion::BTC_int2str(\Blockchain\Conversion\Conversion::bcconv($json['estimated_btc_sent']));
     }
     if (array_key_exists('estimated_transaction_volume_usd', $json)) {
         $this->estimated_transaction_volume_usd = $json['estimated_transaction_volume_usd'];
     }
     if (array_key_exists('hash_rate', $json)) {
         $this->hash_rate = $json['hash_rate'];
     }
     if (array_key_exists('market_price_usd', $json)) {
         $this->market_price_usd = $json['market_price_usd'];
     }
     if (array_key_exists('miners_revenue_btc', $json)) {
         $this->miners_revenue_btc = $json['miners_revenue_btc'];
     }
     if (array_key_exists('miners_revenue_usd', $json)) {
         $this->miners_revenue_usd = $json['miners_revenue_usd'];
     }
     if (array_key_exists('minutes_between_blocks', $json)) {
         $this->minutes_between_blocks = $json['minutes_between_blocks'];
     }
     if (array_key_exists('n_blocks_mined', $json)) {
         $this->n_blocks_mined = $json['n_blocks_mined'];
     }
     if (array_key_exists('n_blocks_total', $json)) {
         $this->n_blocks_total = $json['n_blocks_total'];
     }
     if (array_key_exists('n_btc_mined', $json)) {
         $this->n_btc_mined = \Blockchain\Conversion\Conversion::BTC_int2str(\Blockchain\Conversion\Conversion::bcconv($json['n_btc_mined']));
     }
     if (array_key_exists('n_tx', $json)) {
         $this->n_tx = $json['n_tx'];
     }
     if (array_key_exists('nextretarget', $json)) {
         $this->nextretarget = $json['nextretarget'];
     }
     if (array_key_exists('timestamp', $json)) {
         $this->timestamp = $json['timestamp'] / 1000.0;
     }
     if (array_key_exists('total_btc_sent', $json)) {
         $this->total_btc_sent = \Blockchain\Conversion\Conversion::BTC_int2str(\Blockchain\Conversion\Conversion::bcconv($json['total_btc_sent']));
     }
     if (array_key_exists('total_fees_btc', $json)) {
         $this->total_fees_btc = \Blockchain\Conversion\Conversion::BTC_int2str(\Blockchain\Conversion\Conversion::bcconv($json['total_fees_btc']));
     }
     if (array_key_exists('totalbc', $json)) {
         $this->totalbc = \Blockchain\Conversion\Conversion::BTC_int2str(\Blockchain\Conversion\Conversion::bcconv($json['totalbc']));
     }
     if (array_key_exists('trade_volume_btc', $json)) {
         $this->trade_volume_btc = $json['trade_volume_btc'];
     }
     if (array_key_exists('trade_volume_usd', $json)) {
         $this->trade_volume_usd = $json['trade_volume_usd'];
     }
     if (array_key_exists('market_cap', $json)) {
         $this->market_cap = $json['market_cap'];
     } else {
         $this->market_cap = bcmul($this->totalbc, $this->market_price_usd, 2);
     }
 }
Example #7
0
 /**
  * Methods
  */
 public function __construct($json)
 {
     if (array_key_exists('hash', $json)) {
         $this->hash = $json['hash'];
     }
     if (array_key_exists('ver', $json)) {
         $this->version = $json['ver'];
     }
     if (array_key_exists('prev_block', $json)) {
         $this->previous_block = $json['prev_block'];
     }
     if (array_key_exists('mrkl_root', $json)) {
         $this->merkle_root = $json['mrkl_root'];
     }
     if (array_key_exists('time', $json)) {
         $this->time = $json['time'];
     }
     if (array_key_exists('bits', $json)) {
         $this->bits = $json['bits'];
     }
     if (array_key_exists('fee', $json)) {
         $this->fee = \Blockchain\Conversion\Conversion::BTC_int2str($json['fee']);
     }
     if (array_key_exists('nonce', $json)) {
         $this->nonce = $json['nonce'];
     }
     if (array_key_exists('n_tx', $json)) {
         $this->n_tx = $json['n_tx'];
     }
     if (array_key_exists('size', $json)) {
         $this->size = $json['size'];
     }
     if (array_key_exists('block_index', $json)) {
         $this->block_index = $json['block_index'];
     }
     if (array_key_exists('main_chain', $json)) {
         $this->main_chain = $json['main_chain'];
     }
     if (array_key_exists('height', $json)) {
         $this->height = $json['height'];
     }
     if (array_key_exists('received_time', $json)) {
         $this->received_time = $json['received_time'];
     }
     if (array_key_exists('relayed_by', $json)) {
         $this->relayed_by = $json['relayed_by'];
     }
     if (array_key_exists('tx', $json)) {
         foreach ($json['tx'] as $tx) {
             $this->transactions[] = new Transaction($tx);
         }
     }
 }
Example #8
0
 public function sendMany($recipients, $from_address = null, $fee = null, $public_note = null)
 {
     $R = array();
     // Construct JSON by hand, preserving the full value of amounts
     foreach ($recipients as $address => $amount) {
         $R[] = '"' . $address . '":' . \Blockchain\Conversion\Conversion::BTC_float2int($amount);
     }
     $json = '{' . implode(',', $R) . '}';
     $params = array('recipients' => $json);
     if (!is_null($from_address)) {
         $params['from'] = $from_address;
     }
     if (!is_null($fee)) {
         $params['fee'] = \Blockchain\Conversion\Conversion::BTC_float2int($fee);
     }
     if (!is_null($public_note)) {
         $params['note'] = $public_note;
     }
     return new PaymentResponse($this->call('sendmany', $params));
 }