コード例 #1
0
        public static bool Verify(string encoded)
        {
            if (string.IsNullOrEmpty(encoded.Trim()))
            {
                return(false);
            }
            if (encoded.Length != ENCODED_SIZE)
            {
                return(false);
            }

            try
            {
                var hash = Address32Format.Decode(encoded, out var type);

                if (hash == null || hash.Length != RAW_SIZE - 1)
                {
                    return(false);
                }

                if (!Enum.IsDefined(typeof(AddressType), type))
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
 public Address(AddressType type, byte[] hash)
 {
     Debug.Assert(hash.Length == RAW_SIZE - 1);
     this.hash = hash;
     this.Type = type;
     Encoded   = Address32Format.Encode(type, hash);
     Debug.Assert(Encoded != null);
 }
コード例 #3
0
 public Address(string encoded)
 {
     Debug.Assert(encoded.Length == ENCODED_SIZE);
     Encoded = encoded;
     hash    = Address32Format.Decode(encoded, out Type);
     Debug.Assert(hash != null);
     Debug.Assert(hash.Length == RAW_SIZE - 1);
 }
コード例 #4
0
        public void TestAddress32Format()
        {
            // Private 7r7oFxKhhaH7UvMLpUXlcIEk0WWx7i4nw6BVnrKCmLk=
            var address  = "qyl68tygnjx6qqwrsmynmejmc9wxlw7almv3397j";
            var hash     = Address32Format.Decode(address, out var type);
            var encoded2 = Address32Format.Encode(type, hash);

            Assert.IsTrue(address == encoded2);
        }