Skip to content

toggle to allow raw display of miner tag as per WOC#441

Open
freemans13 wants to merge 2 commits intobsv-blockchain:mainfrom
freemans13:stu/allow-raw-miner-tag
Open

toggle to allow raw display of miner tag as per WOC#441
freemans13 wants to merge 2 commits intobsv-blockchain:mainfrom
freemans13:stu/allow-raw-miner-tag

Conversation

@freemans13
Copy link
Collaborator

@freemans13 freemans13 commented Jan 28, 2026

Summary

Implements a toggle to allow raw (unsanitized) miner tag display, matching WhatsOnChain's behavior.

Fixes https://github.com/bitcoin-sv/teranode/issues/1298

Problem

There was a UTF-8/decoding issue with miner tags. For mainnet block 514587:

  • Teranode block explorer showed: A% Zj?d?;?
  • WhatsOnChain showed: �^G^GA% Zj�d�;��

TAAL wants to run comparisons and would prefer Teranode to use the same decoding as WhatsOnChain.

Solution

Added a new setting blockchain_raw_miner_tag (default: false) that controls whether miner tags are returned raw or sanitized.

When blockchain_raw_miner_tag=false (default)

Current behavior is preserved:

  • Non-printable UTF-8 characters are filtered out
  • Whitespace and quotes are trimmed
  • Text before the first / is removed
  • Text is truncated after the 2nd slash

When blockchain_raw_miner_tag=true

Raw coinbase arbitrary text is returned without any processing, preserving binary data.

Changes

New Setting

  • blockchain_raw_miner_tag in BlockChainSettings - controls miner tag sanitization

New Function

  • ExtractCoinbaseMinerRaw(coinbaseTx *bt.Tx, raw bool) - extracts miner with optional raw mode
  • Original ExtractCoinbaseMiner() preserved for backward compatibility (calls new function with raw=false)

Updated Components

  • SQL Store (stores/blockchain/sql/): All miner extraction points now use the setting
    • block_helpers.go
    • GetBlockHeader.go
    • GetBlockHeaders.go
    • GetBestBlockHeader.go
    • GetLatestHeaderFromBlockLocator.go
  • Centrifuge (services/asset/centrifuge_impl/centrifuge.go): WebSocket block notifications use the setting

Tests

  • Added TestExtractCoinbaseMinerRaw - verifies both raw and sanitized modes
  • Added TestExtractCoinbaseMinerRawPreservesAllBytes - verifies raw mode preserves all bytes including binary data

Usage

To enable raw miner tags (to match WhatsOnChain behavior):

blockchain_raw_miner_tag=true

Testing

All existing tests pass, new tests added for raw mode extraction.

@freemans13 freemans13 self-assigned this Jan 28, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

🤖 Claude Code Review

Status: Complete

No issues found. The implementation is clean and well-tested:

  • Adds optional raw miner tag mode with backward-compatible API design
  • Setting properly documented with detailed longdesc
  • Comprehensive test coverage including binary data edge cases
  • All call sites consistently updated across the codebase
  • Default behavior preserved (sanitized output)

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant