forked from interledger/rfcs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBilateralTransferProtocol.asn
124 lines (107 loc) · 2.78 KB
/
BilateralTransferProtocol.asn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
BilateralTransferProtocol
DEFINITIONS
AUTOMATIC TAGS ::=
BEGIN
IMPORTS
UInt8,
UInt32,
UInt64,
UInt128,
UInt256
FROM GenericTypes
;
-- Zero or more protocolData entries, each with a unique
-- protocolName, describe protocol-specific information about
-- unpaid and conditionally paid requests and results
-- sent over the BilateralTransferProtocol.
-- The protocolName of each entry describes the protocol for
-- interpreting the data. Peers need to establish beforehand
-- which protocols each understand, and which names they
-- use, which can be agreed ad-hoc, except that protocolName 'ilp'
-- is reserved for the Interledger protocol.
-- When multiple protocolData items are sent in a request,
-- only the first one will be decisive in triggering the
-- response, the rest of the protocolData items are considered
-- side protocols that piggyback on the first one.
-- The contentType byte can be used to allow debug tools to
-- display the contents of the protocolData without understanding
-- it.
ContentType ::= INTEGER {
applicationOctetStream (0),
textPlainUtf8 (1),
applicationJson (2)
} (0..255)
ProtocolData ::= SEQUENCE OF SEQUENCE {
protocolName IA5String,
contentType ContentType,
data OCTET STRING
}
-- Response and Error are the response types.
-- When using these in a BTP packet, the requestId should match
-- the requestId of the request they respond to.
Response ::= SEQUENCE {
protocolData ProtocolData
}
Error ::= SEQUENCE {
-- Standardized error code
code IA5String (SIZE (3)),
-- Corresponding error code
name IA5String,
-- Time of emission
triggeredAt GeneralizedTime,
-- Additional data
data OCTET STRING (SIZE (0..8192)),
--
protocolData ProtocolData
}
-- Prepare, Fulfill, Reject, and Message are the request types.
-- Each request should have a unique requestId.
Prepare ::= SEQUENCE {
transferId UInt128,
amount UInt64,
executionCondition UInt256,
expiresAt GeneralizedTime,
--
protocolData ProtocolData
}
Fulfill ::= SEQUENCE {
transferId UInt128,
fulfillment UInt256,
--
protocolData ProtocolData
}
Reject ::= SEQUENCE {
transferId UInt128,
--
protocolData ProtocolData
}
Message ::= SEQUENCE {
protocolData ProtocolData
}
Transfer ::= SEQUENCE {
amount UInt64,
--
protocolData ProtocolData
}
CALL ::= CLASS {
&typeId UInt8 UNIQUE,
&Type
} WITH SYNTAX {&typeId &Type}
CallSet CALL ::= {
{1 Response} |
{2 Error} |
{3 Prepare} |
{4 Fulfill} |
{5 Reject} |
{6 Message} |
{7 Transfer}
}
BilateralTransferProtocolPacket ::= SEQUENCE {
-- One byte type ID
type CALL.&typeId ({CallSet}),
-- Used to associate requests and corresponding responses
requestId UInt32,
-- Length-prefixed main data
data CALL.&Type ({CallSet}{@type})
}
END