Skip to content

Conversation

@BlobMaster41
Copy link
Contributor

@BlobMaster41 BlobMaster41 commented Jan 15, 2026

Witness Malleability Ordering Attack

Attack Mechanics

You're a miner. You create TX-Alpha-W1 and TX-Alpha-W2, same txid, different wtxid. You include both in the same block you mine. Bitcoin doesn't care, both are valid transactions with different wtxids, and Bitcoin deduplicates by wtxid not txid at the block level.

If OPNet orders by txid, it now has two transactions with identical ordering keys. The priority queue or sorting logic has two entries that compare equal on txid. The behavior is undefined or implementation-dependent, different nodes might process them in different orders based on insertion order, memory layout, or however the sort handles duplicates.

Potential Outcome

Consensus divergence. Some nodes execute W1 first, some execute W2 first. If contract state depends on execution order, network splits.

@BlobMaster41 BlobMaster41 force-pushed the feat/potential-exploit-txid branch from a10859c to 981a532 Compare January 15, 2026 01:50
Replaces usage of transactionIdString with transactionHashString throughout transaction processing and sorting logic. Adds txHashHex and transactionHashString properties to Transaction class for consistent access. Updates package.json to use @datastructures-js/priority-queue v6.3.5.

Add separate tsconfig for tests and update main config

Created tests/tsconfig.json to handle test files with noEmit option. Removed test file patterns from the main tsconfig.json 'include' array to separate configuration concerns.

Refactor TransactionSorter tests and update tsconfig includes

Replaces TransactionSorter tests with more comprehensive and deterministic test cases, focusing on witness malleability and dependency ordering. Removes tests/tsconfig.json and updates main tsconfig.json to include tests directory. Minor formatting and import cleanup in BlockIndexer.ts and vitest.config.ts.

Add transaction reindexing feature and sorting improvements

Introduces a transaction reindexing mode to reorder generic transactions within blocks, including new config options and validation. Refactors transaction sorting to use a generic interface, adds dependency-aware sorting, and updates storage interfaces for batch index updates. Also adds new files for transaction reindexing logic and sortable transaction abstraction.
@BlobMaster41 BlobMaster41 force-pushed the feat/potential-exploit-txid branch from e5bd5a7 to 8cb1bf1 Compare January 15, 2026 02:03
Replaces non-null assertions with optional chaining in test files, extracts mock functions to avoid unbound-method warnings, and updates some test expectations for better type compatibility. Also formats the tests/tsconfig.json file for consistency.
Expanded TransactionSorter tests to cover various dependency and fee scenarios, including complex dependency trees, equal-fee sorting, and parent-child relationships. Introduced helper functions and new-style tests using the Transaction class to ensure correct transaction ordering logic.
Updated TransactionSorter tests to use 32-byte hex strings for txid and wtxid, ensuring deterministic ordering by computedIndexingHash. Adjusted test cases to reflect new input format and improved assertions for dependency and fee-based sorting.
@BlobMaster41 BlobMaster41 changed the title Refactor transaction ID usage to use transaction hash Potential Witness Malleability Ordering Attack Jan 15, 2026
@BlobMaster41 BlobMaster41 requested a review from matbout January 15, 2026 08:15
@BlobMaster41 BlobMaster41 marked this pull request as draft January 17, 2026 07:03
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