public async Task <CommandHandlingResult> Handle(RegisterCashInOutCommand command, IEventPublisher eventPublisher)
        {
            var id          = command.CommandId;
            var asset       = command.Asset;
            var amount      = command.Amount;
            var transaction = command.Transaction;

            ChaosKitty.Meow();

            try
            {
                await _cashOperationsRepositoryClient.RegisterAsync(new CashInOutOperation
                {
                    Id             = id,
                    ClientId       = transaction.ClientId,
                    Multisig       = transaction.Multisig,
                    AssetId        = asset.Id,
                    Amount         = amount,
                    BlockChainHash = transaction.Hash,
                    DateTime       = DateTime.UtcNow,
                    AddressTo      = transaction.Multisig,
                    State          = TransactionStates.SettledOnchain
                });
            }
            catch (HttpOperationException)
            {
                var persistedOperation = await _cashOperationsRepositoryClient.GetAsync(transaction.ClientId, id);

                if (persistedOperation == null)
                {
                    throw;
                }
                // else assuming that operation was correctly persisted before
            }

            eventPublisher.PublishEvent(new CashInOutOperationRegisteredEvent
            {
                CommandId   = command.CommandId,
                Asset       = command.Asset,
                Amount      = command.Amount,
                Transaction = command.Transaction
            });

            return(CommandHandlingResult.Ok());
        }
        public async Task ProcessMessage(CashInOutQueueMessage message)
        {
            _log.Info(message: "Processing message", message.ToJson());

            ChaosKitty.Meow();

            var transaction = await _transactionsRepository.FindByTransactionIdAsync(message.Id);

            if (transaction == null)
            {
                if (_cashOperationsRepositoryClient.GetAsync(message.ClientId, message.Id) == null)
                {
                    _log.Warning($"{nameof(CashInOutQueue)}:{nameof(CashInOutQueueMessage)}", "unknown transaction", context: message.ToJson());
                    return;
                }

                await ProcessExternalCashin(message);
            }
            else
            {
                switch (transaction.CommandType)
                {
                case BitCoinCommands.CashIn:
                case BitCoinCommands.Issue:
                    await ProcessIssue(message);

                    break;

                case BitCoinCommands.CashOut:
                    await ProcessCashOut(message);

                    break;

                case BitCoinCommands.ManualUpdate:
                    ProcessManualUpdate(message);
                    break;

                default:
                    _log.Warning($"{nameof(CashInOutQueue)}:{nameof(CashInOutQueueMessage)}", $"Unknown command type (value = [{transaction.CommandType}])", context: message.ToJson());
                    break;
                }
            }
        }