Пример #1
0
        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
 static public WalletBackupModel importFromJsonFile(string walletIdentifier)
 {
     string importJson = IOFacilitator.readFile(
         WalletBackupModel.filePath(walletIdentifier));
     return WalletBackupModel.importFromJson(importJson);
 }