mirror of
https://github.com/ACINQ/eclair.git
synced 2025-01-19 05:33:59 +01:00
Reorder features fields to match the BOLTS (#127)
see spec change a257554456cda98afd1532c302c0e5e84de0455e
This commit is contained in:
parent
3e81fce898
commit
f2560e2c9c
@ -18,10 +18,10 @@ import scala.compat.Platform
|
||||
object Announcements {
|
||||
|
||||
def channelAnnouncementWitnessEncode(shortChannelId: Long, nodeId1: PublicKey, nodeId2: PublicKey, bitcoinKey1: PublicKey, bitcoinKey2: PublicKey, features: BinaryData): BinaryData =
|
||||
sha256(sha256(serializationResult(LightningMessageCodecs.channelAnnouncementWitnessCodec.encode(shortChannelId :: nodeId1 :: nodeId2 :: bitcoinKey1 :: bitcoinKey2 :: features :: HNil))))
|
||||
sha256(sha256(serializationResult(LightningMessageCodecs.channelAnnouncementWitnessCodec.encode(features :: shortChannelId :: nodeId1 :: nodeId2 :: bitcoinKey1 :: bitcoinKey2 :: HNil))))
|
||||
|
||||
def nodeAnnouncementWitnessEncode(timestamp: Long, nodeId: PublicKey, rgbColor: (Byte, Byte, Byte), alias: String, features: BinaryData, addresses: List[InetSocketAddress]): BinaryData =
|
||||
sha256(sha256(serializationResult(LightningMessageCodecs.nodeAnnouncementWitnessCodec.encode(timestamp :: nodeId :: rgbColor :: alias :: features :: addresses :: HNil))))
|
||||
sha256(sha256(serializationResult(LightningMessageCodecs.nodeAnnouncementWitnessCodec.encode(features :: timestamp :: nodeId :: rgbColor :: alias :: addresses :: HNil))))
|
||||
|
||||
def channelUpdateWitnessEncode(shortChannelId: Long, timestamp: Long, flags: BinaryData, cltvExpiryDelta: Int, htlcMinimumMsat: Long, feeBaseMsat: Long, feeProportionalMillionths: Long): BinaryData =
|
||||
sha256(sha256(serializationResult(LightningMessageCodecs.channelUpdateWitnessCodec.encode(shortChannelId :: timestamp :: flags :: cltvExpiryDelta :: htlcMinimumMsat :: feeBaseMsat :: feeProportionalMillionths :: HNil))))
|
||||
|
@ -218,12 +218,12 @@ object LightningMessageCodecs {
|
||||
("bitcoinSignature" | signature)).as[AnnouncementSignatures]
|
||||
|
||||
val channelAnnouncementWitnessCodec = (
|
||||
("shortChannelId" | int64) ::
|
||||
("features" | varsizebinarydata) ::
|
||||
("shortChannelId" | int64) ::
|
||||
("nodeId1" | publicKey) ::
|
||||
("nodeId2" | publicKey) ::
|
||||
("bitcoinKey1" | publicKey) ::
|
||||
("bitcoinKey2" | publicKey) ::
|
||||
("features" | varsizebinarydata))
|
||||
("bitcoinKey2" | publicKey))
|
||||
|
||||
val channelAnnouncementCodec: Codec[ChannelAnnouncement] = (
|
||||
("nodeSignature1" | signature) ::
|
||||
@ -233,11 +233,11 @@ object LightningMessageCodecs {
|
||||
channelAnnouncementWitnessCodec).as[ChannelAnnouncement]
|
||||
|
||||
val nodeAnnouncementWitnessCodec = (
|
||||
("timestamp" | uint32) ::
|
||||
("features" | varsizebinarydata) ::
|
||||
("timestamp" | uint32) ::
|
||||
("nodeId" | publicKey) ::
|
||||
("rgbColor" | rgb) ::
|
||||
("alias" | zeropaddedstring(32)) ::
|
||||
("features" | varsizebinarydata) ::
|
||||
("addresses" | listofsocketaddresses))
|
||||
|
||||
val nodeAnnouncementCodec: Codec[NodeAnnouncement] = (
|
||||
|
@ -126,19 +126,19 @@ case class ChannelAnnouncement(nodeSignature1: BinaryData,
|
||||
nodeSignature2: BinaryData,
|
||||
bitcoinSignature1: BinaryData,
|
||||
bitcoinSignature2: BinaryData,
|
||||
features: BinaryData,
|
||||
shortChannelId: Long,
|
||||
nodeId1: PublicKey,
|
||||
nodeId2: PublicKey,
|
||||
bitcoinKey1: PublicKey,
|
||||
bitcoinKey2: PublicKey,
|
||||
features: BinaryData) extends RoutingMessage
|
||||
bitcoinKey2: PublicKey) extends RoutingMessage
|
||||
|
||||
case class NodeAnnouncement(signature: BinaryData,
|
||||
features: BinaryData,
|
||||
timestamp: Long,
|
||||
nodeId: PublicKey,
|
||||
rgbColor: (Byte, Byte, Byte),
|
||||
alias: String,
|
||||
features: BinaryData,
|
||||
// TODO: check address order + support padding data (type 0)
|
||||
addresses: List[InetSocketAddress]) extends RoutingMessage
|
||||
|
||||
|
@ -183,8 +183,8 @@ class LightningMessageCodecsSpec extends FunSuite {
|
||||
val update_fail_malformed_htlc = UpdateFailMalformedHtlc(randomBytes(32), 2, randomBytes(32), 1111)
|
||||
val commit_sig = CommitSig(randomBytes(32), randomSignature, randomSignature :: randomSignature :: randomSignature :: Nil)
|
||||
val revoke_and_ack = RevokeAndAck(randomBytes(32), scalar(0), point(1))
|
||||
val channel_announcement = ChannelAnnouncement(randomSignature, randomSignature, randomSignature, randomSignature, 1, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, bin(7, 9))
|
||||
val node_announcement = NodeAnnouncement(randomSignature, 1, randomKey.publicKey, (100.toByte, 200.toByte, 300.toByte), "node-alias", bin(0, 0), new InetSocketAddress(InetAddress.getByAddress(Array[Byte](192.toByte, 168.toByte, 1.toByte, 42.toByte)), 42000) :: Nil)
|
||||
val channel_announcement = ChannelAnnouncement(randomSignature, randomSignature, randomSignature, randomSignature, bin(7, 9), 1, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey, randomKey.publicKey)
|
||||
val node_announcement = NodeAnnouncement(randomSignature, bin(0, 0), 1, randomKey.publicKey, (100.toByte, 200.toByte, 300.toByte), "node-alias", new InetSocketAddress(InetAddress.getByAddress(Array[Byte](192.toByte, 168.toByte, 1.toByte, 42.toByte)), 42000) :: Nil)
|
||||
val channel_update = ChannelUpdate(randomSignature, 1, 2, bin(2, 2), 3, 4, 5, 6)
|
||||
val announcement_signatures = AnnouncementSignatures(randomBytes(32), 42, randomSignature, randomSignature)
|
||||
val ping = Ping(100, BinaryData("01" * 10))
|
||||
|
Loading…
Reference in New Issue
Block a user