Skip to content

get_network() doesn't recognize testnet4 chain (Bitcoin Core 28.0+) #108

@al-munazzim

Description

@al-munazzim

Summary

Bitcoin Core 28.0+ introduces testnet4 with chain name testnet4 (returned by getblockchaininfo). Currently, embit's get_network('testnet4') doesn't recognize this chain and falls back to elementsregtest, which has bech32 prefix ert.

This causes applications using embit to generate Liquid addresses (ert1...) instead of testnet4 addresses (tb1...), which Bitcoin Core then rejects.

Reproduction

from embit.liquid.networks import get_network

net = get_network('testnet4')
print(net['bech32'])  # Prints 'ert' instead of expected 'tb'

Expected behavior

get_network('testnet4') should return a network dict with:

  • bech32: 'tb' (same as testnet)
  • bip32: {'public': 0x043587cf, 'private': 0x04358394} (tpub/tprv)
  • Appropriate WIF prefix etc.

Or at minimum, raise an explicit error for unknown chains rather than silently defaulting to elementsregtest.

Context

This was discovered in specter-desktop#2516. A workaround is being added in specter-desktop#2537, but the proper fix belongs in embit.

Proposed fix

Add testnet4 to the networks dict, reusing testnet parameters (since testnet4 uses the same address formats as testnet3):

# In networks.py or equivalent
NETWORKS['testnet4'] = NETWORKS['test'].copy()  # Or define explicitly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions