Skip to content

Seraphis Wallet Coding Conventions

René Brunner edited this page Jun 9, 2023 · 5 revisions

This is intended as a collection of conventions and guidelines for Seraphis wallet dev work that were discussed and (more or less) agreed on. Maybe this wiki is not yet the best place for it, but it should do for the time being.

Use the term enote, avoid output

enote was "invented" by @UkoeHB as a better and more expressive term to supersede output and used througout his Seraphis library. Use it in Seraphis wallet code.

How far this replacement will go, whether we will later e.g. rename CLI wallet commands to align with this, is at least in part another question of course.

Described in this issue, discussed and decided in workgroup meeting #1

Use the term id for transactions, avoid hash

In the existing Monero codebase the "thing" that uniquely identifies a transaction is sometimes called id, sometimes hash. It seems a good idea to standardize on one term. id was favored in a discussion.

Described in this issue, discussed and decided in workgroup meeting #1

Avoid the term transfer

wallet2 and other parts of the Monero codebase now use the term transfer, but it's used in relation to both transactions and enotes which easily leads to confusion. This convention is important mostly when naming types and variables; method names are probably less critical.

Described in this issue, discussed and decided in workgroup meeting #1

Use camel case instead of snake case for type names

As an exception from naming almost everything using snake case, use camel case for types (struct, class, enums and their identifiers). So it's e.g. SpInputProposal instead of sp_input_proposal, or SpMembershipProofV1 instead of sp_membership_proof_v1. We continue this style of naming used in the Seraphis library.

Described in this issue, discussed and decided in workgroup meeting #2

Indent 4 blanks per level

We continue the use of 4 blanks to indent code one level in the Seraphis library. Using only 2 blanks as used in many existing Monero C++ source files is considered not optimal, and neither are the 8 blanks per level used in the Linux source code.

Described in this issue, discussed and decided in workgroup meeting #2

Comment extensively

@UkoeHB has commented his Seraphis library extensively; it's estimated that maybe every 4th or 5th line in the source is a comment line. While this may seem excessive, workgroup members mostly agreed in workgroup meeting #19 that this has merit for groundbreaking and fundamental code that the Monero devs will probably have to live with for many years to come, and that it makes sense to comment wallet code in a similar way.

Clone this wiki locally