PR: neptune-core — expose LockScript in public API
Target repo: Neptune-Crypto/neptune-core
Target branch: master
Title: feat(neptune-cash): expose LockScript and custom lock script output construction
Motivation
Currently neptune-cash (the public re-export crate) does not expose
LockScript, TypeScript, or any way to create a TxOutput whose lock
script is an arbitrary TASM program. All TxOutputListBuilder methods
derive the lock script hash from a ReceivingAddress, which is hardwired
to the standard wallet key scheme.
This forces any third-party tool that wants to deploy a custom TASM program
as a Neptune LockScript (e.g. a Triton VM warrior CLI, a language compiler
toolchain, a zkApp framework) to take a full dependency on the neptune-core
node crate — pulling in ~200k LOC, LevelDB, the full sync engine, and a
multi-minute compile — just to access Utxo::new_native_currency(digest).
The fix is small: re-export three types and add one builder method.
Proposed API
Re-exports in neptune-cash public surface
Add to neptune_cash::api::export (or neptune_cash::prelude):
// Re-exported from neptune_core::transaction::lock_script
pub use LockScript;
pub use LockScriptAndWitness;
// Re-exported from neptune_core::models::blockchain::type_scripts
pub use TypeScript;
TxOutputListBuilder::with_lock_script method
LockScript::from_program convenience constructor
If not already present:
What this enables
A thin client (no neptune-core dependency, only neptune-cash) can:
use *;
use *;
// 1. Compile a Trident program to TASM (via trident-lang)
let tasm: String = compile_to_tasm?;
// 2. Hash it — this is the on-chain identity
let program = from_code?;
let lock_hash = from_program.hash;
// 3. Create a tx output locked by this program
let mut builder = new;
builder.with_lock_script;
// 4. Submit via RPC — no node crate needed
client.record_and_broadcast_transaction.await?;
Before this PR, step 3 requires use neptune_core::... and a direct
dependency on the full node crate.
Scope and non-goals
This PR does not:
- Change any consensus logic
- Change any wire format
- Add wallet integration for custom lock scripts (spending is the caller's responsibility)
- Change how lock scripts are executed during block validation
It only makes existing internal types accessible to thin clients through
the public neptune-cash re-export surface.
Affected files
| File | Change |
|---|---|
neptune-cash/src/api/export.rs |
add pub use for LockScript, LockScriptAndWitness, TypeScript |
neptune-cash/src/api/tx_initiation/builder.rs |
add with_lock_script method on TxOutputListBuilder |
neptune-core/src/transaction/lock_script.rs |
add from_program and hash convenience methods (if absent) |
Alternative considered
neptune-lockscript micro-crate: publish a separate crate containing
only LockScript + its hash computation, with no node dependencies.
Rejected: introduces a third crate to synchronise with neptune-core
releases. The re-export approach is zero maintenance — the type is already
defined, it just needs to be visible.