From 930709157fbab2430bf2a695a85fbf640dfe4a38 Mon Sep 17 00:00:00 2001 From: brunocapelao Date: Tue, 6 Jan 2026 10:06:20 -0300 Subject: [PATCH] feat: add OP_RETURN output support for PSET creation Add support for creating OP_RETURN outputs in PSETs using the 'data:' 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. --- src/actions/simplicity/pset/create.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/actions/simplicity/pset/create.rs b/src/actions/simplicity/pset/create.rs index 20bb4db..22b02ba 100644 --- a/src/actions/simplicity/pset/create.rs +++ b/src/actions/simplicity/pset/create.rs @@ -29,6 +29,9 @@ pub enum PsetCreateError { #[error("confidential addresses are not yet supported")] ConfidentialAddressNotSupported, + + #[error("invalid OP_RETURN hex data: {0}")] + OpReturnHexParse(String), } #[derive(Deserialize)] @@ -127,6 +130,16 @@ pub fn pset_create(inputs_json: &str, outputs_json: &str) -> Result elements::Script::new(), + x if x.starts_with("data:") => { + // OP_RETURN output: "data:HEXDATA" + let hex_data = &x[5..]; + let data = hex::decode(hex_data) + .map_err(|e| PsetCreateError::OpReturnHexParse(e.to_string()))?; + elements::script::Builder::new() + .push_opcode(elements::opcodes::all::OP_RETURN) + .push_slice(&data) + .into_script() + } x => { let addr = x.parse::
().map_err(PsetCreateError::AddressParse)?; if addr.is_blinded() {