unlock wallet so it can be used for payments

@param          $options ['primary_private_key' => key] OR ['passphrase' => pass]
@param callable $fn
@return bool
@throws \Exception
556664
public function unlock($options, callable $fn = null) {
        // explode the wallet data
        $password = isset($options['passphrase']) ? $options['passphrase'] : (isset($options['password']) ? $options['password'] : null);
        $primaryMnemonic = $this->primaryMnemonic;
        $primaryPrivateKey = isset($options['primary_private_key']) ? $options['primary_private_key'] : null;

        if ($primaryMnemonic && $primaryPrivateKey) {
            throw new \InvalidArgumentException("Can't specify Primary Mnemonic and Primary PrivateKey");
        }

        if (!$primaryMnemonic && !$primaryPrivateKey) {
            throw new \InvalidArgumentException("Can't init wallet without Primary Mnemonic or Primary PrivateKey");
        }

        if ($primaryMnemonic && !$password) {
            throw new \InvalidArgumentException("Can't init wallet with Primary Mnemonic without a passphrase");
        }

        if ($primaryPrivateKey) {
            if (!($primaryPrivateKey instanceof HierarchicalKey)) {
                $primaryPrivateKey = HierarchicalKeyFactory::fromExtended($primaryPrivateKey);
            }
        } else {
            // convert the mnemonic to a seed using BIP39 standard
            $primarySeed = (new Bip39SeedGenerator())->getSeed($primaryMnemonic, $password);
            // create BIP32 private key from the seed
            $primaryPrivateKey = HierarchicalKeyFactory::fromEntropy($primarySeed);
        }

        $this->primaryPrivateKey = BIP32Key::create($primaryPrivateKey, "m");

        // create checksum (address) of the primary privatekey to compare to the stored checksum
        $checksum = $this->primaryPrivateKey->key()->getPublicKey()->getAddress()->getAddress();
        if ($checksum != $this->checksum) {
            throw new \Exception("Checksum [{$checksum}] does not match [{$this->checksum}], most likely due to incorrect password");
        }

        $this->locked = false;

        // if the response suggests we should upgrade to a different blocktrail cosigning key then we should
        if (array_key_exists('upgrade_key_index', $options)) {
            $this->upgradeKeyIndex($options['upgrade_key_index']);
        }

        if ($fn) {
            $fn($this);
            $this->lock();
        }
    }
689433
public function Connect ($dsn = FALSE, $user = FALSE, $pass = FALSE, $options = FALSE)
	{
		
		if (!$this->connected)
		{
			
			$this->_dsn		= $dsn?: $this->_dsn;
			$this->_user	= $user?: $this->_user;
			$this->_pass	= $pass?: $this->_pass;
			$this->_options	= $options?: $this->_options;
			
			parent::__construct ($this->_dsn, $this->_user, $this->_pass, $this->_options);
			
			$this->connected	= TRUE;
			
		}
		
	}
1312913
public function generateKey(array $options = [])
	{
		$passphrase = $options['passphrase'] ?? false;

		if ($passphrase === false)
		{
			throw new \RuntimeException('Missing passphrase file');
		}

		return new Key('openssl', $passphrase, 'unused');
	}
909611
public function AuthEnable(AuthEnableRequest $argument,
                               $metadata = [], $options = [])
    {
        return $this->_simpleRequest('/etcdserverpb.Auth/AuthEnable',
            $argument,
            ['\Etcdserverpb\AuthEnableResponse', 'decode'],
            $metadata, $options);
    }
932361
public function updateCard($token, array $options = [])
    {
        $customer = $this->asBraintreeCustomer();

        $response = PaymentMethod::create(
            array_replace_recursive([
                'customerId' => $customer->id,
                'paymentMethodNonce' => $token,
                'options' => [
                    'makeDefault' => true,
                    'verifyCard' => true,
                ],
            ], $options)
        );

        if (! $response->success) {
            throw new Exception('Braintree was unable to create a payment method: '.$response->message);
        }

        $paypalAccount = $response->paymentMethod instanceof PaypalAccount;

        $this->forceFill([
            'paypal_email' => $paypalAccount ? $response->paymentMethod->email : null,
            'card_brand' => $paypalAccount ? null : $response->paymentMethod->cardType,
            'card_last_four' => $paypalAccount ? null : $response->paymentMethod->last4,
        ])->save();

        $this->updateSubscriptionsToPaymentMethod(
            $response->paymentMethod->token
        );
    }
1114171
public function setEncryption($options)
    {
        if (is_string($options)) {
            $this->blockCipher->setKey($options);
            $this->encryption['key'] = $options;
            return $this;
        }

        if (!is_array($options)) {
            throw new Exception\InvalidArgumentException('Invalid options argument provided to filter');
        }

        $options = $options + $this->encryption;

        if (isset($options['key'])) {
            $this->blockCipher->setKey($options['key']);
        }

        if (isset($options['algorithm'])) {
            try {
                $this->blockCipher->setCipherAlgorithm($options['algorithm']);
            } catch (CryptException\InvalidArgumentException $e) {
                throw new Exception\InvalidArgumentException("The algorithm '{$options['algorithm']}' is not supported");
            }
        }

        if (isset($options['hash'])) {
            try {
                $this->blockCipher->setHashAlgorithm($options['hash']);
            } catch (CryptException\InvalidArgumentException $e) {
                throw new Exception\InvalidArgumentException("The algorithm '{$options['hash']}' is not supported");
            }
        }

        if (isset($options['vector'])) {
            $this->setVector($options['vector']);
        }

        if (isset($options['key_iteration'])) {
            $this->blockCipher->setKeyIteration($options['key_iteration']);
        }

        $this->encryption = $options;

        return $this;
    }
147216
public function read($data, array $options = []) {
		$class = $options['class'];

		$encrypted = $class::read(null, ['strategies' => false]);
		$key = isset($options['key']) ? $options['key'] : null;

		if (!isset($encrypted['__encrypted']) || !$encrypted['__encrypted']) {
			return isset($encrypted[$key]) ? $encrypted[$key] : null;
		}

		$current = $this->_decrypt($encrypted['__encrypted']);

		if ($key) {
			return isset($current[$key]) ? $current[$key] : null;
		} else {
			return $current;
		}
	}
1021801
private function authPrecheckAcl($options)
    {
        if (isset($options[self::OSS_HEADERS][self::OSS_ACL]) && !empty($options[self::OSS_HEADERS][self::OSS_ACL])) {
            if (!in_array(strtolower($options[self::OSS_HEADERS][self::OSS_ACL]), self::$OSS_ACL_TYPES)) {
                throw new OssException($options[self::OSS_HEADERS][self::OSS_ACL] . ':' . 'acl is invalid(private,public-read,public-read-write)');
            }
        }
    }
1085654
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $unLockDeployment = new UnlockDeploymentTask();
        $unLockDeployment->setShellCommandService(new ShellCommandService());
        $unLockDeployment->execute($node, $application, $deployment, $options);
    }
54070
public static function work(array $options, callable $callable)
    {
        if (!extension_loaded('pcntl')) {
            throw new \Exception('pcntl extension required');
        }

        if (!extension_loaded('posix')) {
            throw new \Exception('posix extension required');
        }

        if (!isset($options['pid'])) {
            throw new \Exception('pid not specified');
        }

        $options = $options + array(
            'stdin'  => '/dev/null',
            'stdout' => '/dev/null',
            'stderr' => 'php://stdout',
        );

        if (($lock = @fopen($options['pid'], 'c+')) === false) {
            throw new \Exception('unable to open pid file ' . $options['pid']);
        }

        if (!flock($lock, LOCK_EX | LOCK_NB)) {
            throw new \Exception('could not acquire lock for ' . $options['pid']);
        }

        switch ($pid = pcntl_fork()) {
        case -1:
            throw new \Exception('unable to fork');
        case 0:
            break;
        default:
            fseek($lock, 0);
            ftruncate($lock, 0);
            fwrite($lock ,$pid);
            fflush($lock);
            return;
        }

        if (posix_setsid() === -1) {
            throw new \Exception('failed to setsid');
        }

        fclose(STDIN);
        fclose(STDOUT);
        fclose(STDERR);

        if (!($stdin  = fopen($options['stdin'], 'r'))) {
            throw new \Exception('failed to open STDIN ' . $options['stdin']);
        }

        if (!($stdout = fopen($options['stdout'], 'w'))) {
            throw new \Exception('failed to open STDOUT ' . $options['stdout']);
        }

        if (!($stderr = fopen($options['stderr'], 'w'))) {
            throw new \Exception('failed to open STDERR ' . $options['stderr']);
        }

        pcntl_signal(SIGTSTP, SIG_IGN);
        pcntl_signal(SIGTTOU, SIG_IGN);
        pcntl_signal(SIGTTIN, SIG_IGN);
        pcntl_signal(SIGHUP,  SIG_IGN);

        call_user_func($callable, $stdin, $stdout, $stderr);
    }
689180
public static function transactional($fn)
    {
        $oosql = self::getInstance('oosql', 'void');
        if (!$oosql->beginTransaction()) {
            $msg = 'Could not start this transaction. BeginTransaction failed!';
            throw new \Exception($msg, 9815, null);
        }
        if (is_callable($fn)) {
            $ret = $fn($oosql);
            return $ret;
        }
        $msg = 'Please pass a Lamda function as a parameter to this method!';
        throw new \Exception($msg, 9816, null);
    }
163422
public function decrypt($libraryId, array $options): bool
    {
        $hasQueryParams = array_key_exists('query', $options);
        $hasPassword = $hasQueryParams && array_key_exists('password', $options['query']);

        if (!$hasQueryParams || !$hasPassword) {
            throw new \Exception('Password query parameter is required to decrypt library');
        }

        $response = $this->client->request(
            'POST',
            $this->client->getConfig('base_uri') . '/repos/' . $libraryId . '/',
            $options
        );

        return json_decode($response->getBody()) === 'success';
    }
859882
public function make($original, $options = null)
    {
        if (is_array($options)) {
            $this->setCost($options['cost']);
        }

        $hash = password_hash($original, $this->algorithm(), [
            'cost' => $this->getCost(),
        ]);

        if (empty($hash)) {
            throw new \Exception('Bcrypt hashing not supported.', 500);
        }

        return $hash;
    }
1259909
function WalletKey(options, network) {
  if (!(this instanceof WalletKey))
    return new WalletKey(options, network);

  KeyRing.call(this, options, network);

  this.keyType = Path.types.HD;

  this.id = null;
  this.wid = -1;
  this.name = null;
  this.account = -1;
  this.branch = -1;
  this.index = -1;
}
536318
protected function updateTransaction($query, $update, $options)
    {
        return $this->transaction_collection->updateOne($query, $update, $options);
    }
723459
private function setAuthentication($key, $secret, $call, $settings)
    {
        $isBasicAuth = $this->isBasicAuthentication($key, $secret);
        if ($isBasicAuth) {
            $this->apikey = $key;
            $this->apisecret = $secret;
        } else {
            $this->apitoken = $key;
            $this->version = Config::SMS_VERSION;
        }
        $this->initSettings($call, $settings);
        $this->setSettings();
    }
362148
public function getUser($accessToken = null, array $options = [])
    {
        if (null === $accessToken) {
            $options['access_token'] = $this->blizzardClient->getAccessToken();
        } else {
            $options['access_token'] = $accessToken;
        }

        return $this->request('/account/user', $options);
    }