public Wallet AddNewWallet() { ISignatureProvider signer = signatureFactory.GetSignatureProvider(); Wallet wallet = new Wallet(signer, hashFactory); string walletName = Path.GetRandomFileName(); byte[] walletBlob = signer.ExportKeyPairBlob(); walletName = Path.ChangeExtension(walletName, "wallet"); string walletPath = Path.Combine(config.WalletDirectoryPath, walletName); JsonSerializer serializer = new JsonSerializer(); using (Stream jsonFile = File.Open(walletPath, FileMode.Create, FileAccess.Write, FileShare.None)) using (StreamWriter writer = new StreamWriter(jsonFile)) using (JsonWriter jsonWriter = new JsonTextWriter(writer)) serializer.Serialize(jsonWriter, walletBlob); wallets.Add(wallet); return(wallet); }