Skip to content

Add to_le_bytes and to_be_bytes helpers to U256 (Fixes #2065)#2080

Open
therohityadav wants to merge 1 commit intostratum-mining:mainfrom
therohityadav:feature/issue-2065-clean
Open

Add to_le_bytes and to_be_bytes helpers to U256 (Fixes #2065)#2080
therohityadav wants to merge 1 commit intostratum-mining:mainfrom
therohityadav:feature/issue-2065-clean

Conversation

@therohityadav
Copy link
Copy Markdown

Description

This PR adds to_le_bytes and to_be_bytes helper methods to the U256 struct, resolving issue #2065.

These helpers simplify converting U256 to byte arrays (little-endian and big-endian) and remove the need for repetitive try_into().expect(...) calls throughout the codebase.

Changes

  • Added to_le_bytes(&self) -> [u8; 32]
  • Added to_be_bytes(&self) -> [u8; 32]
  • Added test_u256_endianness unit test to verify correct byte order.

Verification

  • Ran cargo test -p binary_sv2 (All tests passed locally).

@therohityadav therohityadav force-pushed the feature/issue-2065-clean branch from 1bc68bc to d980e5e Compare February 10, 2026 08:41
@therohityadav therohityadav force-pushed the feature/issue-2065-clean branch from d980e5e to 0745282 Compare February 10, 2026 09:31
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.

1 participant