Skip to content

Conversation

@OttoAllmendinger
Copy link
Contributor

This PR refactors how coin names are handled in the abstract-utxo module,
significantly improving type safety and simplifying the codebase.

Key changes:

  • Define coin name directly in coin class instead of deriving from network
  • Use type unions with template literals for testnet coin names
  • Add explicit testnet coin array and mapping functions to mainnet variants
  • Replace network-based helper functions with direct coin name operations
  • Improve type checking in wallet data validation
  • Add proper return type annotations for better IDE support

This is part of the effort to get rid of utxolib

BTC-2909

OttoAllmendinger and others added 7 commits January 7, 2026 17:42
Use a type union with template literals to derive testnet coin names from
mainnet names. Update validation function to check if name starts with 't'
followed by a valid mainnet coin name.

This now declares some testnets that may not really exists, but simplifies
the code and type definitions significantly.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
Refines and enhances type definitions throughout the abstract-utxo module.
Introduces cleaner naming conventions with `getCoinName` replacing
the deprecated `getChainFromNetwork` function. Adds proper return type
annotations to class methods for better static analysis and IDE support.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
Check that obj.coin is a string before testing if it's a valid UTXO coin name.
This prevents potential runtime errors when processing wallet data.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
This change makes coin name an explicit property of each coin class instead
of deriving it from the network. Coin classes now declare their name directly
with a readonly property, and the network is derived from the name instead.

This simplifies the constructor by removing the network parameter and
improves the type safety by making the relationship between coin name
and network explicit.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
Add explicit array of testnet coin names instead of deriving them with
string operations. Add getMainnetCoinName function to map any coin to its
mainnet variant, with special handling for Bitcoin testnet variants.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
Replace getFamilyFromNetwork with getMainnetCoinName to directly
determine the family name from the coin name without going through
the network.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
Replace the deprecated `getFullNameFromNetwork` with the new
`getFullNameFromCoinName` function that determines the full coin name
directly from the coin name rather than the network object.

Issue: BTC-2909

Co-authored-by: llm-git <llm-git@ttll.de>
@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review January 7, 2026 18:29
@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner January 7, 2026 18:29
@OttoAllmendinger OttoAllmendinger merged commit 03f6707 into master Jan 8, 2026
20 checks passed
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.

3 participants