Example #1
0
        protected override async Task ProcessEvent(object evt, CancellationToken cancellationToken)
        {
            if (evt is InvoiceEvent invoiceEvent && invoiceEvent.Name == InvoiceEvent.ReceivedPayment &&
                invoiceEvent.Payment.GetPaymentMethodId()?.PaymentType == BitcoinPaymentType.Instance &&
                invoiceEvent.Payment.GetCryptoPaymentData() is BitcoinLikePaymentData bitcoinLikePaymentData)
            {
                var walletId      = new WalletId(invoiceEvent.Invoice.StoreId, invoiceEvent.Payment.GetCryptoCode());
                var transactionId = bitcoinLikePaymentData.Outpoint.Hash;
                var labels        = new List <(string color, Label label)>
                {
                    UpdateTransactionLabel.InvoiceLabelTemplate(invoiceEvent.Invoice.Id)
                };

                if (invoiceEvent.Invoice.GetPayments(invoiceEvent.Payment.GetCryptoCode(), false).Any(entity =>
                                                                                                      entity.GetCryptoPaymentData() is BitcoinLikePaymentData pData &&
                                                                                                      pData.PayjoinInformation?.CoinjoinTransactionHash == transactionId))
                {
                    labels.Add(UpdateTransactionLabel.PayjoinLabelTemplate());
                }

                foreach (var paymentId in PaymentRequestRepository.GetPaymentIdsFromInternalTags(invoiceEvent.Invoice))
                {
                    labels.Add(UpdateTransactionLabel.PaymentRequestLabelTemplate(paymentId));
                }
                foreach (var appId in  AppService.GetAppInternalTags(invoiceEvent.Invoice))
                {
                    labels.Add(UpdateTransactionLabel.AppLabelTemplate(appId));
                }



                _eventAggregator.Publish(new UpdateTransactionLabel(walletId, transactionId, labels));
            }
Example #2
0
        protected override async Task ProcessEvent(object evt, CancellationToken cancellationToken)
        {
            if (evt is InvoiceEvent invoiceEvent && invoiceEvent.Name == InvoiceEvent.ReceivedPayment &&
                invoiceEvent.Payment.GetPaymentMethodId().PaymentType == BitcoinPaymentType.Instance &&
                invoiceEvent.Payment.GetCryptoPaymentData() is BitcoinLikePaymentData bitcoinLikePaymentData)
            {
                var walletId      = new WalletId(invoiceEvent.Invoice.StoreId, invoiceEvent.Payment.GetCryptoCode());
                var transactionId = bitcoinLikePaymentData.Outpoint.Hash;
                var labels        = new List <(string color, string label)>
                {
                    UpdateTransactionLabel.InvoiceLabelTemplate(invoiceEvent.Invoice.Id)
                };

                if (invoiceEvent.Invoice.GetPayments(invoiceEvent.Payment.GetCryptoCode()).Any(entity =>
                                                                                               entity.GetCryptoPaymentData() is BitcoinLikePaymentData pData &&
                                                                                               pData.PayjoinInformation?.CoinjoinTransactionHash == transactionId))
                {
                    labels.Add(UpdateTransactionLabel.PayjoinLabelTemplate());
                }

                _eventAggregator.Publish(new UpdateTransactionLabel()
                {
                    WalletId          = walletId,
                    TransactionLabels =
                        new Dictionary <uint256, List <(string color, string label)> >()
                    {
                        { transactionId, labels }
                    }
                });
            }