public async Task <string> walletExportIpfs(
            string exportKey, string walletKey = "")
        {
            string path = IOFacilitator.homePath() + d_identifier + "WBtemp";

            try
            {
                // create export file
                await walletExportLocal(path, exportKey);

                // convert export file from byte file to txt file
                string textFilePath = IOFacilitator.convertByteToTextFile(
                    d_identifier + "WBtemp");

                // upload text file to ipfs
                IpfsFacilitator ipfs     = new IpfsFacilitator();
                string          ipfsPath = await ipfs.addFile(textFilePath);

                WalletBackupModel model = new WalletBackupModel(
                    ipfsPath,
                    d_identifier,
                    (walletKey == "" ? d_identifier : walletKey),
                    exportKey);

                model.exportToJsonFile();

                return(JsonConvert.SerializeObject(model));
            }
            catch (Exception e)
            {
                return($"Error: {e.Message}");
            }
        }
        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}");
            }
        }
        public async Task <string> createWalletBackupSharedSecrets(
            int min, int total)
        {
            string list = await listSharedSecrets();

            if (list != "0")
            {
                throw new Exception("There allready exist shared secrets.");
            }

            if (!IOFacilitator.fileExists(WalletBackupModel.filePath(d_identifier)))
            {
                throw new Exception("There must be an IPFS backup of the wallet. No IPFS export JSON file was found for this wallet.");
            }

            WalletBackupModel model =
                WalletBackupModel.importFromJsonFile(d_identifier);

            List <string> secrets = SecretSharingFacilitator.createSharedSecret(
                model.toJson(), min, total);

            int idx = 0;

            foreach (string secret in secrets)
            {
                await addRecord(
                    "shared-secret",
                    secret,
                    "WBSS",
                    createSharedSecretTagJson(++idx, min, total));
            }

            list = await listSharedSecrets();

            return(list);
        }
 static public WalletBackupModel importFromJsonFile(string walletIdentifier)
 {
     string importJson = IOFacilitator.readFile(
         WalletBackupModel.filePath(walletIdentifier));
     return WalletBackupModel.importFromJson(importJson);
 }