/** * @param string $token * @return bool */ public function authenticate($token) { $apiContext = $this->apiContextFactory->getApiContext(self::AUTH_WALLET_COIN_SYMBOL, $token); $walletClient = new WalletClient($apiContext); try { // Create BlockCypher wallet $bcWallet = new BlockCypherWallet(); $bcWallet->setToken($token); $bcWallet->setName(self::AUTH_WALLET_NAME); $bcWallet = $walletClient->create($bcWallet); if ($bcWallet && $bcWallet->getName() == self::AUTH_WALLET_NAME) { return true; } else { return false; } } catch (BlockCypherConnectionException $e) { if ($e->getCode() == self::ERROR_WALLET_ALREADY_EXISTS) { return true; } else { return false; } } catch (\Exception $e) { return false; } }
/** * @param $walletName * @param $coinSymbol * @param $token * @return BlockCypherWallet */ public function createWallet($walletName, $coinSymbol, $token) { $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token); $walletClient = new WalletClient($apiContext); // Create BlockCypher wallet $bcWallet = new BlockCypherWallet(); $bcWallet->setToken($token); $bcWallet->setName($walletName); return $walletClient->create($bcWallet); }