예제 #1
0
        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);
        }
예제 #2
0
 static public WalletBackupModel importFromJsonFile(string walletIdentifier)
 {
     string importJson = IOFacilitator.readFile(
         WalletBackupModel.filePath(walletIdentifier));
     return WalletBackupModel.importFromJson(importJson);
 }