Skip to content

Initial Mintlayer Rust SDK - #1

Merged
erubboli merged 29 commits into
mintlayer:mainfrom
nullPointerEnjoyer:initial-sdk
Sep 17, 2026
Merged

erubboli merged 29 commits into
mintlayer:mainfrom
nullPointerEnjoyer:initial-sdk

Conversation

@nullPointerEnjoyer

Copy link
Copy Markdown
Contributor

Initial release of the Mintlayer Rust SDK — the Rust equivalent of the Go SDK, with the embedded WASM cryptography runtime replaced by native bindings to mintlayer-core.

Modules

Module Purpose
node JSON-RPC 2.0 client for the node daemon (chainstate, mempool, P2P incl. broadcast)
indexer REST client for api-web-server (chain, blocks, txs, addresses, pools, tokens, orders, statistics)
wallet JSON-RPC 2.0 client for the wallet daemon (lifecycle, transactions, staking, tokens, DEX orders)
crypto Native cryptography & transaction building backed by mintlayer-core (git deps pinned to rev 7f4393ac9)

Feature flags: default node,indexer,wallet; crypto opt-in; full = everything. Each feature combination compiles and is tested in isolation (CI matrix).

Design notes

  • The crypto module mirrors the go-sdk wasm sub-client operation-for-operation, but exchanges typed values (Transaction, TxOutput, PrivateKey, ...) instead of opaque byte arrays; SCALE Encode/DecodeAll re-exports provide byte-level access.
  • Consumers must replicate the [patch.crates-io] parity-scale-codec entry (documented in the root Cargo.toml and README) — Cargo ignores patches from non-root workspaces.
  • Hand-rolled JSON-RPC transport for exact go-sdk behavioral parity: atomic ids from 1, no batching, HTTP status not inspected, TrustPolicy semantics, wallet submit_transaction hardcodes Trusted.

Security hardening (all covered by tests)

  • Basic-auth credentials, mnemonics, passphrases and HTLC secrets are redacted from Debug output across all client/builder/param types.
  • Daemon response bodies capped at 64 MiB (streaming, both transports); HTTP error bodies truncated and stripped of control characters.
  • JSON-RPC responses must echo the request id (checked before the error field).
  • Indexer path segments validated to a safe charset before URL interpolation.
  • BIP39 seed and passphrase are zeroized; outbound HTTP clients disable redirects.

Tests

88 integration tests: wire-format pins for every RPC/REST shape (incl. string-encoded numbers, tuple-wired fee points/banned peers, tagged enums), consensus vectors for the crypto module (BIP39 legacy derivations, transaction ids, fee schedule, timelock SCALE bytes, token-id/pool-id bech32 pins, orders-V1 fork straddle), HTLC spend/refund/secret-extraction end-to-end, signed-intent sign→verify with tamper negatives, concurrent-id uniqueness, and security regression tests (redaction, oversize bodies, path traversal).

Examples & docs

  • examples/send-coins.rs — native derive → fetch UTXOs → build/sign → submit flow (with fee-semantics guard)
  • examples/issue-token.rs — wallet daemon token issuance flow
  • docs/ — full references for each sub-client plus transactions/staking/tokens guides

…coins fee guard, error naming (final review fixes)
@erubboli
erubboli self-requested a review September 17, 2026 15:04
@erubboli
erubboli merged commit d462098 into mintlayer:main Sep 17, 2026
19 checks passed
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.

2 participants