Skip to content

Add testnet/regtest network detection to coinbase decoder#1578

Open
warioishere wants to merge 1 commit intobitaxeorg:masterfrom
warioishere:feature/testnet-address-detection
Open

Add testnet/regtest network detection to coinbase decoder#1578
warioishere wants to merge 1 commit intobitaxeorg:masterfrom
warioishere:feature/testnet-address-detection

Conversation

@warioishere
Copy link

@warioishere warioishere commented Feb 25, 2026

Summary

  • Detect network from user address prefix (bc1/tb1/bcrt1/m/n/2) and use correct bech32 HRP and base58 version bytes when decoding coinbase output addresses
  • Previously hardcoded to mainnet, causing testnet/regtest addresses to display with bc1 prefix instead of tb1/bcrt1
  • Add test cases for testnet (P2PKH, P2SH, P2WPKH, P2TR) and regtest (P2WPKH)
  • Remove duplicate function declarations in coinbase_decoder.h

Test plan

  • Verify mainnet addresses still decode correctly (existing tests pass)
  • Verify testnet bech32 addresses decode with tb1 prefix
  • Verify regtest bech32 addresses decode with bcrt1 prefix
  • Verify testnet P2PKH addresses start with m or n
  • Verify testnet P2SH addresses start with 2

warioishere added a commit to warioishere/ESP-Miner that referenced this pull request Feb 25, 2026
Detect network from user address prefix (bc1/tb1/bcrt1/m/n/2) and use
the correct bech32 HRP and base58 version bytes when decoding coinbase
output addresses. Previously hardcoded to mainnet ("bc", 0x00/0x05).

- P2PKH: 0x6F for testnet (m/n prefix) instead of 0x00
- P2SH: 0xC4 for testnet (2 prefix) instead of 0x05
- Bech32: "tb" for testnet, "bcrt" for regtest instead of "bc"
- Add test cases for testnet P2PKH, P2SH, P2WPKH, P2TR and regtest P2WPKH
- Remove duplicate function declarations in coinbase_decoder.h
@warioishere warioishere force-pushed the feature/testnet-address-detection branch from 10f6f87 to b4d256a Compare February 25, 2026 08:53
mutatrum added a commit to mutatrum/ESP-Miner that referenced this pull request Mar 3, 2026
…1578)

Author: wario_is_here <mario.hofmann@yourdevice.ch>
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