Skip to content

Conversation

@lcovar
Copy link
Contributor

@lcovar lcovar commented Jan 29, 2026

Summary

  • Changed buildTransaction() to return Transaction instead of Uint8Array
  • Changed buildFromVersionedData() to return VersionedTransaction instead of Uint8Array
  • Added fromWasm() factory methods to Transaction and VersionedTransaction classes
  • Callers that need bytes can simply call .toBytes() on the result

This addresses feedback from PR #113 to return rich Transaction objects that can be inspected before serializing, which is more ergonomic.

Test plan

  • All 90 existing tests pass
  • Updated tests to use new return types

Changed buildTransaction() and buildFromVersionedData() to return
Transaction and VersionedTransaction objects instead of raw bytes.
This allows callers to inspect the transaction before serializing,
which is more ergonomic and matches the existing Transaction API.

Callers that need bytes can simply call .toBytes() on the result.
@lcovar lcovar requested a review from a team as a code owner January 29, 2026 19:19
const txBytes = buildTransaction(intent);
const tx = buildTransaction(intent);
const txBytes = tx.toBytes();
const parsed = parseTransaction(txBytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

why not parse the tx directly instead of going through the byte representation here?

you can widen parseTransaction so that accepts both Transaction or bytes for convenience

Copy link
Contributor Author

Choose a reason for hiding this comment

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

smort

parseTransaction now accepts Uint8Array, Transaction, or VersionedTransaction
directly, avoiding the need for callers to explicitly call .toBytes() when
parsing a transaction that was just built.

Ticket: BTC-2988
@lcovar lcovar merged commit 41607f8 into master Feb 2, 2026
6 checks passed
@lcovar lcovar deleted the BTC-2988 branch February 2, 2026 18:43
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