Skip to content

Commit 8de4883

Browse files
committed
Implement simple taproot channels
This matches changes done on Eclair, and adds support for taproot channels (including splices) with the same TLV extensions. Support for signing commit tx with alternative feerates is not implemented.
1 parent 3e30148 commit 8de4883

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1775
-387
lines changed

modules/core/src/commonMain/kotlin/fr/acinq/lightning/Features.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@ sealed class Feature {
217217
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
218218
}
219219

220+
// README: this is not the feature bit specified in the BOLT, this one is specific to Phoenix
221+
@Serializable
222+
object SimpleTaprootChannels : Feature() {
223+
override val rfcName get() = "simple_taproot_channels"
224+
override val mandatory get() = 564
225+
override val scopes: Set<FeatureScope> get() = setOf(FeatureScope.Init, FeatureScope.Node)
226+
}
220227
}
221228

222229
@Serializable
@@ -294,7 +301,8 @@ data class Features(val activated: Map<Feature, FeatureSupport>, val unknown: Se
294301
Feature.WakeUpNotificationProvider,
295302
Feature.ExperimentalSplice,
296303
Feature.OnTheFlyFunding,
297-
Feature.FundingFeeCredit
304+
Feature.FundingFeeCredit,
305+
Feature.SimpleTaprootChannels
298306
)
299307

300308
operator fun invoke(bytes: ByteVector): Features = invoke(bytes.toByteArray())

modules/core/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelException.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,9 @@ data class PleasePublishYourCommitment (override val channelId: Byte
9292
data class CommandUnavailableInThisState (override val channelId: ByteVector32, val state: String) : ChannelException(channelId, "cannot execute command in state=$state")
9393
data class ForbiddenDuringSplice (override val channelId: ByteVector32, val command: String?) : ChannelException(channelId, "cannot process $command while splicing")
9494
data class InvalidSpliceRequest (override val channelId: ByteVector32) : ChannelException(channelId, "invalid splice request")
95+
data class MissingCommitNonce (override val channelId: ByteVector32, val fundingTxId: TxId, val commitmentNumber: Long) : ChannelException(channelId, "missing commit nonce for funding tx $fundingTxId commitmentNumber $commitmentNumber")
96+
data class InvalidCommitNonce (override val channelId: ByteVector32, val fundingTxId: TxId, val commitmentNumber: Long) : ChannelException(channelId, "invalid commit nonce for funding tx $fundingTxId commitmentNumber $commitmentNumber")
97+
data class MissingFundingNonce (override val channelId: ByteVector32, val fundingTxId: TxId) : ChannelException(channelId, "missing funding nonce for funding tx $fundingTxId")
98+
data class InvalidFundingNonce (override val channelId: ByteVector32, val fundingTxId: TxId) : ChannelException(channelId, "invalid funding nonce for funding tx $fundingTxId")
99+
data class MissingClosingNonce (override val channelId: ByteVector32) : ChannelException(channelId, "missing closing nonce")
95100
// @formatter:on

modules/core/src/commonMain/kotlin/fr/acinq/lightning/channel/ChannelFeatures.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ data class ChannelFeatures(val features: Set<Feature>) {
3232
* In addition to channel types features, the following features will be added to the permanent channel features if they
3333
* are supported by both peers.
3434
*/
35-
private val permanentChannelFeatures = setOf(Feature.DualFunding)
35+
private val permanentChannelFeatures: Set<Feature> = setOf(Feature.DualFunding)
3636
}
3737

3838
}
@@ -65,6 +65,12 @@ sealed class ChannelType {
6565
override val commitmentFormat: Transactions.CommitmentFormat get() = Transactions.CommitmentFormat.AnchorOutputs
6666
}
6767

68+
object SimpleTaprootChannels : SupportedChannelType() {
69+
override val name: String get() = "simple_taproot_channel"
70+
override val features: Set<Feature> get() = setOf(Feature.SimpleTaprootChannels, Feature.ZeroReserveChannels)
71+
override val permanentChannelFeatures: Set<Feature> get() = setOf(Feature.ZeroReserveChannels)
72+
override val commitmentFormat: Transactions.CommitmentFormat get() = Transactions.CommitmentFormat.SimpleTaprootChannels
73+
}
6874
}
6975

7076
data class UnsupportedChannelType(val featureBits: Features) : ChannelType() {
@@ -79,6 +85,7 @@ sealed class ChannelType {
7985
// NB: Bolt 2: features must exactly match in order to identify a channel type.
8086
fun fromFeatures(features: Features): ChannelType = when (features) {
8187
// @formatter:off
88+
Features(Feature.SimpleTaprootChannels to FeatureSupport.Mandatory, Feature.ZeroReserveChannels to FeatureSupport.Mandatory) -> SupportedChannelType.SimpleTaprootChannels
8289
Features(Feature.StaticRemoteKey to FeatureSupport.Mandatory, Feature.AnchorOutputs to FeatureSupport.Mandatory, Feature.ZeroReserveChannels to FeatureSupport.Mandatory) -> SupportedChannelType.AnchorOutputsZeroReserve
8390
Features(Feature.StaticRemoteKey to FeatureSupport.Mandatory, Feature.AnchorOutputs to FeatureSupport.Mandatory) -> SupportedChannelType.AnchorOutputs
8491
else -> UnsupportedChannelType(features)

0 commit comments

Comments
 (0)