Skip to content

Commit dfe40be

Browse files
authored
Provide channel origin tlv in the reader object (#233)
Otherwise we can write the tlv but not read it. A regression happened due to conflict between 4343838 and 7dfe46a, now fixed.
1 parent 7dfe46a commit dfe40be

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/commonMain/kotlin/fr/acinq/eclair/wire/ChannelTlv.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,14 @@ sealed class ChannelTlv : Tlv {
6464
is ChannelOrigin.PayToOpenOrigin -> {
6565
LightningCodecs.writeU16(1, out)
6666
LightningCodecs.writeBytes(channelOrigin.paymentHash, out)
67+
LightningCodecs.writeU64(channelOrigin.fee.toLong(), out)
6768
}
6869
is ChannelOrigin.SwapInOrigin -> {
6970
LightningCodecs.writeU16(2, out)
7071
val addressBytes = channelOrigin.bitcoinAddress.encodeToByteArray()
7172
LightningCodecs.writeBigSize(addressBytes.size.toLong(), out)
7273
LightningCodecs.writeBytes(addressBytes, out)
74+
LightningCodecs.writeU64(channelOrigin.fee.toLong(), out)
7375
}
7476
}
7577
}

src/commonMain/kotlin/fr/acinq/eclair/wire/LightningMessages.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ data class OpenChannel(
319319
@Suppress("UNCHECKED_CAST")
320320
val readers = mapOf(
321321
ChannelTlv.UpfrontShutdownScript.tag to ChannelTlv.UpfrontShutdownScript.Companion as TlvValueReader<ChannelTlv>,
322-
ChannelTlv.ChannelVersionTlv.tag to ChannelTlv.ChannelVersionTlv.Companion as TlvValueReader<ChannelTlv>
322+
ChannelTlv.ChannelVersionTlv.tag to ChannelTlv.ChannelVersionTlv.Companion as TlvValueReader<ChannelTlv>,
323+
ChannelTlv.ChannelOriginTlv.tag to ChannelTlv.ChannelOriginTlv.Companion as TlvValueReader<ChannelTlv>
323324
)
324325
return OpenChannel(
325326
ByteVector32(LightningCodecs.bytes(input, 32)),

src/commonTest/kotlin/fr/acinq/eclair/wire/LightningCodecsTestsCommon.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import fr.acinq.eclair.Features
1212
import fr.acinq.eclair.MilliSatoshi
1313
import fr.acinq.eclair.ShortChannelId
1414
import fr.acinq.eclair.blockchain.fee.FeeratePerKw
15+
import fr.acinq.eclair.channel.ChannelOrigin
1516
import fr.acinq.eclair.crypto.assertArrayEquals
1617
import fr.acinq.eclair.tests.utils.EclairTestSuite
1718
import fr.acinq.eclair.utils.msat
@@ -264,7 +265,10 @@ class LightningCodecsTestsCommon : EclairTestSuite() {
264265
)
265266
),
266267
// non-empty upfront_shutdown_script + unknown odd tlv records
267-
defaultEncoded + ByteVector("0002 1234 0303010203") to defaultOpen.copy(tlvStream = TlvStream(listOf(ChannelTlv.UpfrontShutdownScript(ByteVector("1234"))), listOf(GenericTlv(3L, ByteVector("010203")))))
268+
defaultEncoded + ByteVector("0002 1234 0303010203") to defaultOpen.copy(tlvStream = TlvStream(listOf(ChannelTlv.UpfrontShutdownScript(ByteVector("1234"))), listOf(GenericTlv(3L, ByteVector("010203"))))),
269+
// channel origin tlv records
270+
defaultEncoded + ByteVector("fe47000005 2a 0001 187bf923f7f11ef732b73c417eb5a57cd4667b20a6f130ff505cd7ad3ab87281 00000000000004d2") to defaultOpen.copy(tlvStream = TlvStream(listOf(ChannelTlv.ChannelOriginTlv(ChannelOrigin.PayToOpenOrigin(ByteVector32.fromValidHex("187bf923f7f11ef732b73c417eb5a57cd4667b20a6f130ff505cd7ad3ab87281"), 1234.sat))))),
271+
defaultEncoded + ByteVector("fe47000005 2d 0002 223341754d3868536b584265746a644878577468524669483668596871463250726a72 00000000000001a4") to defaultOpen.copy(tlvStream = TlvStream(listOf(ChannelTlv.ChannelOriginTlv(ChannelOrigin.SwapInOrigin("3AuM8hSkXBetjdHxWthRFiH6hYhqF2Prjr", 420.sat)))))
268272
)
269273

270274
testCases.forEach {

0 commit comments

Comments
 (0)