core-lightning/contrib/msggen
Vincenzo Palazzo 6f0dbbb20f bolt12: allow to inject payer_metadata
Payer metadata is a field that controls the payer ID
provided during the fetchinvoice process.

There are use cases where this is highly useful, such as
proving that the payer has paid for the correct item.

Imagine visiting a merchant's website to pay for multiple offers, where
one of these offers is a default offer (with no description and no set amount).

In this scenario, the merchant could claim not to have received
payment for a specific item. Since the same offer may be used to
fetch invoices for different products, there needs to be a way to
identify which product the invoice corresponds to.

With this commit, it will be possible to inject payer metadata,
which helps solve the issue described above.

For example, possible payer metadata could be `to_hex(b"{payer_node_id}.{product_id}.{created_at}")`.

Changelog-Added: JSON-RPC: `fetchinvoice` allows setting invreq_metadata via `payer_metadata` parameter.
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2024-11-19 22:54:22 +01:00
..
dist added listhtlcs model 2023-07-24 09:07:24 +09:30
examples msggen: adding example and fixes typo 2022-05-07 11:11:51 +02:00
msggen bolt12: allow to inject payer_metadata 2024-11-19 22:54:22 +01:00
.gitignore msggen: Start making the msggen library a standalone tool 2024-02-08 15:03:34 +01:00
Makefile make: Add missing dependency between schemas and schema bundle 2024-02-09 12:20:45 +01:00
poetry.lock msggen: Start making the msggen library a standalone tool 2024-02-08 15:03:34 +01:00
pyproject.toml msggen: Start making the msggen library a standalone tool 2024-02-08 15:03:34 +01:00
README.md msggen: Move overrides into the model itself 2023-05-05 11:54:41 +09:30

MsgGen - Generating language bindings and docs from schemas and wire descriptions

MsgGen is a collection of tools that are used to parse schemas and (eventually) protocol wire CSVs into an intermediate representation in memory, and then generate language specific bindings and documentation from it.

The dependency graph looks like this:

digraph {
  "JSON-RPC Schemas" -> "msggen model";
  "msggen model" -> "grpc proto file";
  "msggen model" -> "Rust From<JsonRpc> Converters";
  "grpc proto file" -> "Rust grpc bindings"
  "Rust grpc bindings" -> "cln-grpc";
  "Rust From<JsonRpc> Converters" -> "cln-grpc";
  "msggen model" -> "Rust JSON-RPC structs";
  "Rust JSON-RPC structs" -> "cln-rpc";
}

msggen will load the schemas in doc/schemas into memory, and then use Patches to enrich the model before using it to generate the bindings for the various languages as well as the converters from one format to another. These patches can be found in msggen/patch.py and perform a variety of operations:

  • Annotate the model with additional data from external sources, such as the .msggen.json file at the repository root to track details that can be derived but should remain constant (grpc field numbering and versioning information)
  • Aggregate common types with type overrides and omit fields that we can't map currently.
  • Infer optionality based on the versions a field was added or deprecated, and the currently supported range of versions.

If there is a field that is currently missing in the model, that is in the schemas it is most likely because it has been marked as omitted in the patch.