Beispiel #1
0
        private void SetString(string base64)
        {
            if (this._Network == null)
            {
                this._Network = NetworkRegistration.GetNetworkFromBase58Data(base64, this.Type);
                if (this._Network == null)
                {
                    throw new FormatException("Invalid " + GetType().Name);
                }
            }

            byte[] vchTemp         = Encoders.Base58Check.DecodeData(base64);
            byte[] expectedVersion = this._Network.GetVersionBytes(this.Type, true);


            this.vchVersion = vchTemp.SafeSubarray(0, expectedVersion.Length);
            if (!Utils.ArrayEqual(this.vchVersion, expectedVersion))
            {
                throw new FormatException("The version prefix does not match the expected one " + String.Join(",", expectedVersion));
            }

            this.vchData = vchTemp.SafeSubarray(expectedVersion.Length);
            this.wifData = base64;

            if (!this.IsValid)
            {
                throw new FormatException("Invalid " + GetType().Name);
            }
        }