Skip to content

Improve type safety in RBF service by replacing any types with proper interfaces#461

Merged
jamespepper81 merged 4 commits into
mainfrom
dev
Jan 11, 2026
Merged

Improve type safety in RBF service by replacing any types with proper interfaces#461
jamespepper81 merged 4 commits into
mainfrom
dev

Conversation

@jamespepper81
Copy link
Copy Markdown
Contributor

This pull request enhances type safety and robustness in the RBF (Replace-By-Fee) service, especially around Esplora transaction handling and ECC library validation. The changes introduce stricter TypeScript interfaces, improve error handling, and add future-proofing notes for Bitcoin transaction building.

Type safety and interface improvements:

  • Introduced new TypeScript interfaces for Esplora transactions, including EsploraTransaction, EsploraTransactionVin, and EsploraTransactionVout, and updated all relevant usages in the RBF service to use these types instead of any. This makes the code more robust and easier to maintain. [1] [2]
  • Updated the ECC library validation function to use a strongly-typed ECCLibrary interface, improving clarity and reducing the risk of runtime errors.

Error handling and robustness:

  • Improved input validation when deriving addresses for transaction inputs by checking for missing address information and throwing a descriptive error if absent.
  • Added nullish coalescing (?? 0) when summing output values, ensuring that missing or undefined values do not cause calculation errors. [1] [2]
  • Updated the parseSequenceNumber function to use a stricter type signature (unknown), improving type safety.

Developer guidance:

  • Added comments noting that TransactionBuilder is deprecated and suggesting migration to PSBT for future compatibility with bitcoinjs-lib. [1] [2]

Dependency update:

  • Updated the @types/node development dependency to version ^24.10.7 in package.json.

Copilot AI and others added 4 commits January 11, 2026 23:04
- Add ECCLibrary interface for ecc parameter
- Add EsploraTransaction interfaces for transaction types
- Change parseSequenceNumber parameter from any to unknown
- Add deprecation comment for TransactionBuilder

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
- Update tsconfig.json to include ES2015+ and DOM libs
- Install @types/node for Node.js type definitions
- Add null/undefined checks in rbf-service.ts
- Fix all TypeScript compilation errors without changing functionality

Co-authored-by: jamespepper81 <84083764+jamespepper81@users.noreply.github.com>
Improve type safety in RBF service by replacing `any` types with proper interfaces
@jamespepper81 jamespepper81 merged commit c7e1c1a into main Jan 11, 2026
12 of 13 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