BOOK: the VOIX phone book
Protocol and consensus12.5.9+

BOOK: the VOIX phone book

The VOIX phone book: signed entries, routes, endorsements and revocations, the name registry, REST and RPC.

The phone book says, on chain, how to write to a Lotus address or a node: its messaging key M, its mailboxes, its first-contact prices, its handle, who vouches for the key, and whether the owner revoked it. Each fact is a signed VOIX record in an OP_RETURN output. The book module indexes the records, applies the history rules (sequence numbers, sticky revocation key, final revoke) and serves the result under /api/v1/book/*. It also keeps the name registry that makes handles unique. Specification: doc/research/VOIX-PROTOCOL-12.5.8.md section 4; byte formats: doc/voix/formats.md; registry: doc/voix/names.md.

Status in this node #

  • Built-in module book (class CBookModule), registered after eMPP and BLOB: src/modules/builtin_modules.cpp:43. Listed in -modules (src/init.cpp:5748); eMPP is added when it is listed (NEEDS_EMPP, src/modules/module_registry.cpp:380).
  • Database: <datadir>/modules/book.sqlite (CBookModule::Init, src/modules/book/book_module.cpp:199). The name registry tables book_name_* live in the same file and follow the same transactions.
  • Indexing only: no consensus or relay rule. A malformed record is skipped.
  • LOKAD id: "VOIX" = 56 4f 49 58, shared with the on-chain messages (voix::LOKAD, src/voix/common.h).
  • Sending is refused on mainnet until the external review of the formats (decision D19 / O9): the write RPCs answer voix_review_pending there, except with dry_run (CheckSendAllowed, src/rpc/book.cpp:176). Indexing runs on every network.

Envelope #

TransportScript shapeRead by
BareOP_RETURN <one canonical push: "VOIX" + body>voix::DecodeScript on every OP_RETURN output (ExtractBlock, book_module.cpp:369)
eMPPOP_RETURN OP_RESERVED <"VOIX" + body> [more segments]the eMPP module's rows (SegmentsForBlock), one record per VOIX segment

A record is identified by (txid, vout, seg); records of a block are applied in (transaction index, vout, segment) order. The burn of a record is the value of its output (eMPP: on the first segment only, as for the other eMPP protocols).

Byte layout #

All integers little-endian. subj is u8 kind || key: kind 1 = 33-byte secp256k1 key S, kind 2 = 32-byte node fingerprint F (SHA-256 of the RSA modulus). Every body starts with version 0x02, type, flags (12.5.9, owner decision M8; a version 0x01 record is listed as skipped with reason old_format_v1).

TypeNameFields after the headerTrailer
0x10ENTRYsubj, seq u32, u8 n + handle (0..32, [a-z0-9._-]), M (33), valid_until u32 [flag 2: accept_price varint, notify_price varint] [flag 1: R (33)]sig; flag 4 (0x10): a second 64-byte signature by the current R
0x11ROUTEsubj, seq u32, slot u8 (0..2), B (33), node (32; zeros = clear)sig
0x12ENDORSEsubj, target subj, target_key = SHA256(M) (32), level u8 (0..2)sig
0x13REVOKEsubj, what u8 then seq u32 (1), slot u32 <= 2 (2), target subj (3) or nothing (4), reason u8 (0..3)sig by S, or by R when flag 0
0x14LINKsubj (kind 1), node (32), role u8 (1, 2) [flag 0: vbytes modulus, vbytes rsa_sig]sig
0x15IDENTsubj, seq u32, u8 n, n x (u8 kind, u8 len, bytes)sig
0x16..0x1Bname registrysee doc/voix/names.md 4
0x1CBINDsubj (kind 1), seq u32, scope u8 (1, 2), A (33) [scope 2: chain_code (32), count u16 <= 1000], addr_sig (64)sig over everything before it

ENTRY flags: bit 0 unlisted, bit 1 has R, bit 2 has prices, bit 3 node box, bit 4 cosigned. Signature: Lotus Schnorr (CKey::SignSchnorr) by S over TH("lotus-voix v2 txsig", TH("lotus-voix v1 book", magic || body up to the trailer) || outputs_digest), where outputs_digest is the SHA-256 of every output of the carrying transaction except the record's own OP_RETURN output (value u64 LE || varint len || script, in order; doc/voix/formats.md section 2.1), with TH(t, x) = SHA256(SHA256(t) || SHA256(t) || x) and magic the 4 network message-start bytes. A kind-2 subject signs with RSA-PSS-SHA256 instead: trailer vbytes modulus || vbytes rsa_sig, and SHA256(modulus) must be F. The LINK proof is an RSA-PSS signature of the node over TH("lotus-voix v1 nodelink", magic || subj || node || role). Decoding and signature checks are the voix library's (voix::DecodeBody, voix::VerifyBook, src/voix/records.h); vectors in doc/voix/vectors/records.json.

Sizes: an ENTRY with a 16-character handle, prices and R is a 210-byte script; ROUTE 179, ENDORSE 176. A LINK with an inline proof or a kind-2 ENTRY is above 223 bytes, which upstream 12.0.x nodes reject; the RPCs say above_223 before sending.

Rules #

Per subject, in chain order (book::Apply, src/modules/book/book_rules.cpp:9; reference BookState in test/functional/test_framework/voix.py, vectors doc/voix/vectors/book_rules.json):

  1. After an accepted REVOKE what = 4 every record of the subject is skipped (subject_revoked).
  2. A record whose signature fails is skipped (bad_signature). The current R of the subject is the key for a REVOKE with flag 0 and for the cosignature of an ENTRY.
  3. ENTRY: seq must be above the subject's last accepted ENTRY (seq_replay; ties go to the first in chain order). Once an entry declared R, a later entry changes or drops it only with the cosignature of the current R; without it the entry is accepted and the old R stays (kept_revocation_key, shown as R_kept). This is what stops a thief who holds S from removing the owner's way to revoke.
  4. ROUTE: seq above the last one of that slot. IDENT: seq above the last IDENT; the latest replaces the list.
  5. ENDORSE level 1 or 2 sets the endorsement of (endorser, target), level 0 withdraws it. It covers one key (target_key); the views say whether it is the target's current M (current).
  6. REVOKE what 1 marks the entry with that seq (also one published later); if it is the current entry, the subject has no current entry until a higher ENTRY. What 2 clears the slot, what 3 removes the endorsement.
  7. IDENT kind 5 is an entity key of RANK 3 (UTF-8, 1 to 96 bytes, several per IDENT; a bad one makes the record malformed). Each is kept in book_entity_claims under eid = base32lower(SHA-256("lotus-entity-v1" || 0x00 || key)[0..16]) (26 characters, RFC 4648 alphabet, no padding). A claim is current while it is in the subject's latest IDENT, the subject is not revoked and its entry is not expired; several subjects may claim one key. RANK 3 reads them with book::EntityClaims(eid) or GET entity/<eid or key>.
  8. BIND (spec 4.11, src/modules/book/book_bind.cpp, Python test_framework/voix_bind.py, vectors doc/voix/vectors/bind.json): addr_sig is a Schnorr signature by A over TH("lotus-voix v1 addr", magic || subj || seq || flags || scope || A [|| chain_code || count]); flags bit 0 Taproot (the address with commitment A, else P2PKH of HASH160(A)), bit 7 withdrawn (scope 1; scope 2 withdraws with count = 0). Scope 2 binds the non-hardened children 0/i and 1/i, i < count, of the account key (BIP32 public derivation); node index policy (a BIND needs no burn): the node derives and indexes i < min(count, 100) only (book::BIND_INDEX_MAX_PER_CHAIN), while the record still decodes and verifies with any count up to 1,000. Cost bound per record: 100 x 2 chains = 200 BIP32 public derivations (one EC tweak each, about 5 ms in all) and 200 book_address_bindings rows, against 2,000 of each with count = 1000; an ENTRY does not rewrite them, a reorg derives them again. seq must rise per (subject, address or account). The subject's own two addresses are bound implicitly (rows with scope = 0). Among the current bindings of an address (not withdrawn, subject not revoked, entry current and not expired) the first in block order wins; a newer seq of the same subject keeps its place while it stays current. A handle is shown only when the winner holds it in the name registry at the tip, never otherwise.
  9. LINK is verified with a valid inline proof (a failing proof makes the record bad_signature), or when the onion part's descriptor check says so (CBookModule::SetLinkDescriptorVerifier), else claimed.

An entry with valid_until below the indexed height is expired. A kind-1 subject S is found from P2PKH(HASH160(S)) and from the Taproot output whose commitment is S (book::AddressScripts, book_module.cpp:173).

Handles are unique through the name registry (doc/voix/names.md 9, HandleStatusLocked, book_module.cpp:1065): registered while the registry binds the name to HASH160(S) and the subject is not revoked, lapsed when it was bound before, unregistered otherwise. Only a registered, listed handle is returned by handle/<h> and search.

Storage #

book_records holds every record that decodes as a book record with its outcome (accepted, reason), raw body and the outputs digest of its transaction (outputs_digest, 12.5.9); it is the source of truth. The other tables are derived per subject: book_subjects (rules state, current entry, revocation), book_entries (history), book_entry_revokes, book_routes, book_endorse, book_links, book_idents, book_entity_claims, book_binds, book_address_bindings (address, subject, seq, height, scope, current; its handle column is left empty, the handle is read from the current entry), book_addr (script to subject), and the registry's book_name_*. Schema: CreateSchema, book_module.cpp:227.

  • Connect: records, derived rows, registry, tip marker and tip history in one transaction (ConnectBlock, book_module.cpp:897).
  • Disconnect and RollbackToHeight: delete the records above the height, rebuild each subject they touched from its remaining records (ReplaySubjectLocked, book_module.cpp:821), roll the registry back (RollbackLocked, book_module.cpp:953). The result equals never having connected those blocks (book_module_tests/rollback_symmetry_all_depths).
  • Rescan (rescanmodule book): records already indexed are left alone; a record the module missed is inserted and its subject queued in book_replay_pending; each queued subject is rebuilt in chain order once, at the end of the rescan and outside cs_main (or at the next start if the rescan stopped) (RescanRange). The registry is not rescanned: it follows connect and disconnect only.
  • Start: every node shows the same book, records and names alike. A new or wiped database starts with its tip at the genesis block (as the contract module), so the startup reconcile replays the existing chain into it. names_from (meta) is the first block the book saw (0: genesis). A book that did not start at genesis (an earlier version's database that started late, or a gap: blocks the replay could not read) is rebuilt from genesis once at the next start (NeedsFullReindex), unless the node has pruned blocks: then it stays a partial book. The views say so (complete, partial_reason: pruned, missing_blocks or late_start, indexed_from_height), the dashboard shows "This node is pruned: its phone book starts at block N and may miss older records", and namecommit / nameclaim refuse (names_incomplete).
  • Rejected name events change no state: the newest 100 per name and the newest 100,000 overall are kept (pruned at the end of each block, NameRegistry::EndBlock).
  • Name commits never revealed by a valid claim are pruned once older than the reveal window plus a margin of twice the window (commit_max_age + CommitPruneMargin = 3 x 5,040 blocks on mainnet); revealed commits are kept (revealed_at, cleared when the claim is rolled back). A rollback of up to the margin finds every commit its blocks can use.
  • Later work (needs undo data): a reorg or rollback rebuilds each subject it touches from all its records (ReplaySubjectLocked), so its cost grows with the subject's history (review M11).

REST #

Under /api/v1/book/ (RegisterRoutes, book_module.cpp:1518): subject/<subj>, address/<address>, node/<fingerprint>, handle/<handle>, search?q=&limit=, endorsements/<subj>, entity/<eid or key>, POST addresses ({"addresses": [up to 100]} to {address: display or null}, answers kept per tip), recent?limit= (cached 5 s), stats (cached 5 s), and the registry routes name/<name>, name/<name>/history, name/<name>/price, names?owner=, names/recent, names/stats, name-commitment/<Q>. Shapes in doc/api-v1.md. Every handler runs under the module mutex and checks the path depth (404 unknown_subroute). The public views are bounded: received endorsements and entity claims are paged, the other lists of a subject or node show the newest (or first) 100 with a *_total, the entity view reads each claimant's entry by key, and stats / names/stats are counted once per indexed block.

RPC #

src/rpc/book.cpp. bookget <address|subject|fingerprint|handle> returns the REST view plus unlisted entries and every record with its outcome. The write RPCs build one record type with the voix library, sign it with the wallet key of an address (P2PKH key, or the tweaked key of a key-path Taproot address) and send it, at most three OP_RETURN outputs per transaction, funded by the wallet: bookpublish {address, handle, prices, revocation, unlisted, rotate, mailbox_nodes, ...} (ENTRY + one ROUTE per mailbox node), bookendorse, bookrevoke, booklink (with proof: inline RSA proof by this node), bookident, bookbind <address> {subject, scope, account_xprv, count, taproot, withdraw}. reloadaddresslabels reads <datadir>/address-labels.json again (operator labels {"<address>": {"label", "type", "url"}}, types default, primary, warning, danger, success; also read at start; shown as label by address/<address>, never on chain). Each write RPC takes dry_run and returns records[] with hex, script, size, above_223.

Keys M, B, R (DeriveRoleKey, src/rpc/book.cpp:256): in a legacy HD wallet whose address key is m/0'/c'/i' of the seed, m/7300'/10605'/account'/role'/rotation' from the same seed with account = i + c * 2^30 (decision O10); for every other key (descriptor wallets, imported keys), TH("lotus-voix v1 keys", secret || u8 role || u32 rotation). Role 0 is M, 1 is B, 2 is R (rotation 0). Nothing new is stored in the wallet.

Unverified: mainnet behaviour (sending is gated off there).

Source doc/protocols/book.md in the lotusd repository