---
# System prepended metadata

title: CSV Structure description

---

# CSV Structure description

The lightning domain specifc CSV describe all the possible messages combination of the BOLT protocol. 

To illustrate the how the CSV are specify, we will use the init message from BOLT 1

```
msgtype,init,16
msgdata,init,gflen,u16,
msgdata,init,globalfeatures,byte,gflen
msgdata,init,flen,u16,
msgdata,init,features,byte,flen
msgdata,init,tlvs,init_tlvs,
tlvtype,init_tlvs,networks,1
tlvdata,init_tlvs,networks,chains,chain_hash,...
```

We will go line by line to explain how the format is defined.

To add a new message into the CSV file, first you need to add a new line that specify the type of the message with the following format:

msgtype,`[name of the message]`, `[message type]`

For example:
```
msgtype,init,16
```
Follow by this msgtype specification line is the all the possible combination of such msgtype

Following the init msg example above we add 1+n lines of msgdata in the format of

msgdata, `[name of the message]`, `[field name]`, `[field type]`

for example:
```
msgdata,init,gflen,u16,
```

If we are to specify the length of the field that depend on previous field
We can add a line with the following format:

msgdata, `[name of the message]`, `[field name]`, `[field type]`, `[field lenght]`

for example:
```
msgdata,init,globalfeatures,byte,gflen
```

If there is tlvs involved in the field, then we can use the following format:
msgdata, `[name of the message]`, tlvs, `[name of the tlvs field]`
for example:
```
msgdata,init,tlvs,init_tlvs,
```

Then we need to define the a tlv type line similar to msgtype in the following format:
tlvtype, `[name of the tlv field defined on previous line]`, tlvs, `[name of the tlvs type]`, `[Int value of the tlvs type]`
for example:
```
tlvtype,init_tlvs,networks,1
```

Then right after this line, a tlvsdata should be added with the following format:
tlvdata, `[name of the tlv field]`, `[Name of the tvls type]`, `[field2]`, `[field3]`
for example:
```
tlvdata,init_tlvs,networks,chains,chain_hash,...
```


```
MessageNode (msgtype): -> []DataType

DataType(msgdata): 
  - U16Dau(name)
  - ArrayByte(globalfeatures, byte, gflen)
  - Tlvs(init_tlvs, TlvData)
  
TlvData(tlvdata):
    
```

There are some special symbol found in the CSV files
```
... -> What is mean 
| -> could be or?
```

## Gossip Queries

### TLV Types

```
tlvdata,query_short_channel_ids_tlvs,query_flags,encoding_type,byte,

tlvdata,init_tlvs,networks,chains,chain_hash,...
```

### Subtype entry

What they are?
