public async Task <string> walletImportIpfs(string identifier,
                                                    string jsonConfig)
        {
            WalletBackupModel model =
                WalletBackupModel.importFromJson(jsonConfig);

            IpfsFacilitator ipfs = new IpfsFacilitator();

            string localPath = IOFacilitator.homePath() + "temp";

            try
            {
                // get file content
                string txt = await ipfs.getFile(model.ipfs_path, identifier);

                // create local file from ipfs content
                IOFacilitator.createFile(txt, "temp.txt");
                // convert txt to binary
                IOFacilitator.convertTextToByteFile("temp.txt", "temp");
                // import wallet into client
                string res = await walletImportLocal(identifier, localPath, model.wallet_key,
                                                     model.export_key);

                return(res);
            }
            catch (Exception e)
            {
                return($"Error: {e.Message}");
            }
        }
示例#2
0
        public async Task <string> downloadEmergencyEHR()
        {
            IpfsFacilitator ipfs         = new IpfsFacilitator();
            string          encryptedEHR = await ipfs.getFile(ipfs_path, "");

            // decrypt ehr data
            CipherFacilitator cipher = new CipherFacilitator();

            cipher.setKey(encryption_key);
            cipher.setIV(encryption_iv);
            return(cipher.decrypt(encryptedEHR));
        }