Code Monkey home page Code Monkey logo

address-validator's Introduction

Cryptocoin Address Validator

Use this code tell if a given address is valid for a given cryptocoin.

The design goals of this library are:

  • Simplicity
  • Security

This code has no dependencies and defines a single function isValidAddress(coin,address) which returns true or false.

The variables coin and address are assumed to be potentially-hostile user input. The main purpose of this library is to prevent easily-detectable invalid addresses from ever getting to lower-level libraries or coin daemons (like bitcoind).

Use at your own risk! This is currently being developed and not ready for production use.

Examples

isValidAddress("BTC","notvalid")                               # false
isValidAddress("HUSH", "t1JTXxWyBrxdWNTaNa5gYPPfpJkhqESvyox")  # true
isValidAddress("KMD", "RNJmgYaFF5DbnrNUX6pMYz9rcnDKC2tuAc")    # true

Supported coins

  • BTC (bech32 not supported yet)
  • BTG
  • DASH
  • DOGE
  • EMC2
  • ETC
  • ETH
  • GAME
  • HUSH
  • KMD (and 30+ asset chains)
  • LTC
  • PIVX
  • RVN
  • VRSC
  • XSG
  • ZCL
  • ZEC

Will You Add Support For Coin X?

Yes, probably! Make it easy, and submit a Github Issue, with the coin ticker and example addresses of each type (normal, multisig, shielded, etc..). That makes it almost trivial to add a new coin.

Even better: Patches Welcome! Please submit PR's to the master branch.

Test Suite

Tests are written with qunit, and run direcly in the browser: http://duke.leto.net/address-validator/

Supported Address Types

Both normal and multisig addresses are supported for coins that have them.

Transparent and shielded addresses are supported, for coins with shielded addresses. For Zcash-derived coins, Sprout and Sapling addresses are supported.

How can I detect only a valid transparent or shielded or multisig address?

Currently that is not directly supported. It is recommended that you call isValidAddress for validity, and then also do a prefix check for the address type.

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.