def __get_median_timestamp(self, blocks):
     # Sort all blocks by timestamp
     sorted_blocks = sorted( blocks, key=lambda b: b["time_utc"] )
     length = len( sorted_blocks )
     if length % 2:
         return int( ConsensusHelper.parse_utc_timestamp( sorted_blocks[length/2]["time_utc"] ) )
     else:
         return int( ( ConsensusHelper.parse_utc_timestamp( sorted_blocks[length/2]["time_utc"] ) + \
                       ConsensusHelper.parse_utc_timestamp( sorted_blocks[length/2-1]["time_utc"] ) ) / 2.0 )
 def __get_median_timestamp(self, blocks):
     # Sort all blocks by timestamp
     sorted_blocks = sorted(blocks, key=lambda b: b["time_utc"])
     length = len(sorted_blocks)
     if length % 2:
         return int(
             ConsensusHelper.parse_utc_timestamp(
                 sorted_blocks[length / 2]["time_utc"]))
     else:
         return int( ( ConsensusHelper.parse_utc_timestamp( sorted_blocks[length/2]["time_utc"] ) + \
                       ConsensusHelper.parse_utc_timestamp( sorted_blocks[length/2-1]["time_utc"] ) ) / 2.0 )
 def getFirstSeen(self, testnet, address):
     """
     Find out when the blockchain has first seen the provided address.
     Returns first transaction info if it has been seen, or None if never seen before.
     Result is ( block_number, confirmation_count, block_timestamp ) 
     """
     address_info = BitcoinThread.request_blockr_json(
         "address/info/%s" % address, testnet)
     if address_info['is_unknown'] or not 'first_tx' in address_info:
         return None
     first_tx = address_info['first_tx']
     return (int(first_tx['block_nb']), first_tx['confirmations'],
             int(ConsensusHelper.parse_utc_timestamp(first_tx['time_utc'])))
 def getFirstSeen(self, testnet, address):
     """
     Find out when the blockchain has first seen the provided address.
     Returns first transaction info if it has been seen, or None if never seen before.
     Result is ( block_number, confirmation_count, block_timestamp ) 
     """
     address_info = BitcoinThread.request_blockr_json( "address/info/%s" % address, testnet )
     if address_info['is_unknown'] or not 'first_tx' in address_info:
         return None
     first_tx = address_info['first_tx']
     return ( int( first_tx['block_nb'] ), 
              first_tx['confirmations'], 
              int( ConsensusHelper.parse_utc_timestamp( first_tx['time_utc'] ) ) )