Skip to content

Conversation

@brunocapelao
Copy link

Summary

Add support for creating OP_RETURN outputs in PSETs using the data:<hex> address format.

Motivation

When working with Simplicity transactions on Liquid, there are use cases where you need to embed arbitrary data in a transaction output, such as:

  • Protocol identifiers (e.g., SAID Protocol)
  • Metadata or commitments
  • Other application-specific data

Currently, simplicity pset create only supports regular addresses and the special fee keyword. This PR adds support for OP_RETURN outputs.

Usage

To create an OP_RETURN output, use the data: prefix followed by hex-encoded data:

{
  "address": "data:534149440101deadbeef",
  "asset": "6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d",
  "amount": 0
}

This will create a transaction output with the script:

OP_RETURN <534149440101deadbeef>

Implementation

  • Added OpReturnHexParse error variant for invalid hex data
  • Added pattern matching for addresses starting with data:
  • Uses elements::script::Builder to construct the OP_RETURN script

Testing

Tested on Liquid Testnet for creating transactions with embedded SAID Protocol identifiers.

Add support for creating OP_RETURN outputs in PSETs using the
'data:<hex>' address format.

Example usage:
  {"address": "data:534149440101...", "asset": "...", "amount": 0}

This is useful for embedding arbitrary data in Liquid transactions,
such as protocol identifiers (e.g., SAID Protocol) or other metadata.

The hex data following 'data:' is decoded and pushed after OP_RETURN
in the script pubkey.
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.

1 participant