Skip to content

Commit b1ad24d

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): add helper to create OP_RETURN output scripts
Add utility function that creates OP_RETURN output scripts with optional data payload. This supports both empty OP_RETURN scripts and ones with custom data. Issue: BTC-2980 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent 2b9bc51 commit b1ad24d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

  • packages/wasm-utxo/js/fixedScriptWallet

packages/wasm-utxo/js/fixedScriptWallet/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,23 @@ import type { ScriptType } from "./scriptType.js";
6161
export function supportsScriptType(coin: CoinName, scriptType: ScriptType): boolean {
6262
return FixedScriptWalletNamespace.supports_script_type(coin, scriptType);
6363
}
64+
65+
/**
66+
* Create an OP_RETURN output script with optional data
67+
*
68+
* @param data - Optional data bytes to include in the OP_RETURN script
69+
* @returns The OP_RETURN script as a Uint8Array
70+
*
71+
* @example
72+
* ```typescript
73+
* // Empty OP_RETURN
74+
* const script = createOpReturnScript();
75+
*
76+
* // OP_RETURN with data
77+
* const data = new Uint8Array([1, 2, 3, 4]);
78+
* const script = createOpReturnScript(data);
79+
* ```
80+
*/
81+
export function createOpReturnScript(data?: Uint8Array): Uint8Array {
82+
return FixedScriptWalletNamespace.create_op_return_script(data);
83+
}

0 commit comments

Comments
 (0)