Skip to content

Commit

Permalink
Activate static_remotekey by default (#1639)
Browse files Browse the repository at this point in the history
We activate static_remotekey by default (optional).
This is necessary since lnd will start making it mandatory in their next
release.
  • Loading branch information
t-bast authored Dec 15, 2020
1 parent 30735b4 commit 183bdde
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 67 deletions.
3 changes: 2 additions & 1 deletion eclair-core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ eclair {
gossip_queries = optional
gossip_queries_ex = optional
var_onion_optin = optional
option_static_remotekey = disabled
option_static_remotekey = optional
payment_secret = optional
basic_mpp = optional
option_support_large_channel = optional
option_anchor_outputs = disabled
trampoline_payment = disabled
keysend = disabled
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,9 @@ object Helpers {
val tx = revokedCommitPublished.commitTx
val obscuredTxNumber = Transactions.decodeTxNumber(tx.txIn.head.sequence, tx.lockTime)
val channelKeyPath = keyManager.keyPath(localParams, channelVersion)
val localPaymentPoint = localParams.walletStaticPaymentBasepoint.getOrElse(keyManager.paymentPoint(channelKeyPath).publicKey)
// this tx has been published by remote, so we need to invert local/remote params
val txnumber = Transactions.obscuredCommitTxNumber(obscuredTxNumber, !localParams.isFunder, remoteParams.paymentBasepoint, keyManager.paymentPoint(channelKeyPath).publicKey)
val txnumber = Transactions.obscuredCommitTxNumber(obscuredTxNumber, !localParams.isFunder, remoteParams.paymentBasepoint, localPaymentPoint)
// now we know what commit number this tx is referring to, we can derive the commitment point from the shachain
remotePerCommitmentSecrets.getHash(0xFFFFFFFFFFFFL - txnumber)
.map(d => PrivateKey(d))
Expand Down
29 changes: 21 additions & 8 deletions eclair-core/src/test/scala/fr/acinq/eclair/TestConstants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,18 @@ object TestConstants {
alias = "alice",
color = Color(1, 2, 3),
publicAddresses = NodeAddress.fromParts("localhost", 9731).get :: Nil,
features = Features(Set(
ActivatedFeature(InitialRoutingSync, Optional),
ActivatedFeature(OptionDataLossProtect, Optional),
ActivatedFeature(ChannelRangeQueries, Optional),
ActivatedFeature(ChannelRangeQueriesExtended, Optional),
ActivatedFeature(VariableLengthOnion, Optional)),
Set(UnknownFeature(TestFeature.optional))),
features = Features(
Set(
ActivatedFeature(InitialRoutingSync, Optional),
ActivatedFeature(OptionDataLossProtect, Optional),
ActivatedFeature(ChannelRangeQueries, Optional),
ActivatedFeature(ChannelRangeQueriesExtended, Optional),
ActivatedFeature(VariableLengthOnion, Optional),
ActivatedFeature(PaymentSecret, Optional),
ActivatedFeature(BasicMultiPartPayment, Optional)
),
Set(UnknownFeature(TestFeature.optional))
),
pluginParams = List(pluginParams),
overrideFeatures = Map.empty,
syncWhitelist = Set.empty,
Expand Down Expand Up @@ -255,7 +260,15 @@ object TestConstants {
alias = "bob",
color = Color(4, 5, 6),
publicAddresses = NodeAddress.fromParts("localhost", 9732).get :: Nil,
features = Features(Set(ActivatedFeature(VariableLengthOnion, Optional))),
features = Features(Set(
ActivatedFeature(InitialRoutingSync, Optional),
ActivatedFeature(OptionDataLossProtect, Optional),
ActivatedFeature(ChannelRangeQueries, Optional),
ActivatedFeature(ChannelRangeQueriesExtended, Optional),
ActivatedFeature(VariableLengthOnion, Optional),
ActivatedFeature(PaymentSecret, Optional),
ActivatedFeature(BasicMultiPartPayment, Optional)
)),
pluginParams = Nil,
overrideFeatures = Map.empty,
syncWhitelist = Set.empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1138,15 +1138,22 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
awaitCond(alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.size == 1)
val rvk = alice.stateData.asInstanceOf[DATA_CLOSING].revokedCommitPublished.head
assert(rvk.commitTx === bobRevokedTxs.commitTx.tx)
assert(rvk.claimMainOutputTx.nonEmpty)
if (channelVersion.paysDirectlyToWallet) {
assert(rvk.claimMainOutputTx.isEmpty)
} else {
assert(rvk.claimMainOutputTx.nonEmpty)
}
assert(rvk.mainPenaltyTx.nonEmpty)
assert(rvk.htlcPenaltyTxs.size === 4)
assert(rvk.claimHtlcDelayedPenaltyTxs.isEmpty)

// alice publishes the penalty txs and watches outputs
(1 to 6).foreach(_ => alice2blockchain.expectMsgType[PublishAsap]) // 2 main outputs and 4 htlcs
val claimTxsCount = if (channelVersion.paysDirectlyToWallet) 5 else 6 // 2 main outputs and 4 htlcs
(1 to claimTxsCount).foreach(_ => alice2blockchain.expectMsgType[PublishAsap])
assert(alice2blockchain.expectMsgType[WatchConfirmed].txId === rvk.commitTx.txid)
assert(alice2blockchain.expectMsgType[WatchConfirmed].txId === rvk.claimMainOutputTx.get.txid)
if (!channelVersion.paysDirectlyToWallet) {
assert(alice2blockchain.expectMsgType[WatchConfirmed].txId === rvk.claimMainOutputTx.get.txid)
}
(1 to 5).foreach(_ => alice2blockchain.expectMsgType[WatchSpent]) // main output penalty and 4 htlc penalties
alice2blockchain.expectNoMsg(1 second)

Expand Down Expand Up @@ -1197,7 +1204,9 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
assert(remainingHtlcPenaltyTxs.size === 2)
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(rvk.commitTx), 100, 3, rvk.commitTx)
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(rvk.mainPenaltyTx.get), 110, 0, rvk.mainPenaltyTx.get)
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(rvk.claimMainOutputTx.get), 110, 1, rvk.claimMainOutputTx.get)
if (!channelVersion.paysDirectlyToWallet) {
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(rvk.claimMainOutputTx.get), 110, 1, rvk.claimMainOutputTx.get)
}
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(remainingHtlcPenaltyTxs.head), 110, 2, remainingHtlcPenaltyTxs.head)
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(remainingHtlcPenaltyTxs.last), 115, 2, remainingHtlcPenaltyTxs.last)
alice ! WatchEventConfirmed(BITCOIN_TX_CONFIRMED(bobHtlcTimeoutTx.txinfo.tx), 115, 0, bobHtlcTimeoutTx.txinfo.tx)
Expand All @@ -1213,6 +1222,10 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
testOutputSpentRevokedTx(f, ChannelVersion.STANDARD)
}

test("recv BITCOIN_OUTPUT_SPENT (one revoked tx, counterparty published htlc-success tx, option_static_remotekey)", Tag("static_remotekey")) { f =>
testOutputSpentRevokedTx(f, ChannelVersion.STATIC_REMOTEKEY)
}

test("recv BITCOIN_OUTPUT_SPENT (one revoked tx, counterparty published htlc-success tx, anchor outputs)", Tag("anchor_outputs")) { f =>
testOutputSpentRevokedTx(f, ChannelVersion.ANCHOR_OUTPUTS)
}
Expand Down
Loading

0 comments on commit 183bdde

Please sign in to comment.