1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 14:22:39 +01:00

added init and error messages

This commit is contained in:
pm47 2016-12-05 12:10:24 +01:00
parent ed56401333
commit a274867136
2 changed files with 19 additions and 3 deletions

View file

@ -18,10 +18,18 @@ object Codecs {
def binarydata(size: Int): Codec[BinaryData] = bytes(size).xmap(d => BinaryData(d.toSeq), d => ByteVector(d.data))
def varsizebinarydata: Codec[BinaryData] = variableSizeBytesLong(uint32, bytes.xmap(d => BinaryData(d.toSeq), d => ByteVector(d.data)))
def varsizebinarydata: Codec[BinaryData] = variableSizeBytes(uint16, bytes.xmap(d => BinaryData(d.toSeq), d => ByteVector(d.data)))
def listofbinarydata(size: Int): Codec[List[BinaryData]] = listOfN(int32, binarydata(size))
val initCodec: Codec[Init] = (
("globalFeatures" | varsizebinarydata) ::
("localFeatures" | varsizebinarydata)).as[Init]
val errorCodec: Codec[Error] = (
("channelId" | uint64) ::
("data" | varsizebinarydata)).as[Error]
val openChannelCodec: Codec[OpenChannel] = (
("temporaryChannelId" | uint64) ::
("fundingSatoshis" | uint64) ::
@ -114,6 +122,8 @@ object Codecs {
).as[RevokeAndAck]
val lightningMessageCodec = discriminated[LightningMessage].by(uint16)
.typecase(16, initCodec)
.typecase(17, errorCodec)
.typecase(32, openChannelCodec)
.typecase(33, acceptChannelCodec)
.typecase(34, fundingCreatedCodec)

View file

@ -14,6 +14,12 @@ sealed trait HtlcMessage extends LightningMessage
sealed trait RoutingMessage extends LightningMessage
// @formatter:on
case class Init(globalFeatures: BinaryData,
localFeatures: BinaryData) extends SetupMessage
case class Error(channelId: Long,
data: BinaryData) extends SetupMessage
case class OpenChannel(temporaryChannelId: Long,
fundingSatoshis: Long,
pushMsat: Long,
@ -63,8 +69,8 @@ case class Shutdown(channelId: Long,
scriptPubKey: BinaryData) extends ChannelMessage
case class ClosingSigned(channelId: Long,
feeSatoshis: Long,
signature: BinaryData) extends ChannelMessage
feeSatoshis: Long,
signature: BinaryData) extends ChannelMessage
case class AddHtlc(channelId: Long,
id: Long,