Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Nimiq support #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) Roman Shtylman
Copyright (c) Rhody Lugo 2020
Copyright (c) Roman Shtylman 2014-2020

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# wallet-address-validator
Simple wallet address validator for validating Bitcoin and other altcoins addresses in **Node.js and browser**.
# public-address-validator
Simple wallet address validator for validating Nimiq and other cryptocurrency addresses in **Node.js and browser**.

Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-address).

Expand All @@ -9,21 +9,21 @@ Forked from [ryanralph/altcoin-address](https://github.com/ryanralph/altcoin-add

### NPM
```
npm install wallet-address-validator
npm install public-address-validator
```

### Browser
```html
<script src="wallet-address-validator.min.js"></script>
<script src="public-address-validator.min.js"></script>
```

## API

##### validate (address [, currency = 'bitcoin'[, networkType = 'prod']])
##### validate (address [, currency = 'cryptocurrency'[, networkType = 'prod']])

###### Parameters
* address - Wallet address to validate.
* currency - Optional. Currency name or symbol, e.g. `'bitcoin'` (default), `'litecoin'` or `'LTC'`
* currency - Optional. Currency name or symbol, e.g. `'nimiq'` (default), `'bitcoin'` or `'ETH'`
* networkType - Optional. Use `'prod'` (default) to enforce standard address, `'testnet'` to enforce testnet address and `'both'` to enforce nothing.

> Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies.
Expand Down Expand Up @@ -71,6 +71,8 @@ npm install wallet-address-validator
* NEO/NEO, `'NEO'` or `'NEO'`
* NeoGas/GAS, `'neogas'` or `'GAS'`

* Nimiq/NIM, `'nimiq'` or `'NIM'`

* Peercoin/PPCoin/PPC, `'peercoin'` or `'PPC'`
* Primecoin/XPM, `'primecoin'` or `'XPM'`
* Protoshares/PTS, `'protoshares'` or `'PTS'`
Expand All @@ -97,7 +99,7 @@ npm install wallet-address-validator

#### Node
```javascript
var WAValidator = require('wallet-address-validator');
var WAValidator = require('public-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if(valid)
Expand All @@ -109,7 +111,7 @@ else
```

```javascript
var WAValidator = require('wallet-address-validator');
var WAValidator = require('public-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'litecoin', 'testnet');
if(valid)
Expand All @@ -122,12 +124,12 @@ else

#### Browser
```html
<script src="wallet-address-validator.min.js"></script>
<script src="public-address-validator.min.js"></script>
```

```javascript
// WAValidator is exposed as a global (window.WAValidator)
var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'bitcoin');
var valid = WAValidator.validate('NQXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX', 'nimiq');
if(valid)
alert('This is a valid address');
else
Expand Down
Loading