예제 #1
0
        /// <summary>
        ///     Create a RadixAddres from a base58 string
        /// </summary>
        /// <param name="addressBase58"></param>
        public RadixAddress(string addressBase58)
        {
            byte[]    raw   = Base58Encoding.Decode(addressBase58);
            RadixHash check = RadixHash.Of(raw, 0, raw.Length - 4);

            for (int i = 0; i < 4; ++i)
            {
                if (check.Get(i) != raw[raw.Length - 4 + i])
                {
                    throw new ArgumentException("Address " + addressBase58 + " checksum mismatch");
                }
            }

            byte[] publicKey = new byte[raw.Length - 5];
            Array.Copy(raw, 1, publicKey, 0, raw.Length - 5);

            _addressBase58 = addressBase58;
            _pubKey        = new ECPublicKey(publicKey);
        }