Skip to content

XOnlyPublicKey (Class)

An x-only public key (32 bytes, Schnorr compatible).

Used for Schnorr signatures and Taproot-style addresses.

__new__

__new__(key: str) -> XOnlyPublicKey

Create an x-only public key from a hex string.

PARAMETER DESCRIPTION
key

A 64-character hex string.

TYPE: str

RETURNS DESCRIPTION
XOnlyPublicKey

A new XOnlyPublicKey instance.

TYPE: XOnlyPublicKey

RAISES DESCRIPTION
Exception

If the hex string is invalid.

from_address staticmethod

from_address(address: Address) -> XOnlyPublicKey

Extract an x-only public key from an address.

PARAMETER DESCRIPTION
address

A Kaspa address.

TYPE: Address

RETURNS DESCRIPTION
XOnlyPublicKey

The extracted public key.

TYPE: XOnlyPublicKey

RAISES DESCRIPTION
Exception

If extraction fails.

to_address

to_address(network: str | NetworkType) -> Address

Derive a Schnorr address from this x-only public key.

PARAMETER DESCRIPTION
network

The network type for address encoding.

TYPE: str | NetworkType

RETURNS DESCRIPTION
Address

The derived Schnorr address.

TYPE: Address

to_address_ecdsa

to_address_ecdsa(network: str | NetworkType) -> Address

Derive an ECDSA address from this x-only public key.

PARAMETER DESCRIPTION
network

The network type for address encoding.

TYPE: str | NetworkType

RETURNS DESCRIPTION
Address

The derived ECDSA address.

TYPE: Address

to_string

to_string() -> str

Convert to hex string representation.

RETURNS DESCRIPTION
str

The x-only public key as a hex string.

TYPE: str