Example #1
0
        public static bool VerfiyAddress(out AddressData addressData, string Address, byte[] PublicKey, string UserName)
        {
            addressData = new AddressData(Address);

            if (!Utils.ValidateUserName(UserName)) return false;

            byte[] ExpectedAddress = GetAddress(PublicKey, UserName, addressData.NetworkType, addressData.AccountType);

            if (Utils.ByteArrayEquals(addressData.AddressBinary, ExpectedAddress))
            {
                return true;
            }

            return false;
        }
        public void Deserialize(byte[] Data)
        {
            List<ProtocolDataType> PDTs = ProtocolPackager.UnPackRaw(Data);
            int cnt = 0;

            while (cnt < (int)PDTs.Count)
            {
                ProtocolDataType PDT = PDTs[cnt++];

                switch (PDT.NameType)
                {
                    case 0:
                        byte[] PK = new byte[Common.KEYLEN_PUBLIC];
                        ProtocolPackager.UnpackByteVector_s(PDT, 0, Common.KEYLEN_PUBLIC, ref PK);
                        PublicKey = PK;
                        break;

                    case 1:
                        string _Name = "";
                        ProtocolPackager.UnpackString(PDT, 1, ref _Name);
                        Name = _Name;
                        break;

                    case 2:
                        string AddressString = "";
                        ProtocolPackager.UnpackString(PDT, 2, ref AddressString);
                        AddressData = new AddressData(AddressString);
                        break;
                }
            }
        }