• Returns the output script of an OP_NAME_DOI operation, which registers, transfers or updates a name on Doichain: OP_NAME_DOI <name> <value> OP_2DROP OP_DROP <owner's script>.

    Name and value are pushed with their length in bytes, never as a number opcode, so an empty value or a one-byte value such as 0x05 still makes a name script. Strings are encoded as UTF-8 exactly as given: normalize a name the way your application registers names (for example with name.normalize('NFC')).

    The owner's script decides who holds the name. Build it from an address with address.toOutputScript(address, networks.doichain), which also checks the network and the address type. Psbt signs name inputs held by P2PKH and P2WPKH scripts. A transaction with a name output needs version 0x7100: set it before anybody signs.

    Parameters

    • name: string | Buffer

      The name, at most MAX_NAME_LENGTH bytes.

    • value: string | Buffer

      The value, at most MAX_VALUE_LENGTH bytes. It may be empty.

    • owner: Buffer

      The output script of the holder.

    Returns Buffer

    The name output script.

    Example

    const output = nameops.nameDoiScript(
    name.normalize('NFC'),
    value,
    address.toOutputScript(holderAddress, networks.doichain),
    );
    psbt.setVersion(0x7100);
    psbt.addOutput({ script: output, value: 1_000_000 });

    Throws

    TypeError if the name or the value is too long, or if the owner's script is empty or carries a name itself.