Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ object LightningMessageCodecs {
("htlcSignatures" | listofsignatures) ::
("tlvStream" | CommitSigTlv.commitSigTlvCodec)).as[CommitSig]

// This isn't a "real" lightning codec, as we send each commit_sig individually to our peers.
// But it's necessary to send CommitSigBatch objects to front machines when the cluster mode is used.
val commitSigBatchCodec: Codec[CommitSigBatch] = listOfN(uint16, lengthDelimited(commitSigCodec)).xmap(sigs => CommitSigBatch(sigs.toSeq), batch => batch.messages.toList)

val revokeAndAckCodec: Codec[RevokeAndAck] = (
("channelId" | bytes32) ::
("perCommitmentSecret" | privateKey) ::
Expand Down Expand Up @@ -567,7 +571,7 @@ object LightningMessageCodecs {
//
.typecase(39409, recommendedFeeratesCodec)
//

.typecase(53011, commitSigBatchCodec)
//

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import fr.acinq.eclair._
import fr.acinq.eclair.blockchain.fee.FeeratePerKw
import fr.acinq.eclair.channel.ChannelSpendSignature.{IndividualSignature, PartialSignatureWithNonce}
import fr.acinq.eclair.channel.ChannelTypes.SimpleTaprootChannelsPhoenix
import fr.acinq.eclair.channel.{ChannelFlags, ChannelTypes}
import fr.acinq.eclair.channel.{ChannelFlags, ChannelSpendSignature, ChannelTypes}
import fr.acinq.eclair.json.JsonSerializers
import fr.acinq.eclair.reputation.Reputation
import fr.acinq.eclair.router.Announcements
Expand Down Expand Up @@ -696,6 +696,18 @@ class LightningMessageCodecsSpec extends AnyFunSuite {
}
}

test("encode/decode commit_sig batch") {
val channelId = randomBytes32()
val batch = CommitSigBatch(Seq(
CommitSig(channelId, ChannelSpendSignature.IndividualSignature(randomBytes64()), Nil, batchSize = 3),
CommitSig(channelId, ChannelSpendSignature.IndividualSignature(randomBytes64()), Nil, batchSize = 3),
CommitSig(channelId, ChannelSpendSignature.IndividualSignature(randomBytes64()), Nil, batchSize = 3),
))
val encoded = lightningMessageCodec.encode(batch).require
val decoded = lightningMessageCodec.decode(encoded).require.value
assert(decoded == batch)
}

test("unknown messages") {
// Non-standard tag number so this message can only be handled by a codec with a fallback
val unknown = UnknownMessage(tag = 47282, data = ByteVector32.Zeroes.bytes)
Expand Down