/** * @test */ public function should_allow_import_private_key_fom_wif() { $privateKey = PrivateKeyManipulator::importPrivateKeyFromWif(self::ADDRESS_WIF); $network = CoinSymbolNetworkMapping::getNetwork('btc-testnet'); $this->assertNotNull($privateKey); $this->assertInstanceOf('\\BitWasp\\Bitcoin\\Key\\PrivateKeyInterface', $privateKey); $this->assertEquals(self::ADDRESS_WIF, $privateKey->toWif($network)); }
/** * @dataProvider invalidProvider * @expectedException \Exception */ public function testInvalidDataValidate($coinSymbol) { $this->assertInstanceOf('\\BitWasp\\Bitcoin\\Network\\NetworkInterface', CoinSymbolNetworkMapping::getNetwork($coinSymbol)); }
/** * @param PrivateKeyInterface $privateKey * @param string $coinSymbol * @return mixed * @throws \Exception */ public static function getAddressFromPrivateKey($privateKey, $coinSymbol) { CoinSymbolValidator::validate($coinSymbol, 'coinSymbol'); $network = CoinSymbolNetworkMapping::getNetwork($coinSymbol); $publicKey = $privateKey->getPublicKey(); $address = $publicKey->getAddress()->getAddress($network); return $address; }