Skip to content

feat(wasm-utxo)!: add index-based PSBT/transaction mutation ops#190

Merged
OttoAllmendinger merged 2 commits intomasterfrom
BTC-3049.psbt-edit-support
Mar 4, 2026
Merged

feat(wasm-utxo)!: add index-based PSBT/transaction mutation ops#190
OttoAllmendinger merged 2 commits intomasterfrom
BTC-3049.psbt-edit-support

Conversation

@OttoAllmendinger
Copy link
Contributor

Add index-based insertion and removal methods to PSBT and transaction
types, enabling flexible construction and editing workflows. Also
restructure linting scripts for granular control over individual
linters.

Breaking Changes

  • All add_* methods now return Result<usize, String> consistently
  • addInput, addOutput, and related wallet methods may now throw
    errors for out-of-bounds indices
  • inputCount, outputCount, lockTime, and version changed from
    property accessors to methods (use () to call)
  • unsignedTxid renamed to unsignedTxId for consistency
  • IPsbtIntrospection renamed to IPsbt to reflect mutation support
  • IPsbtIntrospectionWithAddress renamed to IPsbtWithAddress
  • check-fmt now runs prettier and rustfmt instead of both formatters.
    Use lint for comprehensive checks including clippy.

New Features

  • addInputAtIndex/addOutputAtIndex for PSBTs and transactions
  • addWalletInputAtIndex/addWalletOutputAtIndex for wallet ops
  • addReplayProtectionInputAtIndex for replay protection
  • removeInput/removeOutput methods for PSBTs
  • New psbt_ops module with bounds-checked operations
  • Individual linting tasks for prettier, eslint, rustfmt, and clippy

Implementation

  • All append operations delegate to index variants at len()
  • Bounds checking ensures indices are <= len (allow append)
  • Consistent error handling across all mutation operations
  • Methods maintain PSBT/transaction invariants during mutation
  • Split monolithic lint commands into individual tasks for better control

Issue: BTC-3049

@OttoAllmendinger OttoAllmendinger force-pushed the BTC-3049.psbt-edit-support branch from c21a4ee to d60dbaa Compare March 4, 2026 14:34
OttoAllmendinger and others added 2 commits March 4, 2026 15:42
Add index-based insertion and removal methods to PSBT and transaction
types, enabling flexible construction and editing workflows.

## Breaking Changes
- All `add_*` methods now return `Result<usize, String>` consistently
- `addInput`, `addOutput`, and related wallet methods may now throw
  errors for out-of-bounds indices
- `inputCount`, `outputCount`, `lockTime`, and `version` changed from
  property accessors to methods (use `()` to call)
- `unsignedTxid` renamed to `unsignedTxId` for consistency
- `IPsbtIntrospection` renamed to `IPsbt` to reflect mutation support
- `IPsbtIntrospectionWithAddress` renamed to `IPsbtWithAddress`

## New Features
- `addInputAtIndex`/`addOutputAtIndex` for PSBTs and transactions
- `addWalletInputAtIndex`/`addWalletOutputAtIndex` for wallet ops
- `addReplayProtectionInputAtIndex` for replay protection
- `removeInput`/`removeOutput` methods for PSBTs
- New `psbt_ops` module with bounds-checked operations

## Implementation
- All append operations delegate to index variants at `len()`
- Bounds checking ensures indices are `<= len` (allow append)
- Consistent error handling across all mutation operations
- Methods maintain PSBT/transaction invariants during mutation

Co-authored-by: llm-git <llm-git@ttll.de>

Issue: BTC-3049
Split monolithic lint commands into individual tasks for prettier,
eslint, rustfmt, and clippy. This enables running specific linters
independently and provides better control over the linting workflow.

BREAKING CHANGE: `check-fmt` now runs prettier and rustfmt instead of
both formatters. Use `lint` for comprehensive checks including clippy.

Issue: BTC-XXXX

Co-authored-by: llm-git <llm-git@ttll.de>
@OttoAllmendinger OttoAllmendinger force-pushed the BTC-3049.psbt-edit-support branch from d60dbaa to 19d0182 Compare March 4, 2026 14:43
@OttoAllmendinger OttoAllmendinger marked this pull request as ready for review March 4, 2026 14:53
@OttoAllmendinger OttoAllmendinger requested a review from a team as a code owner March 4, 2026 14:53
@OttoAllmendinger OttoAllmendinger merged commit cfcddc0 into master Mar 4, 2026
12 checks passed
@OttoAllmendinger OttoAllmendinger deleted the BTC-3049.psbt-edit-support branch March 4, 2026 20:50
Comment on lines +205 to +212
addInputAtIndex(
index: number,
txid: string,
vout: number,
value: bigint,
script: Uint8Array,
sequence?: number,
): number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a jsdoc here

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