Skip to content

Exception

KernelException

Bases: Exception

Base class for errors emitted by this library.

Source code in pbk/util/exc.py
1
2
3
4
class KernelException(Exception):
    """Base class for errors emitted by this library."""

    pass

ProcessBlockException

Bases: KernelException

Raised when ChainstateManager fails to process a block.

Source code in pbk/util/exc.py
class ProcessBlockException(KernelException):
    """Raised when ChainstateManager fails to process a block."""

    def __init__(self, code: int):
        """Create a block processing exception.

        Args:
            code: The error code returned by the C API.
        """
        self.code = code
        super().__init__(f"Block processing failed with error code {code}")

code instance-attribute

code = code

__init__

__init__(code: int)

Create a block processing exception.

PARAMETER DESCRIPTION
code

The error code returned by the C API.

TYPE: int

Source code in pbk/util/exc.py
def __init__(self, code: int):
    """Create a block processing exception.

    Args:
        code: The error code returned by the C API.
    """
    self.code = code
    super().__init__(f"Block processing failed with error code {code}")

ScriptVerifyException

Bases: KernelException

Exception raised when script verification fails.

This exception is raised by the ScriptPubkey.verify function when a script does not pass validation. The exception includes a status code that provides details about why verification failed.

ATTRIBUTE DESCRIPTION
status

The status code indicating the failure reason.

TYPE: ScriptVerifyStatus

Source code in pbk/script.py
class ScriptVerifyException(KernelException):
    """Exception raised when script verification fails.

    This exception is raised by the [ScriptPubkey.verify][pbk.ScriptPubkey.verify]
    function when a script does not pass validation. The exception includes a
    status code that provides details about why verification failed.

    Attributes:
        status: The status code indicating the failure reason.
    """

    status: ScriptVerifyStatus

    def __init__(self, status: ScriptVerifyStatus):
        """Create a script verification exception.

        Args:
            status: The verification status code indicating the failure reason.
        """
        super().__init__(f"Script verification failed: {status.name}")
        self.status = status

status instance-attribute

status: ScriptVerifyStatus = status

__init__

__init__(status: ScriptVerifyStatus)

Create a script verification exception.

PARAMETER DESCRIPTION
status

The verification status code indicating the failure reason.

TYPE: ScriptVerifyStatus

Source code in pbk/script.py
def __init__(self, status: ScriptVerifyStatus):
    """Create a script verification exception.

    Args:
        status: The verification status code indicating the failure reason.
    """
    super().__init__(f"Script verification failed: {status.name}")
    self.status = status