pyrxd.script — Script types and evaluation

Script types, templates, and evaluation for Radiant transactions.

class pyrxd.script.P2PK[source]

Bases: ScriptTemplate

lock(public_key)[source]

from public key in format str or bytes

Parameters:

public_key (str | bytes)

Return type:

Script

unlock(private_key)[source]
Returns:

sign (function), estimated_unlocking_byte_length (function)

Parameters:

private_key (PrivateKey)

class pyrxd.script.P2PKH[source]

Bases: ScriptTemplate

lock(addr)[source]

from address (str) or public key hash160 (bytes)

Parameters:

addr (str | bytes)

Return type:

Script

unlock(private_key)[source]
Returns:

sign (function), estimated_unlocking_byte_length (function)

Parameters:

private_key (PrivateKey)

class pyrxd.script.BareMultisig[source]

Bases: ScriptTemplate

lock(participants, threshold)[source]
Returns:

locking script

Parameters:
Return type:

Script

unlock(private_keys)[source]
Returns:

sign (function), estimated_unlocking_byte_length (function)

Parameters:

private_keys (list[PrivateKey])

class pyrxd.script.OpReturn[source]

Bases: ScriptTemplate

lock(pushdatas)[source]
Returns:

locking script

Parameters:

pushdatas (list[str | bytes])

Return type:

Script

unlock(**kwargs)[source]
Returns:

sign (function), estimated_unlocking_byte_length (function)

class pyrxd.script.Script[source]

Bases: object

__init__(script=None)[source]

Create script from hex string or bytes

Parameters:

script (str | bytes | None)

byte_length()[source]
Return type:

int

byte_length_varint()[source]
Return type:

bytes

classmethod find_and_delete(source, pattern)[source]
Parameters:
Return type:

Script

classmethod from_asm(asm)[source]
Parameters:

asm (str)

Return type:

Script

classmethod from_chunks(chunks)[source]
Parameters:

chunks (list[ScriptChunk])

Return type:

Script

hex()[source]
Return type:

str

is_push_only()[source]

Checks if the script contains only push data operations. :return: True if the script is push-only, otherwise false.

Return type:

bool

serialize()[source]
Return type:

bytes

size()
Return type:

int

size_varint()
Return type:

bytes

to_asm()[source]
Return type:

str

classmethod write_bin(octets)[source]
Parameters:

octets (bytes)

Return type:

Script

class pyrxd.script.ScriptChunk[source]

Bases: object

A representation of a chunk of a script, which includes an opcode. For push operations, the associated data to push onto the stack is also included.

__init__(op, data=None)[source]
Parameters:
class pyrxd.script.ScriptTemplate[source]

Bases: object

abstractmethod lock(*args, **kwargs)[source]
Returns:

locking script

Return type:

Script

abstractmethod unlock(*args, **kwargs)[source]
Returns:

sign (function), estimated_unlocking_byte_length (function)

Return type:

UnlockingScriptTemplate

class pyrxd.script.Unknown[source]

Bases: ScriptTemplate

lock(**kwargs)[source]
Returns:

locking script

Return type:

Script

unlock(**kwargs)[source]
Returns:

sign (function), estimated_unlocking_byte_length (function)