/// <summary> /// Generates a new instance of <see cref="Wallet"/> object. /// </summary> /// <returns>A <see cref="Wallet"/> object.</returns> public static Wallet Generate() { var secret = Seed.GenerateSecret(); var address = Seed.ComputeAddress(secret); return(new Wallet(address, secret)); }
public void TestWallet() { var secret = Seed.GenerateSecret(); var address = Seed.ComputeAddress(secret); var wallet = new Wallet(address, secret); Assert.AreEqual("j", (wallet.Address).Substring(0, 1)); Assert.AreEqual("s", (wallet.Secret).Substring(0, 1)); }
/// <summary> /// Constructs the <see cref="Wallet"/> instance from a scerect. /// </summary> /// <param name="secret">The secret.</param> /// <returns>A <see cref="Wallet"/> object.</returns> /// <exception cref="ArgumentNullException">secret is null.</exception> /// <exception cref="InvalidSecretException">secret is invalid.</exception> public static Wallet FromSecret(string secret) { if (secret == null) { throw new ArgumentNullException("secret"); } try { var address = Seed.ComputeAddress(secret); return(new Wallet(address, secret)); } catch (Exception ex) { throw new InvalidSecretException(secret, ex); } }
public static bool IsValidSecret(string secret) { if (secret == null || secret == string.Empty) { return(false); } try { var address = Seed.ComputeAddress(secret); return(IsValidAddress(address)); } catch { return(false); } }
/// <summary> /// Validate the address and secret pair. /// </summary> /// <param name="address"></param> /// <param name="secret"></param> /// <returns>true if the address and secret is valid.</returns> public static bool ValidateKeyPair(String address, String secret) { String myAddress = null; try { myAddress = Seed.ComputeAddress(secret); // compute address from secret } catch (Exception) { return(false); } if (!string.IsNullOrEmpty(address) && address.Equals(myAddress)) { return(true); } return(false); }