Exemplo n.º 1
0
        private void SetData(byte[] vchData)
        {
            this.vchData = vchData;
#if HAS_SPAN
            if (!(_Network.GetVersionMemory(Type, false) is ReadOnlyMemory <byte> v))
            {
                throw new FormatException("Invalid " + this.GetType().Name);
            }
            this.vchVersion = v;
            Span <byte> buffer = vchVersion.Length + vchData.Length is int length &&
                                 length > 256 ? new byte[length] : stackalloc byte[length];
            this.vchVersion.Span.CopyTo(buffer);
            this.vchData.CopyTo(buffer.Slice(this.vchVersion.Length));
            wifData = _Network.NetworkStringParser.GetBase58CheckEncoder().EncodeData(buffer);
#else
            this.vchVersion = _Network.GetVersionBytes(Type, false);
            wifData         = _Network.NetworkStringParser.GetBase58CheckEncoder().EncodeData(vchVersion.Concat(vchData).ToArray());
#endif

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