Skip to content

fix: show OP_RETURN outputs when reviewing a PSBT - #969

Open
habakan wants to merge 2 commits into
selfcustody:developfrom
habakan:fix/op-return-output
Open

habakan wants to merge 2 commits into
selfcustody:developfrom
habakan:fix/op-return-output

Conversation

@habakan

@habakan habakan commented Nov 3, 2026

Copy link
Copy Markdown

What is this PR for?

Fixes #965.

Reviewing a PSBT with an OP_RETURN output raised a TypeError in get_policy(), and past that a ValueError from address().
OP_RETURN outputs are now counted as spends and shown on their own "OP_RETURN:" screen, with the amount and the data in hex.
When the script is a single push the push opcode is dropped; otherwise every byte after OP_RETURN is shown.

There was no reply on the issue yet, so I went with showing them rather than refusing the PSBT.
I'm happy to switch to refusing instead if you prefer.
#968 keeps this fix separate, so this PR only covers the review crash.

The sat/vB estimate still leaves these outputs out, as it already does for script types it does not know.
uv run poe pre-commit passes. Not tested on a device.

Changes made to:

  • Code
  • Tests
  • Docs
  • CHANGELOG

Did you build the code and tested on device?

  • Yes, build and tested on

What is the purpose of this pull request?

  • Bug fix
  • New feature
  • Docs update
  • Other

They have no address, so reviewing a PSBT with one raised before anything was shown (selfcustody#965).

@qlrd qlrd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubt: what happens when the OP_RETURN is too big? could it be break UI/UX or even give it an attack if it is a malicious one?

Data over 80 bytes pushed the output amount off the smallest screen.
@habakan

habakan commented Nov 4, 2026

Copy link
Copy Markdown
Author

Thanks for question.
A long OP_RETURN doesn't crash or overflow the screen: the text is cut to fit and ends with an ellipsis.

But the amount comes after the data, so it was cut off.
Here is 80 bytes of data on the M5StickV simulator, before and after this change:

krux-op-return-80-bytes

I pushed a change that shows only the first 32 bytes of longer data, so the amount always fits.
If you'd prefer another limit, or the amount before the data, I'm happy to change it.

This branch has not been deployed

No deployments
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