Пример #1
0
        public async Task TransferDispatchMessageReceivedAsync(string sessionId, TransferDispatchMessage message)
        {
            var transaction = _incomingTransactions.SingleOrDefault(x => x.SessionId == sessionId);

            if (transaction == null || transaction.Status != TransactionStatus.TransferAllowed)
            {
                return; //todo: handle this case.
            }
            transaction.TransactionHash = message.Transaction.TransactionId;
            transaction.SendingAddress  = message.Transaction.SendingAddress;
            transaction.Status          = TransactionStatus.TransferDispatched;
        }
        public static ProtoTransferDispatchMessage MapToProto(TransferDispatchMessage message)
        {
            var proto = new ProtoTransferDispatchMessage()
            {
                Comment     = message.Comment,
                Transfer    = Mapper.MapTransferToProto(message.Transfer),
                Transaction = Mapper.MapTranactionToProto(message.Transaction),
                Beneficiary = Mapper.MapBeneficiaryToProto(message.Beneficiary),
                Originator  = Mapper.MapOriginatorToProto(message.Originator),
                Message     = Mapper.MapMessageToProto(message.MessageType, message.Message),
                VaspInfo    = Mapper.MapVaspInformationToProto(message.VASP)
            };

            return(proto);
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (msgCase_ == MsgOneofCase.SessionRequestMessage)
            {
                hash ^= SessionRequestMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.SessionReplyMessage)
            {
                hash ^= SessionReplyMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.TransferRequestMessage)
            {
                hash ^= TransferRequestMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.TransferReplyMessage)
            {
                hash ^= TransferReplyMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.TransferDispatchMessage)
            {
                hash ^= TransferDispatchMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.TransaferConfirmationMessage)
            {
                hash ^= TransaferConfirmationMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.TerminationMessage)
            {
                hash ^= TerminationMessage.GetHashCode();
            }
            if (msgCase_ == MsgOneofCase.ReservedField)
            {
                hash ^= ReservedField.GetHashCode();
            }
            if (Signature.Length != 0)
            {
                hash ^= Signature.GetHashCode();
            }
            hash ^= (int)msgCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Пример #4
0
        public async Task TransferDispatchAsync(TransferReply transferReply, Transaction transaction)
        {
            var transferRequest = new TransferDispatchMessage(
                this.SessionId,
                this._originator,
                new Beneficiary("", _beneficiaryVaan.Vaan),
                transferReply,
                transaction,
                _vaspInfo
                );

            await _transportClient.SendAsync(new MessageEnvelope()
            {
                Topic          = this.CounterPartyTopic,
                SigningKey     = _privateSigningKey,
                EncryptionType = EncryptionType.Symmetric,
                EncryptionKey  = _sharedSymKeyId
            }, transferRequest);
        }
        public static TransferDispatchMessage MapFromProto(ProtoTransferDispatchMessage message)
        {
            var messageIn = new Message(
                message.Message.MessageId,
                message.Message.SessionId,
                message.Message.MessageCode);
            var originator  = Mapper.MapOriginatorFromProto(message.Originator);
            var beneficiary = Mapper.MapBeneficiaryFromProto(message.Beneficiary);
            var transfer    = Mapper.MapTransferFromProto(message.Transfer);
            var transaction = Mapper.MapTranactionFromProto(message.Transaction);
            var vasp        = Mapper.MapVaspInformationFromProto(message.VaspInfo);

            var obj = new TransferDispatchMessage(messageIn, originator, beneficiary, transfer, transaction, vasp)
            {
                Comment = message.Comment,
            };

            return(obj);
        }
Пример #6
0
        private void AssertTransferDispatch(TransferDispatchMessage response, TransferDispatchMessage request)
        {
            Assert.NotNull(response);

            Assert.Equal(request.Comment, response.Comment);

            Assert.Equal(request.Message.SessionId, response.Message.SessionId);
            Assert.Equal(request.MessageType, response.MessageType);
            Assert.Equal(request.Message.MessageCode, response.Message.MessageCode);
            Assert.Equal(request.Message.MessageId, response.Message.MessageId);

            AssertPlaceOfBirth(request.VASP.PlaceOfBirth, response.VASP.PlaceOfBirth);

            Assert.Equal(request.VASP.BIC, response.VASP.BIC);
            Assert.Equal(request.VASP.Name, response.VASP.Name);
            Assert.Equal(request.VASP.VaspPublickKey, response.VASP.VaspPublickKey);
            Assert.Equal(request.VASP.VaspIdentity, response.VASP.VaspIdentity);

            Assert.Equal(request.VASP.PostalAddress.StreetName, response.VASP.PostalAddress.StreetName);
            Assert.Equal(request.VASP.PostalAddress.AddressLine, response.VASP.PostalAddress.AddressLine);
            Assert.Equal(request.VASP.PostalAddress.BuildingNumber, response.VASP.PostalAddress.BuildingNumber);
            Assert.Equal(request.VASP.PostalAddress.Country, response.VASP.PostalAddress.Country);
            Assert.Equal(request.VASP.PostalAddress.PostCode, response.VASP.PostalAddress.PostCode);

            Assert.Equal(request.VASP.JuridicalPersonIds.Count(), response.VASP.JuridicalPersonIds.Count());

            AssertJuridicalPersonIds(request.VASP.JuridicalPersonIds, response.VASP.JuridicalPersonIds);

            Assert.Equal(request.VASP.NaturalPersonIds.Count(), response.VASP.NaturalPersonIds.Count());

            AssertNaturalPersonIds(request.VASP.NaturalPersonIds, response.VASP.NaturalPersonIds);

            Assert.Equal(request.Transfer.TransferType, response.Transfer.TransferType);
            Assert.Equal(request.Transfer.VirtualAssetType, response.Transfer.VirtualAssetType);
            Assert.Equal(request.Transfer.Amount, response.Transfer.Amount);
            Assert.Equal(request.Transfer.DestinationAddress, response.Transfer.DestinationAddress);

            AssertBeneficiary(request.Beneficiary, response.Beneficiary);

            AssertOriginator(request.Originator, response.Originator);

            AssertTransaction(request.Transaction, response.Transaction);
        }
        public async Task <TransferConfirmationMessage> TransferDispatchAsync(TransferReply transferReply, Transaction transaction)
        {
            if (_transferConfirmationCompletionSource.Task.Status == TaskStatus.WaitingForActivation)
            {
                var transferRequest = new TransferDispatchMessage(
                    this.SessionId,
                    this._originator,
                    new Beneficiary("", _beneficiaryVaan.Vaan),
                    transferReply,
                    transaction,
                    _vaspInfo
                    );

                await _transportClient.SendAsync(new MessageEnvelope()
                {
                    Topic          = this.CounterPartyTopic,
                    SigningKey     = _privateSigningKey,
                    EncryptionType = EncryptionType.Symmetric,
                    EncryptionKey  = _sharedSymKeyId
                }, transferRequest);
            }

            return(await _transferConfirmationCompletionSource.Task);
        }
Пример #8
0
        private static TransferDispatchMessage GetTransferDispatchMessage()
        {
            //Should be a contract
            var vaspKey = EthECKey.GenerateKey();

            var message = new Message(
                Guid.NewGuid().ToByteArray().ToHex(prefix: false),
                Guid.NewGuid().ToByteArray().ToHex(prefix: false),
                "1");

            var postalAddress = new PostalAddress(
                "TestingStreet",
                61,
                "Test Address Line",
                "410000",
                "TownN",
                Country.List["DE"]
                );
            var placeOfBirth    = new PlaceOfBirth(DateTime.UtcNow, "TownN", Country.List["DE"]);
            var vaspInformation = new VaspInformation(
                "Test test",
                vaspKey.GetPublicAddress(),
                vaspKey.GetPubKey().ToHex(prefix: false),
                postalAddress,
                placeOfBirth,
                new NaturalPersonId[]
            {
                new NaturalPersonId("SomeId2", NaturalIdentificationType.AlienRegistrationNumber,
                                    Country.List["DE"]),
            },
                new JuridicalPersonId[]
            {
                new JuridicalPersonId("SomeId1", JuridicalIdentificationType.BankPartyIdentification,
                                      Country.List["DE"]),
            },
                "DEUTDEFF");

            var originator = new Originator("Originator1", "VaaN", postalAddress, placeOfBirth,
                                            new NaturalPersonId[]
            {
                new NaturalPersonId("SomeId2", NaturalIdentificationType.AlienRegistrationNumber,
                                    Country.List["DE"]),
            },
                                            new JuridicalPersonId[]
            {
                new JuridicalPersonId("SomeId1", JuridicalIdentificationType.BankPartyIdentification,
                                      Country.List["DE"]),
            },
                                            "DEUTDEFF");

            var beneficiary = new Beneficiary("Ben1", "VaaN");

            var transferReply = new TransferReply(VirtualAssetType.ETH, TransferType.BlockchainTransfer, "10000000", "0x0000001");
            var transaction   = new Transaction("txId", DateTime.UtcNow, "0x0000002");

            var request = new TransferDispatchMessage(message, originator, beneficiary, transferReply, transaction, vaspInformation)
            {
                Comment = "This is test message",
            };

            return(request);
        }
 Task <TransferConfirmationMessage> IVaspMessageHandler.TransferDispatchHandlerAsync(TransferDispatchMessage request, VaspSession vaspSession)
 {
     return(_transferDispatch.Invoke(request, vaspSession));
 }
        public void MergeFrom(ProtoMessageWrapper other)
        {
            if (other == null)
            {
                return;
            }
            if (other.Signature.Length != 0)
            {
                Signature = other.Signature;
            }
            switch (other.MsgCase)
            {
            case MsgOneofCase.SessionRequestMessage:
                if (SessionRequestMessage == null)
                {
                    SessionRequestMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoSessionRequestMessage();
                }
                SessionRequestMessage.MergeFrom(other.SessionRequestMessage);
                break;

            case MsgOneofCase.SessionReplyMessage:
                if (SessionReplyMessage == null)
                {
                    SessionReplyMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoSessionReplyMessage();
                }
                SessionReplyMessage.MergeFrom(other.SessionReplyMessage);
                break;

            case MsgOneofCase.TransferRequestMessage:
                if (TransferRequestMessage == null)
                {
                    TransferRequestMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferRequestMessage();
                }
                TransferRequestMessage.MergeFrom(other.TransferRequestMessage);
                break;

            case MsgOneofCase.TransferReplyMessage:
                if (TransferReplyMessage == null)
                {
                    TransferReplyMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferReplyMessage();
                }
                TransferReplyMessage.MergeFrom(other.TransferReplyMessage);
                break;

            case MsgOneofCase.TransferDispatchMessage:
                if (TransferDispatchMessage == null)
                {
                    TransferDispatchMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferDispatchMessage();
                }
                TransferDispatchMessage.MergeFrom(other.TransferDispatchMessage);
                break;

            case MsgOneofCase.TransaferConfirmationMessage:
                if (TransaferConfirmationMessage == null)
                {
                    TransaferConfirmationMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTransferConfirmationMessage();
                }
                TransaferConfirmationMessage.MergeFrom(other.TransaferConfirmationMessage);
                break;

            case MsgOneofCase.TerminationMessage:
                if (TerminationMessage == null)
                {
                    TerminationMessage = new global::OpenVASP.ProtocolMessages.Messages.ProtoTerminationMessage();
                }
                TerminationMessage.MergeFrom(other.TerminationMessage);
                break;

            case MsgOneofCase.ReservedField:
                ReservedField = other.ReservedField;
                break;
            }

            _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
        }