Esempio n. 1
0
        public bool Login(LoginRequest _loginRequest)
        {
            WalletData ret = null;

            if (_loginRequest.CreateNewWallet &&
                _loginRequest.PassCode != "" &&
                _loginRequest.WalletName != "" &&
                !FileBinIO.Exists(_loginRequest.WalletName))
            {
                ret = GenerateWallet(_loginRequest.PassCode, _loginRequest.WalletName);
            }
            else if (_loginRequest.CreateNewWallet)
            {
                Console.WriteLine("Missing wallet name or password, or password requirements do not match, or wallet already exists");
                return(false);    //Todo: add exception error
            }
            else
            {
                ret = LoginWallet(_loginRequest);
            }

            Data = ret;

            return(Data == null ? false : true);
        }
Esempio n. 2
0
        public static void WriteWalletData(WalletData _WalletDataToBlob, string _walletName)
        {
            //TODO: Move serialization to FileBinIO to avoid duplicating code on multiple objects
            MemoryStream    memorystream = new MemoryStream();
            BinaryFormatter bf           = new BinaryFormatter();

            bf.Serialize(memorystream, _WalletDataToBlob);
            byte[] BlobData = memorystream.ToArray();

            FileBinIO.WriteBin(BlobData, _walletName);
        }
Esempio n. 3
0
        public static WalletData ReadBlobToWalletData(string _walletName)
        {
            //Read from bin
            //TODO: Move deserialization to FileBinIO to avoid duplicating code on multiple objects
            byte[] BlobData = FileBinIO.ReadBin(_walletName);

            MemoryStream    memorystreamd     = new MemoryStream(BlobData);
            BinaryFormatter bfd               = new BinaryFormatter();
            WalletData      deserializedBlock = bfd.Deserialize(memorystreamd) as WalletData;

            memorystreamd.Close();

            return(deserializedBlock);
        }