Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wally_scriptpubkey_get_type: only check 1st byte for OP_RETURN scripts #448

Merged

Conversation

LeoComandini
Copy link
Contributor

Even though a script might not be created with
wally_scriptpubkey_op_return_from_bytes (e.g. <OP_RETURN>) or it is not standard (e.g. <OP_RETURN OP_RETURN>), if it's starting with OP_RETURN, it should still be considered a OP_RETURN script.

Bitcoin Core checks [1]

    bool IsUnspendable() const
    {
        return (size() > 0 && *begin() == OP_RETURN) || (size() > MAX_SCRIPT_SIZE);
    }

rust-bitcoin does [2]

    pub fn is_op_return(&self) -> bool {
        match self.0.first() {
            Some(b) => *b == OP_RETURN.to_u8(),
            None => false,
        }
    }

[1] https://github.com/bitcoin/bitcoin/blob/d04324a7056a735c1127ba8ccdc720a16e7281a3/src/script/script.h#L552-L555

[2] https://github.com/rust-bitcoin/rust-bitcoin/blob/9df59639cec214bd9363d426335923611a304119/bitcoin/src/blockdata/script/borrowed.rs#L350-L354

Even though a script might not be created with
wally_scriptpubkey_op_return_from_bytes (e.g. <OP_RETURN>) or it
is not standard (e.g. <OP_RETURN OP_RETURN>), if it's starting with
OP_RETURN, it should still be considered a OP_RETURN script.
@jgriffiths
Copy link
Contributor

utack fcd39ce, will merge once the CI completes thanks.

@jgriffiths jgriffiths merged commit 1c6888e into ElementsProject:master Mar 27, 2024
4 checks passed
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