show miner name on block timeline

This commit is contained in:
BitcoinMechanic
2024-09-20 14:31:31 -07:00
parent 156bf12034
commit 25482b9a06
15 changed files with 204 additions and 14 deletions

View File

@@ -200,4 +200,27 @@ export function getVarIntLength(n: number): number {
} else {
return 9;
}
}
/** Extracts miner names from a DATUM coinbase transaction */
export function parseDATUMTemplateCreator(coinbaseRaw: string): string[] | null {
let bytes: number[] = [];
for (let c = 0; c < coinbaseRaw.length; c += 2) {
bytes.push(parseInt(coinbaseRaw.slice(c, c + 2), 16));
}
// Skip block height
let tagLengthByte = 1 + bytes[0];
let tagsLength = bytes[tagLengthByte];
if (tagsLength == 0x4c) {
tagLengthByte += 1;
tagsLength = bytes[tagLengthByte];
}
const tagStart = tagLengthByte + 1;
const tags = bytes.slice(tagStart, tagStart + tagsLength);
const tagString = String.fromCharCode(...tags);
return tagString.split('\x0f');
}