Skip to content

Commit

Permalink
Require explicit channel type negotiation
Browse files Browse the repository at this point in the history
This feature was introduced by lightning/bolts#880

We also clean up the channel state machine to leverage the feature bits
added in #237
  • Loading branch information
t-bast committed Aug 24, 2021
1 parent 9d576dc commit 1542d72
Show file tree
Hide file tree
Showing 47 changed files with 2,615 additions and 550 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ object TestConstants {

object Alice {
private val entropy = Hex.decode("0101010101010101010101010101010101010101010101010101010101010101")
val mnemonics = MnemonicCode.toMnemonics(entropy)
val seed = MnemonicCode.toSeed(mnemonics, "").toByteVector32()
private val mnemonics = MnemonicCode.toMnemonics(entropy)
private val seed = MnemonicCode.toSeed(mnemonics, "").toByteVector32()

val keyManager = LocalKeyManager(seed, Block.RegtestGenesisBlock.hash)
val walletParams = WalletParams(NodeUri(randomKey().publicKey(), "alice.com", 9735), trampolineFees, InvoiceDefaultRoutingFees(1_000.msat, 100, CltvExpiryDelta(144)))
Expand All @@ -54,12 +54,10 @@ object TestConstants {
Feature.StaticRemoteKey to FeatureSupport.Mandatory,
Feature.AnchorOutputs to FeatureSupport.Mandatory,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.ZeroReserveChannels to FeatureSupport.Optional,
Feature.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
Feature.ChannelBackupClient to FeatureSupport.Optional,
Feature.WakeUpNotificationProvider to FeatureSupport.Optional,
Feature.PayToOpenProvider to FeatureSupport.Optional,
Feature.TrustedSwapInProvider to FeatureSupport.Optional,
Feature.ChannelBackupProvider to FeatureSupport.Optional,
),
dustLimit = 1_100.sat,
maxRemoteDustLimit = 1_500.sat,
Expand Down Expand Up @@ -100,7 +98,7 @@ object TestConstants {
enableTrampolinePayment = true
)

val closingPubKeyInfo = keyManager.closingPubkeyScript(PublicKey.Generator)
private val closingPubKeyInfo = keyManager.closingPubkeyScript(PublicKey.Generator)
val channelParams: LocalParams = PeerChannels.makeChannelParams(
nodeParams,
defaultFinalScriptPubkey = ByteVector(closingPubKeyInfo.second),
Expand All @@ -112,7 +110,7 @@ object TestConstants {
object Bob {
private val entropy = Hex.decode("0202020202020202020202020202020202020202020202020202020202020202")
val mnemonics = MnemonicCode.toMnemonics(entropy)
val seed = MnemonicCode.toSeed(mnemonics, "").toByteVector32()
private val seed = MnemonicCode.toSeed(mnemonics, "").toByteVector32()
val keyManager = LocalKeyManager(seed, Block.RegtestGenesisBlock.hash)
val walletParams = WalletParams(NodeUri(randomKey().publicKey(), "bob.com", 9735), trampolineFees, InvoiceDefaultRoutingFees(1_000.msat, 100, CltvExpiryDelta(144)))
val nodeParams = NodeParams(
Expand All @@ -130,8 +128,6 @@ object TestConstants {
Feature.StaticRemoteKey to FeatureSupport.Mandatory,
Feature.AnchorOutputs to FeatureSupport.Mandatory,
Feature.TrampolinePayment to FeatureSupport.Optional,
Feature.ZeroReserveChannels to FeatureSupport.Optional,
Feature.ZeroConfChannels to FeatureSupport.Optional,
Feature.WakeUpNotificationClient to FeatureSupport.Optional,
Feature.PayToOpenClient to FeatureSupport.Optional,
Feature.TrustedSwapInClient to FeatureSupport.Optional,
Expand Down Expand Up @@ -176,7 +172,7 @@ object TestConstants {
enableTrampolinePayment = true
)

val closingPubKeyInfo = keyManager.closingPubkeyScript(PublicKey.Generator)
private val closingPubKeyInfo = keyManager.closingPubkeyScript(PublicKey.Generator)
val channelParams: LocalParams = PeerChannels.makeChannelParams(
nodeParams,
defaultFinalScriptPubkey = ByteVector(closingPubKeyInfo.second),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public suspend fun CoroutineScope.newPeer(
}

val yourLastPerCommitmentSecret = state.commitments.remotePerCommitmentSecrets.lastIndex?.let { state.commitments.remotePerCommitmentSecrets.getHash(it) } ?: ByteVector32.Zeroes
val channelKeyPath = peer.nodeParams.keyManager.channelKeyPath(state.commitments.localParams, state.commitments.channelVersion)
val channelKeyPath = peer.nodeParams.keyManager.channelKeyPath(state.commitments.localParams, state.commitments.channelConfig)
val myCurrentPerCommitmentPoint = peer.nodeParams.keyManager.commitmentPoint(channelKeyPath, state.commitments.localCommit.index)

val channelReestablish = ChannelReestablish(
Expand Down
Loading

0 comments on commit 1542d72

Please sign in to comment.