Exemplo n.º 1
0
 public function __construct($json)
 {
     if (array_key_exists('balance', $json)) {
         $this->balance = 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'];
     }
 }
Exemplo n.º 2
0
 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 = 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);
         }
     }
 }
Exemplo n.º 3
0
 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 = BTC_int2str(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 = BTC_int2str(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 = BTC_int2str(bcconv($json['total_btc_sent']));
     }
     if (array_key_exists('total_fees_btc', $json)) {
         $this->total_fees_btc = BTC_int2str(bcconv($json['total_fees_btc']));
     }
     if (array_key_exists('totalbc', $json)) {
         $this->totalbc = BTC_int2str(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);
     }
 }