Skip to content

About

Watchtower Protocol (WTP) protobuf contract + generated Go and Rust

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

wtp-protos

The Watchtower Protocol (WTP) protobuf contract, plus committed generated code for Go and Rust.

This repository is the single source of truth for the WTP wire contract. The .proto sources live under proto/, and the generated language bindings under gen/ are committed to the repo so consumers can depend on them directly without running protoc/buf themselves.

Layout

proto/canyonroad/wtp/v1/            # WTP service + message definitions (package canyonroad.wtp.v1)
proto/canyonroad/wtp/v1/ocsf/       # OCSF event payload schemas (package canyonroad.wtp.v1.ocsf)
gen/go/                             # Generated Go module (+ hand-written validator)
gen/rust/                           # Generated Rust crate (prost messages + tonic services)
buf.yaml                            # buf module + lint/breaking config
buf.gen.yaml                        # buf code-generation config

Go

The generated Go code is its own module:

github.com/canyonroad/wtp-protos/gen/go

Import the WTP v1 messages/service and OCSF payloads via:

import (
    wtpv1 "github.com/canyonroad/wtp-protos/gen/go/canyonroad/wtp/v1"
    ocsfpb "github.com/canyonroad/wtp-protos/gen/go/canyonroad/wtp/v1/ocsf"
)

The module also ships validate.go (package wtpv1), a hand-written validator that is part of the WTP contract and is maintained alongside the generated code.

Build and test the Go module:

( cd gen/go && go build ./... && go test ./... )

Rust

The generated Rust code is a crate named wtp-proto (gen/rust/). It contains prost message types and tonic client/server service stubs. The crate root (gen/rust/src/lib.rs) re-exports the modules under wtp_proto::canyonroad::wtp::v1 (and ...::ocsf).

Build the crate:

( cd gen/rust && cargo build )

Cargo.lock is not committed (this is a library crate); downstream consumers resolve their own dependency versions.

Regenerating gen/

The committed gen/ tree is produced by buf generate. To regenerate after editing the .proto sources you need buf, the Go protoc plugins, and the Rust protoc plugins installed:

go install github.com/bufbuild/buf/cmd/buf@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
cargo install protoc-gen-prost protoc-gen-prost-crate protoc-gen-tonic

buf invokes the local: plugins by binary name from PATH, so the Go bin dir and the Cargo bin dir must both be on PATH for every buf/protoc invocation:

export PATH="$(go env GOPATH)/bin:$HOME/.cargo/bin:$PATH"
buf lint
buf generate

Notes for maintainers

  • gen/rust/Cargo.toml is treated as a template by the protoc-gen-prost-crate plugin: regeneration rewrites only the ## @@protoc_insertion_point(features) section in place. The [package] and [dependencies] sections (including tonic-prost, which tonic 0.14 split out of the tonic crate for the prost codec) are preserved across regeneration.
  • The buf.yaml lint config uses STANDARD but excludes four naming-convention rules (PACKAGE_VERSION_SUFFIX, SERVICE_SUFFIX, RPC_REQUEST_STANDARD_NAME, RPC_RESPONSE_STANDARD_NAME). The WTP contract predates this repo and renaming the package/service/RPC types to satisfy those rules would break the existing wire/API contract.

About

Watchtower Protocol (WTP) protobuf contract + generated Go and Rust

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages