Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neuenet/handshake-regex
Regular expression for matching Handshake (HNS) wallet addresses
https://github.com/neuenet/handshake-regex
handshake hns regex
Last synced: 23 days ago
JSON representation
Regular expression for matching Handshake (HNS) wallet addresses
- Host: GitHub
- URL: https://github.com/neuenet/handshake-regex
- Owner: neuenet
- Archived: true
- Created: 2021-05-19T05:05:54.000Z (over 3 years ago)
- Default Branch: primary
- Last Pushed: 2021-11-08T00:45:29.000Z (about 3 years ago)
- Last Synced: 2024-10-04T14:08:16.608Z (about 1 month ago)
- Topics: handshake, hns, regex
- Language: TypeScript
- Homepage: https://npm.im/handshake-regex
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# handshake-regex
> Regular expression for matching Handshake (HNS) wallet addresses
## Install
```sh
$ npm i handshake-regex
```## Notes
- Version 31 Handshake addresses are _technically_ valid but they are also unspendable. For the sake of this module, those addresses are deemed invalid.
- This module does not fully validate a Handshake address (that involves hashing and more). It is intended to show fairly quickly if an obviously incorrect address is indeed incorrect. For validation, you will want to use something like [hsd](https://github.com/handshake-org/hsd/blob/master/lib/primitives/address.js).## Usage
```js
// Import the default export
import dap from "handshake-regex";dap("hs1q98ddwl2lcpnnzfvvrqad80qu97w0q72cyq2uy3");
// ^ Returns truedap("3MWvddmToBWnnPes3L45i1pRQDhPrLdznc");
// ^ Returns false
``````js
// Or, export the named function
import { handshakeRegex } from "handshake-regex";handshakeRegex("hs1q98ddwl2lcpnnzfvvrqad80qu97w0q72cyq2uy3");
// ^ Returns truehandshakeRegex("3MWvddmToBWnnPes3L45i1pRQDhPrLdznc");
// ^ Returns false
```## API
### handshakeRegex(suppliedString)
#### suppliedStringType: `string` (required)
- If nothing is supplied, an error is returned. Gotta love types.
- If you supply a nonsense string or non-Handshake wallet address, the response is `false`.## Tests
```sh
# Run all tests, sequentially
$ npm test# Test dependencies for latest versions
$ npm run test:dependencies# Lint "src" directory
$ npm run test:typescript# Test this module
$ npm run test:assert
```