Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ ahash = "0.8.12"
bincode = "1.3.3"
faster-hex = "0.9.0"
futures = "0.3.31"
kaspa-addresses = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-bip32 = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-consensus-client = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-consensus-core = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-hashes = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-notify = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-rpc-core = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-txscript = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07", features = ["wasm32-sdk"]}
kaspa-utils = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-wallet-core = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-wallet-keys = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-wrpc-client = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "90dbf07" }
kaspa-addresses = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-bip32 = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-consensus-client = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-consensus-core = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-hashes = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-notify = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-rpc-core = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-txscript = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4", features = ["wasm32-sdk"]}
kaspa-utils = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-wallet-core = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-wallet-keys = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
kaspa-wrpc-client = { git = "https://github.com/kaspanet/rusty-kaspa.git", rev = "c53a83bf4" }
paste = "1.0"
pyo3 = { version = "0.27.1", features = ['multiple-pymethods'] }
pyo3-async-runtimes = { version = "0.27.0", features = ['tokio-runtime'] }
Expand Down
5 changes: 3 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ search:
- Enum `AccountKind` exposed to Python. Represents the account type (legacy, bip32, multisig, keypair, etc.).
- Wallet-specific exception classes populated into the `kaspa.exceptions` submodule, covering the rusty-kaspa wallet error variants (e.g. `WalletInsufficientFundsError`, `WalletAccountNotFoundError`, `WalletNotSyncedError`, etc.).
- Examples under `examples/wallet/` demonstrating wallet usage
- Wallet `sync-state` events now include an SMT-sync phase payload (`{processed, total}`), emitted while the node imports the pruning-point SMT state during IBD.
- TypedDicts for `RpcClient` subscription event payloads — `BlockAddedEvent`, `VirtualChainChangedEvent`, `FinalityConflictEvent`, `FinalityConflictResolvedEvent`, `UtxosChangedEvent`, `SinkBlueScoreChangedEvent`, `VirtualDaaScoreChangedEvent`, `PruningPointUtxoSetOverrideEvent`, `NewBlockTemplateEvent`, `ConnectEvent`, `DisconnectEvent` — and their notification body TypedDicts (`RpcBlockAddedNotification`, etc.) for typing event-listener callbacks.
- `RpcClient.get_block_reward_info(request)` — new RPC returning a block's reward info (header, block color, confirmation count, merging chain block hash, reward amount).
- `ScriptBuilder` covenant/engine flags: optional `covenants_enabled` and `sigop_script_units` arguments on `ScriptBuilder(...)` and `ScriptBuilder.from_script(...)`, plus read-only `covenants_enabled` / `sigop_script_units` properties (mirrors the WASM SDK's `ScriptBuilderOptions`).
- `Transaction.storage_mass` property and a `storageMass` key in the `Transaction` dict output (alongside the existing `mass`), mirroring the WASM SDK.
- Class `CovenantBinding` exposed to Python. Binds a transaction output to the covenant and the input authorizing its creation. Accepted as either an instance or a `{"authorizingInput": ..., "covenantId": ...}` dict wherever the bindings take a `CovenantBinding`.
- Class `GenesisCovenantGroup` exposed to Python. Describes a group of transaction outputs bound to a single covenant id, used with `Transaction.populate_genesis_covenants`.
- Class `GenesisCovenantGroup` exposed to Python. Describes a group of transaction outputs bound to a single covenant id, used with `Transaction.populate_genesis_covenants`. Constructible via `GenesisCovenantGroup(authorizing_input, outputs)`, with read/write `authorizing_input` and `outputs` properties.
- `Transaction.populate_genesis_covenants(groups)` — computes covenant ids and sets the bindings on the targeted outputs.
- Function `covenant_id(outpoint, auth_outputs)` exposed to Python. Computes a covenant id from the authorizing input outpoint and ordered auth outputs.
- `PaymentOutput.with_covenant(address, amount, covenant)` static method, plus an optional `covenant` key in `PaymentOutput` dicts.
Expand Down Expand Up @@ -66,7 +67,7 @@ search:
### Development
*Internal SDK changes — not visible through the Python package API.*

- Bumped the pinned `rusty-kaspa` dependency from `d290179` to `90dbf07` (v2.0.0, Toccata hardfork).
- Bumped the pinned `rusty-kaspa` dependency from `d290179` to `c53a83bf4` (which includes rusty-kaspa v2.0.0, Toccata hardfork).
- `py_error_map!` macro generating the wallet exception classes, the rusty-kaspa error → Python exception mapping, and `register_exceptions`. The mapping's `match` is exhaustive, so an upstream error variant addition fails the build until it is mapped.
- `IntoPyResult` trait for more ergonomic conversion of rusty-kaspa native errors into `PyResult`.
- `pyproject.toml`: set `python-source = "python"` and moved the package stub tree under `python/kaspa/` (`kaspa.pyi` → `python/kaspa/__init__.pyi`).
Expand Down
16 changes: 16 additions & 0 deletions python/kaspa/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,22 @@ class GenesisCovenantGroup:
Args:
value: The index of the transaction input authorizing the covenant.
"""
@property
def outputs(self) -> builtins.list[builtins.int]:
r"""
The indices of the transaction outputs bound to the covenant.

Returns:
list[int]: The output indices in this group.
"""
@outputs.setter
def outputs(self, value: builtins.list[builtins.int]) -> None:
r"""
Set the output indices.

Args:
value: The indices of the transaction outputs to bind to the covenant.
"""
def __new__(cls, authorizing_input: builtins.int, outputs: typing.Sequence[builtins.int]) -> GenesisCovenantGroup:
r"""
Create a new GenesisCovenantGroup.
Expand Down
35 changes: 17 additions & 18 deletions src/consensus/client/covenant.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::crypto::hashes::PyHash;
use kaspa_consensus_client::{CovenantBinding, GenesisCovenantGroup};
use kaspa_consensus_core::tx::GenesisCovenantGroup as CoreGenesisCovenantGroup;
use pyo3::{
prelude::*,
types::{PyAny, PyDict},
Expand Down Expand Up @@ -131,11 +130,7 @@ impl PyGenesisCovenantGroup {
/// GenesisCovenantGroup: A new GenesisCovenantGroup instance.
#[new]
pub fn constructor(authorizing_input: u16, outputs: Vec<u32>) -> Self {
// TODO this tmp construction process is temporary
// until client::GenesisCovenantGroup exposes new fn that takes rust native types
let tmp = CoreGenesisCovenantGroup::new(authorizing_input, outputs);
let inner = GenesisCovenantGroup::from(tmp);
Self(inner)
Self(GenesisCovenantGroup::new(authorizing_input, outputs))
}

/// The index of the transaction input authorizing the covenant.
Expand All @@ -153,19 +148,23 @@ impl PyGenesisCovenantGroup {
self.0.set_authorizing_input(value);
}

// TODO blocked until GenesisCovenantGroup exposes non-WASM `outputs` fns
// `GenesisCovenantGroup::outputs -> NumberArray` instead of Vec<u32> return type
// NumberArray is WASM type, we should not convert from that here.
// Better solution is that native GenesisCovenantGroup exposes native Rust getter/setter
// #[getter]
// pub fn get_outputs(&self) -> Vec<u32> {
// self.0.outputs.clone()
// }
/// The indices of the transaction outputs bound to the covenant.
///
/// Returns:
/// list[int]: The output indices in this group.
#[getter]
pub fn get_outputs(&self) -> Vec<u32> {
self.0.outputs()
}

// #[setter]
// pub fn set_outputs(&mut self, value: Vec<u32>) {
// self.0.outputs = value
// }
/// Set the output indices.
///
/// Args:
/// value: The indices of the transaction outputs to bind to the covenant.
#[setter]
pub fn set_outputs(&mut self, value: Vec<u32>) {
self.0.set_outputs(value);
}
}

impl From<GenesisCovenantGroup> for PyGenesisCovenantGroup {
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/core/tx/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl PyPaymentOutput {
self.0.address.address_to_string(),
self.0.amount,
match &self.0.covenant {
Some(covenant) => PyCovenantBinding::from(*covenant).__repr__(),
Some(covenant) => PyCovenantBinding::from(covenant.clone()).__repr__(),
None => "None".to_string(),
}
)
Expand Down
Loading