Skip to content

Instantly share code, notes, and snippets.

@riptl
riptl / parseNimiqExtraData.js
Created March 17, 2019 12:05
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 {