Skip to content

Sync to kth/0.80.0 + full v2 regeneration of py-native bindings - #6

Merged
fpelliccioni merged 1 commit into
masterfrom
feature/sync-kth-0.80
Apr 21, 2026
Merged

Sync to kth/0.80.0 + full v2 regeneration of py-native bindings#6
fpelliccioni merged 1 commit into
masterfrom
feature/sync-kth-0.80

Conversation

@fpelliccioni

@fpelliccioni fpelliccioni commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Moves py-native off kth/0.79.0 and regenerates every Python wrapper through the v2 generator against the current C-API surface. Three layers in one PR because they cannot land separately without leaving the tree in a non-building intermediate state (bumping conan alone breaks the build, regenerating alone doesn't relink module.c, fixing chain.cpp alone doesn't compile against the renamed types…).

1. Conan + build plumbing

  • conanfile.pykth/0.80.0 (was 0.79.0).
  • setup.py sources list now reflects the full generated surface (binary + new chain classes + new wallet classes). src/chain/history.cpp is out of sources — the generator covers that surface via history_compact + history_compact_list. chain.cpp stays (async-callback bridge to safe_chain, doesn't fit ClassConfig).
  • scripts/build-nix.sh — new NixOS-only wrapper: resolves gcc.cc.lib into LD_LIBRARY_PATH, provisions a local .venv so editable installs have a writable prefix, scrubs stale build/ / kth/ / conan artefacts before every run, and runs the pytest suite at the end (skippable with --no-tests). Non-NixOS devs keep using scripts/build.sh unchanged.

2. Regenerated surface (~70 files)

Full generate_capi_v2.py --all --target python --write:

  • Modified every existing binding to pick up the C-API changes from kth 0.79 → 0.80: handle typedefs post the primitives.h split (kth_*_mut_t / _const_t), the *_simple convention on flag-aware overloads, the leak / leak_if_valid adjustment on types without operator bool, and the owned-copy policy for scalar-value list accessors (short_ids, mnemonics).
  • Created ~38 new bindings that weren't generated before: history_compact{,_list}, double_spend_proof{,_spender}, get_blocks, get_headers, operation{,_list}, prefilled_transaction{,_list}, token_data, utxo{,_list} on the chain side, and ec_private, ec_public, hd_private, hd_public, payment_address_list, wallet_data on the wallet side.
  • kth_native.pyi and src/module.c picked up the splice updates for every class above.

3. Hand-fixes in the surviving hand-written wrappers

Where the regen doesn't reach and the C-API renames broke the build:

  • src/chain/chain.cppkth_merkleblock_tkth_merkle_block_mut_t, and the matching _mut_t adjustments on history_compact_list, stealth_compact_list, compact_block, payment_address; kth_wallet_payment_address_construct_from_string_construct_from_address.
  • src/chain/history.cpp — list / element handle renames to *_mut_t. The file is kept for its async surface but is out of setup.py sources; the generator covers the sync side.
  • src/module.c — dropped 50 lines of stale PyMethodDef entries (for merkle_block, history_compact{,_list}, compact_block, stealth_compact{,_list}, payment_address) that pointed at pre-regen function names. Every class on that list is now registered through the AUTO-generated PyModule_AddFunctions block further down.

Test plan

  • scripts/build-nix.sh builds the .so cleanly on NixOS.
  • Existing pytest suite stays green: 89 passed in 1.23s.
  • CI wheel builds on the standard linux / macOS matrix.

Follow-up

End-to-end pytest cases for the ~30 newly-generator-driven classes (double_spend_proof, get_blocks, get_headers, operation, prefilled_transaction, token_data, utxo, history_compact, ec_private, ec_public, hd_private, hd_public, wallet_data, and the matching _list types). They compile, link and import today; dedicated Python-side tests will land in a separate PR.

Summary by CodeRabbit

  • New Features

    • Much-expanded Python API: new chain types (compact/merkle/get-blocks/headers, operations, token data, UTXO, prefilled txs, history, double-spend proofs) and wallet types (EC/HD keys, payment addresses, wallet data), plus script helpers.
  • Improvements

    • Core dependency bumped to 0.80.0.
    • Safer resource lifecycles, better input validation, and clearer error reporting.
    • Added a Nix-friendly build wrapper for reproducible builds.
  • Bug Fixes

    • Hardened bindings to prevent crashes and reduce allocation/edge-case failures.
  • Tests

    • Large suite of new tests validating lifetimes, bindings, serialization, and behavior.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant