bitcoin-address-soft-regex-validation
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

bitcoin-address-soft-regex-validation

Build Status Build Cron Coverage Status TypeScript

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.

npm install --save bitcoin-address-soft-regex-validation
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, this one and mixed together on Regex101.

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):

Stefano Magni
Stefano Magni

💻 ⚠️

This project follows the all-contributors specification. Contributions of any kind welcome!

Readme

Keywords

none

Package Sidebar

Install

npm i bitcoin-address-soft-regex-validation

Weekly Downloads

18

Version

1.1.3

License

MIT

Unpacked Size

109 kB

Total Files

8

Last publish

Collaborators

  • noriste