iris-grpc-proto
gRPC protobuf definitions and conversions for nockbox-wallet.
This crate provides protobuf type definitions compatible with nockchain's gRPC API, along with conversion traits to/from iris-nockchain-types.
Overview
This crate bridges the gap between:
- nockchain's gRPC server - Full-featured blockchain node with Nock VM
- nockbox-wallet - Lightweight, no_std compatible wallet client
Architecture
iris-nockchain-types (no_std, custom types)
↕ conversion layer
iris-grpc-proto (std, protobuf)
↕ tonic/gRPC
nockchain server (nockchain-types)
Key Differences Handled
Type Mappings
| iris-nockchain-types | Protobuf | nockchain-types |
|---|---|---|
iris_ztd::Belt |
Belt { value: u64 } |
nockchain_math::Belt |
iris_ztd::Digest ([Belt; 5]) |
Hash (5 Belt fields) |
Hash ([Belt; 5]) |
Nicks (usize) |
Nicks { value: u64 } |
Nicks (usize) |
BlockHeight (usize) |
BlockHeight { value: u64 } |
BlockHeight(Belt) |
Version enum |
NoteVersion { value: u32 } |
Version enum |
Implementation Notes
- NoteData Serialization: Currently simplified - full implementation requires proper noun serialization
- Public Fields: Made key fields public in iris-nockchain-types for gRPC conversions:
Name:first,lastPkh:m,hashesPkhSignature: tuple field (Vec of PublicKey/Signature pairs)MerkleProof:root,pathHax: tuple field (Vec of Digest)
- Signature Conversion: Converts between
iris_crypto::Signature(UBig c/s fields) and protobuf EightBelt arrays
Usage
gRPC Client
use ;
async
Type Conversions
use ;
use RawTx;
// Convert wallet transaction to protobuf
let raw_tx: RawTx = /* ... */;
let pb_tx: RawTransaction = raw_tx.into;
Proto Files
The .proto files are copied from nockchain's nockapp-grpc-proto crate:
nockchain/common/v1/primitives.proto- Basic types (Belt, Hash, etc.)nockchain/common/v1/blockchain.proto- V0 transaction typesnockchain/common/v2/blockchain.proto- V1 transaction types with witnessesnockchain/public/v2/nockchain.proto- gRPC service definitions
Features
- ✅ Full gRPC client for Nockchain public API
wallet_get_balance- Get wallet balance (with automatic pagination)wallet_send_transaction- Send signed transactionstransaction_accepted- Check transaction acceptance status
- ✅ Complete type conversions between iris-nockchain-types and protobuf
- ✅ Proper error handling with typed
ClientError
TODO
- Implement proper NoteData serialization/deserialization (currently marked with
todo!()) - Add comprehensive conversion tests
- Add reverse conversions (protobuf → iris-nockchain-types) where needed
- Consider WASM compatibility for client-side gRPC-web
Building
The build process automatically generates Rust code from .proto files using tonic-build.