fix(wallet): enforce OP_RETURN standardness via try_add_data#456
Open
tharu-jwd wants to merge 1 commit intobitcoindevkit:masterfrom
Open
fix(wallet): enforce OP_RETURN standardness via try_add_data#456tharu-jwd wants to merge 1 commit intobitcoindevkit:masterfrom
tharu-jwd wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
Add TxBuilder::try_add_data which validates against Bitcoin Core standardness rules before adding an OP_RETURN output: - Data payload must not exceed 80 bytes (Bitcoin Core MAX_OP_RETURN_RELAY limits the scriptPubKey to 83 bytes, constraining the payload to 80 bytes) - At most one OP_RETURN output per transaction is permitted Add CreateTxError::OpReturnInvalidDataSize and CreateTxError::MultipleOpReturnOutputs error variants with links to the relevant Bitcoin Core policy source. Deprecate add_data in favour of try_add_data per the project deprecation policy. Closes #44
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.
add_datahas been silently accepting oversized payloads and multiple OP_RETURNs, both non-standard. Closes bitcoindevkit/bdk-tx#49.Adds
try_add_datathat validates at call-site and deprecatesadd_data:MAX_OP_RETURN_RELAY= 83 bytes total scriptPubKey)Two new
CreateTxErrorvariants:OpReturnInvalidDataSize(usize)andMultipleOpReturnOutputs.Deprecating rather than removing since this is a public API.
Checklist
All Submissions:
cargo fmtandcargo clippybefore committingNew Features: