https://github.com/noriste/bitcoin-address-soft-regex-validation
A single-function package to perform soft (no checksum) bitcoin address (Base58 and Bech32) validation
https://github.com/noriste/bitcoin-address-soft-regex-validation
bitcoin-address javascript typescript-definitions validation-library
Last synced: 2 months ago
JSON representation
A single-function package to perform soft (no checksum) bitcoin address (Base58 and Bech32) validation
- Host: GitHub
- URL: https://github.com/noriste/bitcoin-address-soft-regex-validation
- Owner: NoriSte
- Created: 2019-02-25T10:47:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-03T11:09:28.000Z (about 2 years ago)
- Last Synced: 2025-04-07T07:38:15.496Z (2 months ago)
- Topics: bitcoin-address, javascript, typescript-definitions, validation-library
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/bitcoin-address-soft-regex-validation
- Size: 907 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# bitcoin-address-soft-regex-validation
[](https://travis-ci.com/NoriSte/bitcoin-address-soft-regex-validation)
[](https://travis-ci.com/NoriSte/bitcoin-address-soft-regex-validation)
[](https://renovatebot.com/)
[](https://coveralls.io/github/NoriSte/bitcoin-address-soft-regex-validation?branch=master)
[](https://stryker-mutator.github.io)
[](https://codeclimate.com/github/NoriSte/bitcoin-address-soft-regex-validation/maintainability)
[](https://github.com/ellerbrock/typescript-badges/)Performs a soft (syntactically-only) validation of Bitcoin address (both Base58 and Bech32, both Mainnet and Testnet). It takes for granted that you have a stronger (maybe server side) Checksum validation.
```bash
npm install --save bitcoin-address-soft-regex-validation
```
```javascript
const {isValidBitcoinAddress} = require("bitcoin-address-soft-regex-validation");
// a mainnet address
isValidBitcoinAddress("1JDknRvZTi5XdhQB3cgvJ9R8aogUvfbYUB"); // "mainnet"
// a testnet address
isValidBitcoinAddress("tb1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"); // "testnet"
// an invalid address
isValidBitcoinAddress("fake-address"); // undefined
```Remember that it's not so important if some false positives pass the validation (as said above, it takes for granted that a serious validation is made elsewhere), the only important thing is that no one valid address is blocked.
It's bases on some resources like [this one](http://mokagio.github.io/tech-journal/2014/11/21/regex-bitcoin.html), [this one](https://stackoverflow.com/a/48643915) and mixed together on [Regex101](https://regex101.com/r/v0g6bv/1).
It has no dependencies and it's a single-function package, check the `index.js` file to copy the code and avoid adding one more dependency if you want.
Last but not least: it's written in TypeScript.
## Contributors
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!