Skip to content

refactor(abstract-utxo): delete fetchInputs and remove redundant fee guard#8916

Merged
OttoAllmendinger merged 1 commit into
masterfrom
otto/drop-fetchinputs
Jun 10, 2026
Merged

refactor(abstract-utxo): delete fetchInputs and remove redundant fee guard#8916
OttoAllmendinger merged 1 commit into
masterfrom
otto/drop-fetchinputs

Conversation

@OttoAllmendinger

@OttoAllmendinger OttoAllmendinger commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacks on otto/abstract-utxo-foundation.

Two related cleanups enabled by the dead-code removal in the parent PR:

  1. Delete fetchInputs.tsgetTxInputs and getPsbtTxInputs are no longer called anywhere after the dead code removal in the parent PR. The file and its barrel export are deleted.

  2. Remove fee guard from verifyTransaction — the inputAmount - outputAmount < 0 check in fixedScript/verifyTransaction.ts is unreachable dead code. The PSBT path calls psbt.parseTransactionWithWalletKeys (wasm), whose Rust implementation uses checked_sub to compute miner_fee and returns ParseTransactionError::FeeCalculation ("Fee calculation error: outputs exceed inputs") if total output value exceeds total input value — this fires before the TypeScript guard would ever execute.

PR group context

Stack: master → abstract-utxo-foundation → this PR → abstract-utxo-replacements → keychains-drop-utxolib → abstract-utxo-terminal

Test plan

  • New unit test in test/unit/transaction/fixedScript/explainPsbt.ts: tampers a PSBT's witnessUtxo.value to make outputs exceed inputs and asserts explainPsbtWasmBigInt throws /Fee calculation error: outputs exceed inputs/ — proving the wasm layer enforces the invariant before the deleted TypeScript guard would have run
  • yarn tsc --noEmit clean in modules/abstract-utxo
  • yarn lint clean in modules/abstract-utxo
  • All abstract-utxo unit tests pass

🤖 Generated with Claude Code

@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner June 2, 2026 08:51
@OttoAllmendinger OttoAllmendinger marked this pull request as draft June 2, 2026 08:57
@OttoAllmendinger OttoAllmendinger changed the title refactor(abstract-utxo): eliminate fetchInputs and remove fee guard [STACK psvytnwm] refactor(abstract-utxo): eliminate fetchInputs by reusing explainPsbtWasm inputAmount Jun 2, 2026
@OttoAllmendinger OttoAllmendinger force-pushed the otto/abstract-utxo-foundation branch from f3ecc52 to 3454b9d Compare June 9, 2026 08:54
@OttoAllmendinger OttoAllmendinger force-pushed the otto/drop-fetchinputs branch from b088a74 to 7e020d6 Compare June 9, 2026 08:59
@OttoAllmendinger OttoAllmendinger changed the title [STACK psvytnwm] refactor(abstract-utxo): eliminate fetchInputs by reusing explainPsbtWasm inputAmount refactor(abstract-utxo): eliminate fetchInputs by reusing explainPsbtWasm inputAmount Jun 9, 2026
@OttoAllmendinger OttoAllmendinger changed the base branch from otto/abstract-utxo-foundation to master June 9, 2026 13:25
@OttoAllmendinger OttoAllmendinger force-pushed the otto/drop-fetchinputs branch from 7e020d6 to 52032dc Compare June 9, 2026 13:27
…guard

Two related cleanups enabled by dead-code removal in the parent PR:

1. **Delete fetchInputs.ts** — getTxInputs and getPsbtTxInputs are no
   longer called anywhere after the parent PR's dead-code removal.

2. **Remove fee guard from verifyTransaction** — the
   `inputAmount - outputAmount < 0` check in
   fixedScript/verifyTransaction.ts is unreachable dead code. The PSBT
   path calls psbt.parseTransactionWithWalletKeys (wasm), whose Rust
   implementation uses checked_sub to compute miner_fee and returns
   ParseTransactionError::FeeCalculation ("Fee calculation error: outputs
   exceed inputs") if total output value exceeds total input value. This
   fires before the TypeScript guard would ever run. A new unit test in
   test/unit/transaction/fixedScript/explainPsbt.ts verifies this: it
   tampers a PSBT's witnessUtxo.value to make outputs > inputs and
   asserts that explainPsbtWasmBigInt throws with that message.

Refs: T1-3279
@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review June 10, 2026 09:52
@OttoAllmendinger OttoAllmendinger changed the title refactor(abstract-utxo): eliminate fetchInputs by reusing explainPsbtWasm inputAmount refactor(abstract-utxo): delete fetchInputs and remove redundant fee guard Jun 10, 2026
@OttoAllmendinger OttoAllmendinger merged commit c3a2638 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.

2 participants