feat(bitcoin): Increase OP_RETURN size limit to match Bitcoin Core v30#4623
Open
EricGrill wants to merge 1 commit intotrustwallet:masterfrom
Open
feat(bitcoin): Increase OP_RETURN size limit to match Bitcoin Core v30#4623EricGrill wants to merge 1 commit intotrustwallet:masterfrom
EricGrill wants to merge 1 commit intotrustwallet:masterfrom
Conversation
Bitcoin Core v30 increased the default -datacarriersize from 83 to 10000 bytes. This change updates wallet-core to support larger OP_RETURN payloads. Changes: - Update MaxOpReturnLength from 80 to 10000 bytes (C++) - Update OP_RETURN_DATA_LIMIT from 80 to 10000 bytes (Rust) - Extend pushDataLength() to support OP_PUSHDATA2 for data > 255 bytes - Remove outdated 83-byte assertion in buildOpReturnScript() - Add comprehensive tests for larger OP_RETURN data sizes Fixes trustwallet#4548 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
sergei-boiko-trustwallet
requested changes
Jan 14, 2026
Contributor
sergei-boiko-trustwallet
left a comment
There was a problem hiding this comment.
LGTM! But to be able to merge the PR, could you please add one test with a successfully broadcasted transaction on mainnet? You should generate a new private key, top up with ONLY required funds, and spend the entire balance before publishing the changes into the PR. That's needed to avoid funds loss.
Please add a comment like // Successfully broadcasted tx: https://...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-datacarriersizepushDataLength()function in C++ to supportOP_PUSHDATA2for data larger than 255 bytesBackground
Bitcoin Core v30 increased the default
-datacarriersizefrom 83 to 10,000 bytes. Transactions with OP_RETURN outputs larger than 80 bytes that are valid under Bitcoin Core 30 were failing to build in wallet-core due to hardcoded limits.Changes
C++ Code:
src/Bitcoin/Script.h: UpdatedMaxOpReturnLengthfrom 80 to 10000src/Bitcoin/Script.cpp: ExtendedpushDataLength()to handle sizes > 255 bytes usingOP_PUSHDATA2, removed 83-byte assertionRust Code:
rust/frameworks/tw_utxo/src/transaction/standard_transaction/builder/output.rs: UpdatedOP_RETURN_DATA_LIMITfrom 80 to 10000rust/frameworks/tw_utxo/src/script/standard_script/conditions.rs: Updated capacity hint innew_op_return()Tests:
tests/chains/Bitcoin/BitcoinScriptTests.cpp: Added tests for 100, 255, 256, 1000, and 10000 byte OP_RETURN dataoutput.rsfor the same size rangesTest plan
buildOpReturnScript()with various data sizesOutputBuilder::op_return()with various data sizesFixes #4548
Generated with Claude Code