Example #1
0
        public void VerifyTest()
        {
            string[] correctAddresses =
            {
                "grs1q7y35lw3fgev6fhgep4d8fqtj8cuvxdcwmfpqhx",
                "grs1qgyl6qr6jwj92j49ceskp089taqd3vsms5g9508",
            };
            string[] incorrectAddresses =
            {
                "grs117y35lw3fgev6fhgep4d8fqtj8cuvxdcwmfpqhx",
                "grs10ody35lw3fgev6fhgep4d8fqtj8cuvxdcwmfpqhx",
                "bc1rw5uspcuh",
                "bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90",
                "BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P",
                "bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du",
                "bc1gmk9yu"
            };

            foreach (var addr in correctAddresses)
            {
                Assert.AreEqual(true, SegWitAddress.Verify(addr, SegWitAddress.NetworkType.MainNet).IsVerified);
            }

            foreach (var addr in incorrectAddresses)
            {
                Assert.AreEqual(false, SegWitAddress.Verify(addr, SegWitAddress.NetworkType.MainNet).IsVerified);
            }
        }
        public void VerifyTest()
        {
            // Examples are from https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
            string[] correctAddresses =
            {
                "BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4",
                "bc1pw508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7k7grplx",
                "BC1SW50QA3JX3S",
                "bc1zw508d6qejxtdg4y5r3zarvaryvg6kdaj"
            };
            string[] incorrectAddresses =
            {
                "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t5",
                "BC13W508D6QEJXTDG4Y5R3ZARVARY0C5XW7KN40WF2",
                "bc1rw5uspcuh",
                "bc10w508d6qejxtdg4y5r3zarvary0c5xw7kw508d6qejxtdg4y5r3zarvary0c5xw7kw5rljs90",
                "BC1QR508D6QEJXTDG4Y5R3ZARVARYV98GJ9P",
                "bc1zw508d6qejxtdg4y5r3zarvaryvqyzf3du",
                "bc1gmk9yu"
            };

            foreach (var addr in correctAddresses)
            {
                Assert.AreEqual(true, SegWitAddress.Verify(addr, SegWitAddress.NetworkType.MainNet).IsVerified);
            }

            foreach (var addr in incorrectAddresses)
            {
                Assert.AreEqual(false, SegWitAddress.Verify(addr, SegWitAddress.NetworkType.MainNet).IsVerified);
            }
        }
Example #3
0
        private VerificationResult ValidateAddr(string addr)
        {
            VerificationResult vr = new VerificationResult();

            if (addr.StartsWith("grs1"))
            {
                vr = SegWitAddress.Verify(addr, SegWitAddress.NetworkType.MainNet);
            }
            else
            {
                vr = Base58.Verify(addr);
            }
            return(vr);
        }
        public void Validate(string address)
        {
            VerificationResult r = new VerificationResult();

            if (address.StartsWith("bc1"))
            {
                r = SegWitAddress.Verify(address, SegWitAddress.NetworkType.MainNet);
            }
            else
            {
                r = Base58.Verify(address);
            }

            if (r.IsVerified)
            {
                RemoveError("Address", "");
            }
            else
            {
                AddError("Address", r.Error);
            }
        }