Forum Home
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular

    [Solved] Pub Key/Address Regex - Advice on regular expressions Valid FTC keys

    Technical Development
    3
    4
    1585
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mathco last edited by wrapper

      In the process of writing a mobile application and wanted to check on the validity of FTC addresses without hitting the network each time (seems unnecessary when just adding new addresses from a barcode).

      I’ve adapted a regex someone posted for LTC some for what I _think_ is valid for FTC. Can anyone confirm the following:

      Rules:

      • Always starts with the #6
      • 34 characters long (in total)
      • a-z, A-Z, 0-9 are the only valid characters allowed.
      • Ends with a capital character (A-Z)

      If so, I believe the regex would be the following:

      • ^6[a-zA-Z0-9]{32}[A-Z]{1}$

      Can anyone confirm the above?

      Thanks!
      Joel

      1 Reply Last reply Reply Quote 0
      • zerodrama
        zerodrama Regular Member last edited by

        No. Some start with 7.

        1 Reply Last reply Reply Quote 0
        • K
          Kevlar Spammer last edited by

          [quote name=“Mathco” post=“46484” timestamp=“1387554970”]
          In the process of writing a mobile application and wanted to check on the validity of FTC addresses without hitting the network each time (seems unnecessary when just adding new addresses from a barcode).

          I’ve adapted a regex someone posted for LTC some for what I _think_ is valid for FTC. Can anyone confirm the following:

          Rules:

          • Always starts with the #6
          • 34 characters long (in total)
          • a-z, A-Z, 0-9 are the only valid characters allowed.
          • Ends with a capital character (A-Z)

          If so, I believe the regex would be the following:

          • ^6[a-zA-Z0-9]{32}[A-Z]{1}$

          Can anyone confirm the above?

          Thanks!
          Joel
          [/quote]

          Nope. Some start with 6, some start with 7. lowercase l is not allowed, nor is uppercase I or uppercase O, or 0.

          Here’s the list.

          123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

          But even then it can still be an invalid address.

          What you need to do is base58 decode it, then strip the last 4 bytes, and run that through 2 rounds of sha256. If the first 4 bytes of that has match the last 4 bytes you stripped off previously, it’s a valid address.

          1 Reply Last reply Reply Quote 0
          • M
            Mathco last edited by

            Great information. Thanks!

            That means if I use the Regular Expression method (as a dummy check at least for now) the expression would be something like the following:

            ^[6-7][ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz1-9]{33}$

            I’ll look into the Base58/SHA256 way later on when I get encryption libraries included though.

            Thanks again!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post