/**
  * @param CreateTransactionCommand $command
  * @throws \Exception
  */
 public function handle(CreateTransactionCommand $command)
 {
     $walletId = $command->getWalletId();
     $payToAddress = $command->getPayToAddress();
     $description = $command->getDescription();
     $amount = $command->getAmount();
     // Get wallet object from repository
     $wallet = $this->walletRepository->walletOfId(new WalletId($walletId));
     if (!$wallet) {
         throw new \Exception(sprintf("Wallet not found %s", $walletId));
     }
     // Call BlockCypher API to generate new transaction
     $txSkeleton = $this->blockCypherTransactionService->create($wallet->getId()->getValue(), $wallet->getCoinSymbol(), $wallet->getToken(), $payToAddress, $amount);
     // Create new app Transaction
     $transaction = new Transaction($this->transactionRepository->nextIdentity(), $wallet->getId(), null, $payToAddress, $description, $amount, $this->clock->now());
     // Get all addresses from all tx inputs.
     $allInputsAddresses = $txSkeleton->getInputsAddresses();
     // Get private keys from repository
     $privateKeys = $this->getPrivateKeysFromRepository($allInputsAddresses, $walletId);
     // Check private keys
     $this->checkPrivateKeys($privateKeys, $txSkeleton->getTosign());
     // Sign transaction
     $txSkeletonSigned = $this->blockCypherTransactionService->sign($txSkeleton, $privateKeys, $wallet->getCoinSymbol(), $wallet->getToken());
     // Send transaction to the network
     $txSkeletonSent = $this->blockCypherTransactionService->send($txSkeletonSigned, $wallet->getCoinSymbol(), $wallet->getToken());
     // Map real network tx with app transaction
     $transaction->assignNetworkTransactionHash($txSkeletonSent->getTx()->getHash());
     // Store new local app transaction
     $this->transactionRepository->insert($transaction);
 }