feat(bitcoin): Increase OP_RETURN size limit to match Bitcoin Core v30 #4623
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