Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
125 lines (107 sloc) 2.78 KB
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