Fix WIF/LegacyAddress mishandling
Unfortunately, there's not a prettier way of doing this at the moment.
I'd hoped to use secp256k1.validatePrivateKey(...)
, but legacy addresses (despite being 20 byte payloads) are actually still considered valid PrivKeys and we can't use decodedPrivateKey.type
because LibAuth makes an if/else assumption under the hood and will give us a false result indicating it's a testnetUncompressed
key. So just checking payload length is probably the most foolproof for now.
I've got a PR for LibAuth here to fix:
https://github.com/bitauth/libauth/pull/147
Once merged, I'll return and remove this code to clean things up a bit.
Signed-off-by: James Zuccon zuccon@gmail.com