cashscript_py.interfaces module

Shared interfaces and simple data models used across the public API.

class ContractUnlocker(generate_locking_bytecode: Callable[[], bytes], generate_unlocking_bytecode: Callable[[Transaction, list[Output], int], bytes], contract: cashscript_py.Contract, params: list[FunctionArgument], abi_function: dict[str, Any])[source]

Bases: Unlocker

Unlocker associated with a Contract ABI function and its parameters.

class HashType(*values)[source]

Bases: Flag

Supported SIGHASH flags.

SIGHASH_ALL = 1
SIGHASH_ANYONECANPAY = 128
SIGHASH_FORKID = 64
SIGHASH_NONE = 2
SIGHASH_SINGLE = 3
SIGHASH_UTXOS = 32
class NftCapability(*values)[source]

Bases: StrEnum

NFT CashTokens capabilities.

MINTING = 'minting'
MUTABLE = 'mutable'
NONE = 'none'
class Output(to: bytes | str, amount: int, token: TokenDetails | None = None)[source]

Bases: object

Transaction output description.

to

Recipient locking bytecode (bytes) or CashAddress (str).

amount

BCH amount in satoshis.

token

Optional CashToken details.

class SignatureAlgorithm(*values)[source]

Bases: Flag

Supported signature algorithms.

ECDSA = 0
SCHNORR = 1
class TokenDetails(amount: int | None, category: str, nft: Nft | None)[source]

Bases: object

CashToken details: fungible amount and optional NFT.

class Nft(capability: NftCapability, commitment: str | None)[source]

Bases: object

Nested NFT metadata.

class Transaction(inputs: list[UnlockableUtxo], locktime: int, outputs: list[Output], version: int)[source]

Bases: object

Simple transaction template used for signing and serialization.

class TransactionDetails(inputs: list[UnlockableUtxo], locktime: int, outputs: list[Output], version: int)[source]

Bases: Transaction

Transaction including txid and hex representation.

hex: str
txid: str
class UnlockableUtxo(txid: str, vout: int, satoshis: int, token: TokenDetails | None, unlocker: Unlocker, sequence: int | None)[source]

Bases: Utxo

Utxo extended with an unlocker and optional input options.

classmethod from_utxo(utxo: Utxo, unlocker: Unlocker, sequence: int | None) UnlockableUtxo[source]

Construct an UnlockableUtxo from a plain Utxo and an Unlocker.

sequence: int | None
unlocker: Unlocker
class Unlocker(generate_locking_bytecode: Callable[[], bytes], generate_unlocking_bytecode: Callable[[Transaction, list[Output], int], bytes])[source]

Bases: object

Unlocker providing locking/unlocking bytecode generators.

class Utxo(txid: str, vout: int, satoshis: int, token: TokenDetails | None = None)[source]

Bases: object

Spendable output reference with optional CashToken details.

classmethod from_unspent(unspent: Unspent) Utxo[source]

Convert a bitcash Unspent to a Utxo, mapping CashToken/NFT details.

Parameters:

unspent – bitcash Unspent instance.

Returns:

Converted UTXO.

Return type:

Utxo