Ejemplo n.º 1
0
 /// <summary>
 /// Retrieve key pair from a local data store.
 /// </summary>
 /// <returns>A Cryptokeypair object contains seed, private key, and public key. (BIP44)</returns>
 public CryptoKeyPair GetKey()
 {
     try
     {
         var           data   = collection.FindAll().FirstOrDefault();
         CryptoKeyPair result = new CryptoKeyPair();
         if (!string.IsNullOrEmpty(data?.Seed))
         {
             var hdGenerator = new DigibyteHDGenerator(MainNetwork, "Thai", data.Seed);
             return(hdGenerator.KeyPair(0));
         }
         else if (!string.IsNullOrEmpty(data?.PrivateKey))
         {
             var secretKey = new BitcoinSecret(data.PrivateKey, MainNetwork);
             result.SecretKey = secretKey;
             result.PublicKey = secretKey.GetAddress();
             return(result);
         }
         else
         {
             return(null);
         }
     }
     catch (System.Exception e)
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Retrieve a Cryptokeypair information according to the given seed.
 /// </summary>
 /// <param name="seed">15-word seed in Thai language</param>
 /// <returns>A Cryptokeypair object contains seed, private key, and public key. (BIP44)</returns>
 public CryptoKeyPair ParseSeed(string seed)
 {
     if (string.IsNullOrEmpty(seed))
     {
         return(null);
     }
     try
     {
         var hdGenerator = new DigibyteHDGenerator(MainNetwork, "Thai", seed);
         return(hdGenerator.KeyPair(0));
     }
     catch (System.Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Generate key pair with seed in Thai language.
        /// </summary>
        /// <returns>A Cryptokeypair object contains seed, private key, and public key. (BIP44)</returns>
        public CryptoKeyPair GenerateKey()
        {
            var hdGenerator = new DigibyteHDGenerator(MainNetwork, "Thai");

            return(hdGenerator.KeyPair(0));
        }