/**
  * @param $wif
  * @param EcAdapterInterface|null $ecAdapter
  * @return PrivateKey
  * @throws InvalidPrivateKey
  */
 public static function fromWif($wif, EcAdapterInterface $ecAdapter = null)
 {
     $ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter();
     $wifSerializer = new WifPrivateKeySerializer($ecAdapter->getMath(), new HexPrivateKeySerializer($ecAdapter));
     return $wifSerializer->parse($wif);
 }
 /**
  * @param $wif
  * @param EcAdapterInterface|null $ecAdapter
  * @return PrivateKey
  * @throws InvalidPrivateKey
  */
 public static function fromWif($wif, EcAdapterInterface $ecAdapter = null)
 {
     $ecAdapter = $ecAdapter ?: Bitcoin::getEcAdapter();
     $wifSerializer = new WifPrivateKeySerializer($ecAdapter->getMath(), EcSerializer::getSerializer($ecAdapter, 'BitWasp\\Bitcoin\\Crypto\\EcAdapter\\Serializer\\Key\\PrivateKeySerializerInterface'));
     return $wifSerializer->parse($wif);
 }
Example #3
0
 /**
  * @param NetworkInterface $network
  * @return string
  */
 public function toWif(NetworkInterface $network = null)
 {
     $network = $network ?: Bitcoin::getNetwork();
     $wifSerializer = new WifPrivateKeySerializer($this->ecAdapter->getMath(), new PrivateKeySerializer($this->ecAdapter));
     return $wifSerializer->serialize($network, $this);
 }