i'm trying to validate a dogecoin address using node.js javascript.
But i'm still trying to understand, the algorithm.
my current node.js version is v0.10.22
from what i was able to understand (correct me if i'm wrong) its a dogecoin address is no different from a bitcoin address.
So i try to do the following
- Base58 decode the address
- calculate sha256 of the returned result of a sha256 of the decoded address (two times sha256)
- do a comparison of the first 4 bytes of sha256 result with the last 4 bytes of the decoded address (i think i'm making a mistake here) ..
when i attempted to write this to javascript the base58 decoded result is correct, when i try to create a buffer from the decoded value , it throws error pointing that the value is not correct
var decodedHex = new Buffer(decodedBase58Result,'hex')
the above throws an error, if i do decodedBase58Result.toString()
which will stringify the number the script continues but doesn't return expected result.
So, is there a solution to this? without depending on third-party api calls
Update: i researched a lot and i found a client-side validator, with a small piece of code i made an npm package
which validates the address without relying on any third party api/service calls.