lbry.tech/documents/resources/schema.md

179 lines
4.2 KiB
Markdown
Raw Normal View History

# Schema
## [Claim](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/claim.proto)
2018-09-24 20:14:40 +02:00
A `Claim` is the toplevel schema for everything that is published to the LBRY blockchain.
2018-09-24 20:02:34 +02:00
```protobuf
message Claim {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
}
2018-09-24 20:02:34 +02:00
required Version version = 1;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
enum ClaimType {
UNKNOWN_CLAIM_TYPE = 0;
streamType = 1;
certificateType = 2;
}
required ClaimType claimType = 2;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
optional Stream stream = 3;
optional Certificate certificate = 4;
optional Signature publisherSignature = 5;
}
```
2018-09-24 20:15:53 +02:00
## Content
2018-09-24 20:15:53 +02:00
### [Stream](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/stream.proto)
2018-09-24 20:14:40 +02:00
All content claims have a Stream field, which includes the content-specific information (e.g. a description of the content, instructions for downloading the content, etc).
2018-09-24 20:02:34 +02:00
```protobuf
message Stream {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
}
2018-09-24 20:02:34 +02:00
required Version version = 1;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
required Metadata metadata = 2;
required Source source = 3;
}
```
2018-09-24 20:15:53 +02:00
### [Metadata](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/metadata.proto)
2018-09-24 20:14:40 +02:00
`Metadata` provides information about a piece of content, such as the title, description, and price.
2018-09-24 20:02:34 +02:00
```protobuf
message Metadata {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
_0_0_2 = 2;
_0_0_3 = 3;
_0_1_0 = 4;
}
2018-09-24 20:14:40 +02:00
required Version version = 1;
2018-09-24 20:02:34 +02:00
enum Language {
UNKNOWN_LANGUAGE = 0;
en = 1;
}
2018-09-24 20:02:34 +02:00
required Language language = 2;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
required string title = 3;
required string description = 4;
required string author = 5;
required string license = 6;
required bool nsfw = 7;
optional Fee fee = 8;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
optional string thumbnail = 9;
optional string preview = 10;
optional string licenseUrl = 11;
}
```
2018-09-24 20:15:53 +02:00
### [Fee](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/fee.proto)
2018-09-24 20:14:40 +02:00
A `Fee` defines the prices for accessing a piece of content.
2018-09-24 20:02:34 +02:00
```protobuf
message Fee {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
}
2018-09-24 20:14:40 +02:00
required Version version = 1;
2018-09-24 20:02:34 +02:00
enum Currency {
UNKNOWN_CURRENCY = 0;
LBC = 1;
BTC = 2;
USD = 3;
}
2018-09-24 20:02:34 +02:00
required Currency currency = 2;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
required bytes address = 3;
required float amount = 4;
}
```
2018-09-24 20:15:53 +02:00
### [Source](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/source.proto)
2018-09-24 20:14:40 +02:00
A `Source` contains information on how to download a stream. Only the LBRY data network is supported at the moment, but other sources may be added in the future.
2018-09-24 20:02:34 +02:00
```protobuf
message Source {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
}
2018-09-24 20:02:34 +02:00
required Version version = 1;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
enum SourceTypes {
UNKNOWN_SOURCE_TYPE = 0;
lbry_sd_hash = 1;
}
required SourceTypes sourceType = 2;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
required bytes source = 3;
required string contentType = 4;
}
```
2018-09-24 20:14:40 +02:00
## Channels
2018-09-24 20:15:53 +02:00
Channels are the identity mechanism in LBRY. They are constructed out of Certificates and Signatures. Both utilize a KeyType:
2018-09-24 20:14:40 +02:00
```protobuf
enum KeyType {
UNKNOWN_PUBLIC_KEY_TYPE = 0;
NIST256p = 1;
NIST384p = 2;
SECP256k1 = 3;
}
```
### [Certificate](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/certificate.proto)
Creating a channel involves making a `certificateType` claim. This claim contains the public key for a channel. It must include a Certificate field:
2018-09-24 20:02:34 +02:00
```protobuf
message Certificate {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
}
2018-09-24 20:02:34 +02:00
required Version version = 1;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
required KeyType keyType = 2;
required bytes publicKey = 4;
}
```
2018-09-24 20:14:40 +02:00
### [Signature](https://github.com/lbryio/lbryschema/blob/master/lbryschema/proto/signature.proto)
Publishing a claim to a channels simply means that the claim is signed using the private key for a channel. This is done by including a Signature field in a Claim:
2018-09-24 20:02:34 +02:00
```protobuf
message Signature {
enum Version {
UNKNOWN_VERSION = 0;
_0_0_1 = 1;
}
2018-09-24 20:02:34 +02:00
required Version version = 1;
2018-09-24 20:14:40 +02:00
2018-09-24 20:02:34 +02:00
required KeyType signatureType = 2;
required bytes signature = 3;
required bytes certificateId = 4;
}
```