Skip to content

Instantly share code, notes, and snippets.

@riptl
Created March 17, 2019 12:05
Show Gist options
  • Save riptl/222a1680d819183746e84f0e61c1f094 to your computer and use it in GitHub Desktop.
Save riptl/222a1680d819183746e84f0e61c1f094 to your computer and use it in GitHub Desktop.
Parse Nimiq Extra Data
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