Exemple #1
0
 private void calcBase58()
 {
     if (pubKeyHash != null)
     {
         this.address = Base58CheckString.FromByteArray(pubKeyHash, PUBKEYHASH);
     }
     else if (scriptHash != null)
     {
         this.address = Base58CheckString.FromByteArray(scriptHash, SCRIPTHASH);
     }
     else
     {
         throw new InvalidOperationException("Address is not a public key or script hash!");
     }
 }
Exemple #2
0
 public static PrivateKey FromWIF(String s)
 {
     Byte[] b = Base58CheckString.ToByteArray(s);
     if (b.Length == 0x20)
     {
         return(new PrivateKey(b, false));
     }
     else if (b.Length == 0x21)
     {
         return(new PrivateKey(b.Take(0x20).ToArray(), true));
     }
     else
     {
         throw new ArgumentException("Invalid WIF Private Key");
     }
 }
Exemple #3
0
        private Byte calcHash()
        {
            Byte version;

            Byte[] hash = Base58CheckString.ToByteArray(this.ToString(), out version);
            switch (version)
            {
            case PUBKEYHASH:
                pubKeyHash = hash;
                break;

            case SCRIPTHASH:
                scriptHash = hash;
                break;
            }
            type = version;
            return(version);
        }