Created
March 17, 2019 12:05
-
-
Save riptl/222a1680d819183746e84f0e61c1f094 to your computer and use it in GitHub Desktop.
Parse Nimiq Extra Data
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
function parseExtraData(extraData) { | |
try { | |
const nullSep = extraData.indexOf(0); | |
if (nullSep == -1) | |
return null; | |
const nameBin = extraData.slice(0, nullSep); | |
const name = Nimiq.BufferUtils.toAscii(nameBin); | |
const addrBin = extraData.slice(nullSep + 1, nullSep + 21); | |
const addr = new Nimiq.Address(addrBin); | |
return { | |
poolName: name, | |
minerAddress: addr | |
} | |
} catch (e) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment