Example: preflight-service (Rust)
Location: examples/rust/src/bin/preflight_service.rs
Run:
cd examples/rustcargo run --bin preflight_serviceWhat it demonstrates
Section titled “What it demonstrates”A custodian or relayer service in Rust that:
- Fetches the live registry via HTTP (
ureq) usingget_cellsto discover the current outpoint - Parses the BLKL v2 payload with
parse_registry_payload - Checks three candidate transactions with
check_transaction - Accepts clean candidates, rejects blacklisted ones, and rejects missing-dep transactions (fail-closed)
Outputs:
candidate-payment: accepted for signingblacklisted-payment: rejected — BlacklistedLockArgs (code -11)missing-registry-dep: rejected — MissingRegistryCellDep (code -8)If the live registry has no active entries, the blacklisted-payment branch is reported as unavailable rather than fabricated.
SDK patterns
Section titled “SDK patterns”- Manual
get_cellsRPC call to discover registry outpoint (nofindRegistryCellin Rust SDK — implement using the indexer directly) parse_registry_payloadto parse the fetched cell data bytescheck_transactionwithnow_secsfor time-based entry evaluation
Production note
Section titled “Production note”This example uses a local path dependency (../../sdk/rust). In a real project, use the published crate:
[dependencies]ckb-transaction-firewall-sdk = "0.3"See Rust SDK API for full type signatures and Pre-flight check in Rust for the complete how-to.