From 012d804474bc571cd6c0cd98a9c81673dfc6163f Mon Sep 17 00:00:00 2001 From: Fabrice Drouin Date: Wed, 23 Aug 2017 16:58:05 +0200 Subject: [PATCH] Fix node announcement encoding (closes #124) (#136) --- .../scala/fr/acinq/eclair/wire/LightningMessageCodecs.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eclair-core/src/main/scala/fr/acinq/eclair/wire/LightningMessageCodecs.scala b/eclair-core/src/main/scala/fr/acinq/eclair/wire/LightningMessageCodecs.scala index 4afaa12fc..68e1601a2 100644 --- a/eclair-core/src/main/scala/fr/acinq/eclair/wire/LightningMessageCodecs.scala +++ b/eclair-core/src/main/scala/fr/acinq/eclair/wire/LightningMessageCodecs.scala @@ -40,7 +40,10 @@ object LightningMessageCodecs { .typecase(2, ipv6address) ~ uint16) .xmap(x => new InetSocketAddress(x._1, x._2), x => (x.getAddress, x.getPort)) - def listofsocketaddresses: Codec[List[InetSocketAddress]] = listOfN(uint16, socketaddress) + // this one is a bit different from most other codecs: the first 'len' element is * not * the number of items + // in the list but rather the number of bytes of the encoded list. The rationale is once we've read this + // number of bytes we can just skip to the next field + def listofsocketaddresses: Codec[List[InetSocketAddress]] = variableSizeBytes(uint16, list(socketaddress)) def signature: Codec[BinaryData] = Codec[BinaryData]( (der: BinaryData) => bytes(64).encode(ByteVector(der2wire(der).toArray)),