Last active
November 11, 2017 16:11
-
-
Save paOol/1e83dd785cbe9fe965e1635553d3f041 to your computer and use it in GitHub Desktop.
Copay Bitcoin Cash address translator function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const translate = require("npm-address-translator"); | |
translateAddress(address) { | |
let rgx = "[13CH][a-km-zA-HJ-NP-Z0-9]{30,33}"; | |
let testRegEx = new RegExp(rgx, "i"); | |
if (testRegEx.test(address)) { | |
let translated = translate.translateAddress(address); | |
if (translated.origCoin == "BTC") { | |
return translated.origAddress; | |
} else { | |
return translated.resultAddress; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment