I couldn't find a function that validates a btc address. How can this be done? Thanks.
If you're generating an address using the library, then I'm sure it will only return a valid address, but if you want to add your own checks to it, here is a good resource:
http://stackoverflow.com/questions/21559851/bitcoin-address-form-validation-javascript-and-php
https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/address.js#L7
bitcoin.addresses.fromBase58Check will throw if the provided address parameter is invalid.
Use bitcoin.addresses.toOutputScript if you also want to check the version byte for a valid script.
Most helpful comment
https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/address.js#L7
bitcoin.addresses.fromBase58Checkwill throw if the providedaddressparameter is invalid.Use
bitcoin.addresses.toOutputScriptif you also want to check the version byte for a valid script.