示例#1
0
 /**
  * Address from MPK
  * 
  * Generate an address from the $mpk, and $iteration. This function 
  * uses the public_key_from_mpk() function, and converts the result
  * to the bitcoin address.
  * 
  * @param	string	$mpk
  * @param	int	$iteration
  * @return	string
  */
 public static function address_from_mpk($mpk, $iteration, $magic_byte, $change = 0, $compressed = FALSE)
 {
     $change = $change == 0 ? 0 : 1;
     $public_key = self::public_key_from_mpk($mpk, $iteration, $change, $compressed);
     $address = BitcoinLib::public_key_to_address($public_key, $magic_byte);
     return $address;
 }
示例#2
0
 /**
  * Create Multisig
  *
  * This function mirrors that of Bitcoind's. It creates a redeemScript
  * out of keys given in the given order, creates a redeemScript, and
  * creates the address from this. $m must be greater than zero, and
  * public keys are required.
  *
  * @param    int $m
  * @param    array $public_keys
  * @param   string $address_version
  * @return  array/FALSE
  */
 public static function create_multisig($m, $public_keys = array(), $address_version = '05')
 {
     if ($m == 0) {
         return FALSE;
     }
     if (count($public_keys) == 0) {
         return FALSE;
     }
     $redeem_script = self::create_redeem_script($m, $public_keys);
     if ($redeem_script == FALSE) {
         return FALSE;
     }
     return array('redeemScript' => $redeem_script, 'address' => BitcoinLib::public_key_to_address($redeem_script, $address_version));
 }
示例#3
0
 /**
  * Key To Address
  * 
  * This function accepts a bip32 extended key, and converts it to a 
  * bitcoin address. 
  * 
  * @param	string	$extended_key
  * @param	string	$address_version
  * return	string/FALSE
  */
 public static function key_to_address($extended_key)
 {
     $import = self::import($extended_key);
     if ($import['type'] == 'public') {
         $public = $import['key'];
     } else {
         if ($import['type'] == 'private') {
             $public = BitcoinLib::private_key_to_public_key($import['key'], TRUE);
         } else {
             return FALSE;
         }
     }
     // Convert the public key to the address.
     return BitcoinLib::public_key_to_address($public, $import['version']);
 }