Skip to content

refactor(abstract-utxo): remove utxolib runtime dependency from abstractUtxoCoin#8915

Merged
OttoAllmendinger merged 7 commits into
masterfrom
otto/abstract-utxo-replacements
Jun 10, 2026
Merged

refactor(abstract-utxo): remove utxolib runtime dependency from abstractUtxoCoin#8915
OttoAllmendinger merged 7 commits into
masterfrom
otto/abstract-utxo-replacements

Conversation

@OttoAllmendinger

@OttoAllmendinger OttoAllmendinger commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes all @bitgo/utxo-lib runtime call sites from modules/abstract-utxo/src/abstractUtxoCoin.ts, replacing them with @bitgo/wasm-utxo or plain coinName-based equivalents. By the end of this PR, abstractUtxoCoin.ts carries no utxolib import at all.

Changes land in stack order (lowest first):

  1. remove createTransactionFromHex from AbstractUtxoCoin — the only remaining caller was the already-deleted fetchInputs; the Doge override just delegated to super. Removes the method and the stale sinon stubs from verifyTransaction tests.
  2. pass coinName directly to BitGoPsbt.fromBytesBitGoPsbt.fromBytes already accepts CoinName | UtxolibName, so the utxolib.getNetworkName round-trip in decode.ts is unnecessary. Drops the utxolib import from decode.ts.
  3. replace 3 utxolib network/script helperssupportsBlockTarget now compares coinName strings; isSupportedScriptType delegates to fixedScriptWallet.supportsScriptType (wasm-utxo); postProcessPrebuild drops the dead psbt-lite detection block and the allowNonSegwitSigningWithoutPrevTx flag (wasm-utxo signing never consulted it).
  4. migrate isValidAddress off utxolib.addressFormat — replaces toOutputScriptAndFormat / fromOutputScriptWithFormat with wasm-utxo's address.toOutputScriptWithCoin / fromOutputScriptWithCoin, detecting format by round-trip equality.
  5. replace utxolib.bitgo helpers and drop dead branchesisChainCode/scriptTypeForChainChainCode.is/ChainCode.scriptType (wasm-utxo); removes the unreachable UtxoPsbt branch in hasKeyPathSpendInput; inlines the 2-of-3 script type list instead of utxolib.outputScripts.scriptTypes2Of3; drops unused RootWalletKeys/UtxoNetwork re-exports.
  6. remove deprecated network getter and getNetworkFromCoinName — drops the deprecated coin.network getter from AbstractUtxoCoin and the getNetworkFromCoinName helper from names.ts. Tests that called coin.network now use a test-local getNetworkForCoinName(coin.name). With this, names.ts no longer depends on utxolib.
  7. inline ScriptType2Of3 type definition — replaces the utxolib.bitgo.outputScripts.ScriptType2Of3 type re-export with a local literal union ('p2sh' | 'p2shP2wsh' | 'p2wsh' | 'p2tr' | 'p2trMusig2'), removing the last utxolib type reference and the top-level utxolib import from abstractUtxoCoin.ts.

The downstream PR (#8986) updates keychains.ts; #8987 deletes wasmUtil.ts and demotes @bitgo/utxo-lib to devDependencies.

Followed by #8986

Test plan

  • yarn tsc --noEmit clean in modules/abstract-utxo
  • yarn lint clean in modules/abstract-utxo
  • All abstract-utxo unit tests pass

Refs: T1-3279

🤖 Generated with Claude Code

@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner June 2, 2026 08:23
@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-foundation branch from c011adb to f3ecc52 Compare June 2, 2026 08:51
@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-replacements branch from 4b8b110 to d5eb4fa Compare June 2, 2026 08:51
@OttoAllmendinger OttoAllmendinger changed the base branch from otto/abstract-utxo-foundation to otto/drop-fetchinputs June 2, 2026 08:51
@OttoAllmendinger OttoAllmendinger marked this pull request as draft June 2, 2026 08:58
@OttoAllmendinger OttoAllmendinger changed the title refactor(abstract-utxo): replace utxolib helpers with wasm/coinName equivalents [STACK nxrtmzsz] refactor(abstract-utxo): inline ScriptType2Of3 type definition Jun 2, 2026
lcovar
lcovar previously approved these changes Jun 2, 2026
@OttoAllmendinger OttoAllmendinger force-pushed the otto/drop-fetchinputs branch 2 times, most recently from 7e020d6 to 52032dc Compare June 9, 2026 13:27
@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-replacements branch from d5eb4fa to 88c632f Compare June 9, 2026 13:27
@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-replacements branch from 88c632f to 724080b Compare June 10, 2026 09:26
@OttoAllmendinger OttoAllmendinger changed the title [STACK nxrtmzsz] refactor(abstract-utxo): inline ScriptType2Of3 type definition refactor(abstract-utxo): inline ScriptType2Of3 type definition Jun 10, 2026
@OttoAllmendinger OttoAllmendinger changed the base branch from otto/drop-fetchinputs to master June 10, 2026 14:25
@OttoAllmendinger OttoAllmendinger dismissed lcovar’s stale review June 10, 2026 14:25

The base branch was changed.

@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-replacements branch from 724080b to 1e3a4b1 Compare June 10, 2026 14:27
…tUtxoCoin

The only remaining caller was the deleted fetchInputs and the doge override
that just delegated to super. Remove the method, drop the doge override, and
remove the now-unused createTransactionFromHex stubs from verifyTransaction tests.

Refs: T1-3279
BitGoPsbt.fromBytes accepts NetworkName = UtxolibName | CoinName, so the
round-trip through utxolib.getNetworkName is unnecessary. Drop the utxolib
import from decode.ts.

Refs: T1-3279
…h wasm/coinName equivalents

- supportsBlockTarget: compare coinName instead of utxolib network objects
- isSupportedScriptType: use fixedScriptWallet.supportsScriptType from wasm-utxo
- postProcessPrebuild: delete the psbt-lite detection block and the
  allowNonSegwitSigningWithoutPrevTx flag end-to-end (wasm-utxo signing is
  permissive by default and never read the flag)

Refs: T1-3279
…rmat

Replace utxolib.addressFormat.toOutputScriptAndFormat / fromOutputScriptWithFormat
with wasm-utxo's address.toOutputScriptWithCoin / fromOutputScriptWithCoin.
Detect address format by trying each candidate and checking which round-trips
byte-equal.

Refs: T1-3279
…branches

- isChainCode / scriptTypeForChain -> ChainCode.is / ChainCode.scriptType (wasm-utxo)
- hasKeyPathSpendInput: drop unreachable utxolib.bitgo.UtxoPsbt branch and
  isTransactionWithKeyPathSpendInput call (DecodedTransaction is now BitGoPsbt only)
- validAddressTypes: inline the 2-of-3 list instead of utxolib.outputScripts.scriptTypes2Of3
- Drop unused RootWalletKeys / UtxoNetwork type re-exports and the now-empty
  utxolib bitgo import

Three utxolib references remain in abstractUtxoCoin: the ScriptType2Of3 type
re-export, the deprecated network getter (still used by tests), and the top-level
utxolib import that backs both.

Refs: T1-3279
…orkFromCoinName

Drop the deprecated coin.network getter from AbstractUtxoCoin and the
getNetworkFromCoinName helper from names.ts. Tests that previously called
coin.network now call the test-local getNetworkForCoinName(coin.name) from
util/utxoCoins. With this, names.ts no longer depends on utxolib.

Refs: T1-3279
Replace the utxolib.bitgo.outputScripts.ScriptType2Of3 type re-export with
an inline literal union. The values are identical to the utxolib export
('p2sh' | 'p2shP2wsh' | 'p2wsh' | 'p2tr' | 'p2trMusig2').

This removes the last utxolib type reference and the top-level utxolib import
from abstractUtxoCoin.ts.

Refs: T1-3279
@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-replacements branch from 1e3a4b1 to ea0b137 Compare June 10, 2026 14:45
@OttoAllmendinger OttoAllmendinger changed the title refactor(abstract-utxo): inline ScriptType2Of3 type definition refactor(abstract-utxo): remove utxolib runtime dependency from abstractUtxoCoin Jun 10, 2026
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

T1-3279

@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review June 10, 2026 15:18
@OttoAllmendinger OttoAllmendinger merged commit 5576f3a into master Jun 10, 2026
22 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