Skip to content

Commit caac917

Browse files
committed
Simplify how to create taproot transactions
1 parent bfc7c84 commit caac917

File tree

4 files changed

+224
-214
lines changed

4 files changed

+224
-214
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,36 +1446,6 @@ case class Commitments(params: ChannelParams,
14461446
def resolveCommitment(shortChannelId: RealShortChannelId): Option[Commitment] = {
14471447
all.find(c => c.shortChannelId_opt.contains(shortChannelId))
14481448
}
1449-
1450-
/**
1451-
* Generate local verification nonces for a specific funding tx index and commit tx index
1452-
*
1453-
* @param keyManager key manager that will generate actual nonces
1454-
* @param fundingIndex funding tx index
1455-
* @param commitIndex commit tx index
1456-
* @return a public nonce for thr provided fundint tx index and commit tx index if taproot is used, None otherwise
1457-
*/
1458-
def generateLocalNonce(keyManager: ChannelKeyManager, fundingIndex: Long, commitIndex: Long): Option[IndividualNonce] = {
1459-
if (latest.params.commitmentFormat.useTaproot) {
1460-
val localFundingKey = keyManager.fundingPublicKey(params.localParams.fundingKeyPath, latest.fundingTxIndex).publicKey
1461-
Some(keyManager.verificationNonce(latest.fundingTxId, localFundingKey, commitIndex)._2)
1462-
} else {
1463-
None
1464-
}
1465-
}
1466-
1467-
/**
1468-
* Create local verification nonces a specific funding tx index and a range of commit tx indexes
1469-
*
1470-
* @param keyManager key manager that will generate actual nonces
1471-
* @param fundingIndex funding tx index
1472-
* @param commitIndexes range of commit tx indexes
1473-
* @return a list of nonces if raproot is used, or an empty list
1474-
*/
1475-
def generateLocalNonces(keyManager: ChannelKeyManager, fundingIndex: Long, commitIndexes: Long*): List[IndividualNonce] = {
1476-
commitIndexes.toList.flatMap(commitIndex => generateLocalNonce(keyManager, fundingIndex, commitIndex))
1477-
}
1478-
14791449
}
14801450

14811451
object Commitments {

eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ object Helpers {
463463
/**
464464
* Check whether we are in sync with our peer.
465465
*/
466-
def checkSync(keyManager: ChannelKeyManager, commitments: Commitments, remoteChannelReestablish: ChannelReestablish)(implicit log: LoggingAdapter): SyncResult = {
466+
def checkSync(keyManager: ChannelKeyManager, commitments: Commitments, remoteChannelReestablish: ChannelReestablish): SyncResult = {
467467

468468
// This is done in two steps:
469469
// - step 1: we check our local commitment
@@ -948,7 +948,7 @@ object Helpers {
948948

949949
// first we will claim our main output as soon as the delay is over
950950
val mainDelayedTx = withTxGenerationLog("local-main-delayed") {
951-
Transactions.makeClaimLocalDelayedOutputTx(tx, commitment.localParams.dustLimit, localRevocationPubkey, commitment.remoteParams.toSelfDelay, localDelayedPubkey, finalScriptPubKey, feeratePerKwDelayed, commitment.params.commitmentFormat).map(claimDelayed => {
951+
Transactions.makeClaimLocalDelayedOutputTx(tx, commitment.localParams.dustLimit, localRevocationPubkey, commitment.remoteParams.toSelfDelay, localDelayedPubkey, finalScriptPubKey, feeratePerKwDelayed).map(claimDelayed => {
952952
val sig = keyManager.sign(claimDelayed, keyManager.delayedPaymentPoint(channelKeyPath), localPerCommitmentPoint, TxOwner.Local, commitment.params.commitmentFormat)
953953
Transactions.addSigs(claimDelayed, sig)
954954
})
@@ -992,10 +992,10 @@ object Helpers {
992992
}
993993
val claimAnchorTxs = List(
994994
withTxGenerationLog("local-anchor") {
995-
Transactions.makeClaimLocalAnchorOutputTx(lcp.commitTx, localPaymentKey, confirmationTarget, commitment.params.commitmentFormat)
995+
Transactions.makeClaimLocalAnchorOutputTx(lcp.commitTx, localPaymentKey, confirmationTarget)
996996
},
997997
withTxGenerationLog("remote-anchor") {
998-
Transactions.makeClaimRemoteAnchorOutputTx(lcp.commitTx, remotePaymentKey, commitment.params.commitmentFormat)
998+
Transactions.makeClaimRemoteAnchorOutputTx(lcp.commitTx, remotePaymentKey)
999999
}
10001000
).flatten
10011001
lcp.copy(claimAnchorTxs = claimAnchorTxs)
@@ -1062,7 +1062,7 @@ object Helpers {
10621062
val localRevocationPubkey = Generators.revocationPubKey(commitment.remoteParams.revocationBasepoint, localPerCommitmentPoint)
10631063
val localDelayedPubkey = Generators.derivePubKey(keyManager.delayedPaymentPoint(channelKeyPath).publicKey, localPerCommitmentPoint)
10641064
val htlcDelayedTx = withTxGenerationLog("htlc-delayed") {
1065-
Transactions.makeHtlcDelayedTx(tx, commitment.localParams.dustLimit, localRevocationPubkey, commitment.remoteParams.toSelfDelay, localDelayedPubkey, finalScriptPubKey, feeratePerKwDelayed, commitment.params.commitmentFormat).map(claimDelayed => {
1065+
Transactions.makeHtlcDelayedTx(tx, commitment.localParams.dustLimit, localRevocationPubkey, commitment.remoteParams.toSelfDelay, localDelayedPubkey, finalScriptPubKey, feeratePerKwDelayed).map(claimDelayed => {
10661066
val sig = keyManager.sign(claimDelayed, keyManager.delayedPaymentPoint(channelKeyPath), localPerCommitmentPoint, TxOwner.Local, commitment.params.commitmentFormat)
10671067
Transactions.addSigs(claimDelayed, sig)
10681068
})
@@ -1127,10 +1127,10 @@ object Helpers {
11271127
}
11281128
val claimAnchorTxs = List(
11291129
withTxGenerationLog("local-anchor") {
1130-
Transactions.makeClaimLocalAnchorOutputTx(rcp.commitTx, localPaymentKey, confirmationTarget, commitment.params.commitmentFormat)
1130+
Transactions.makeClaimLocalAnchorOutputTx(rcp.commitTx, localPaymentKey, confirmationTarget)
11311131
},
11321132
withTxGenerationLog("remote-anchor") {
1133-
Transactions.makeClaimRemoteAnchorOutputTx(rcp.commitTx, remotePaymentKey, commitment.params.commitmentFormat)
1133+
Transactions.makeClaimRemoteAnchorOutputTx(rcp.commitTx, remotePaymentKey)
11341134
}
11351135
).flatten
11361136
rcp.copy(claimAnchorTxs = claimAnchorTxs)
@@ -1164,7 +1164,7 @@ object Helpers {
11641164
})
11651165
}
11661166
case _: AnchorOutputsCommitmentFormat => withTxGenerationLog("remote-main-delayed") {
1167-
Transactions.makeClaimRemoteDelayedOutputTx(tx, params.localParams.dustLimit, localPaymentPoint, finalScriptPubKey, feeratePerKwMain, params.commitmentFormat).map(claimMain => {
1167+
Transactions.makeClaimRemoteDelayedOutputTx(tx, params.localParams.dustLimit, localPaymentPoint, finalScriptPubKey, feeratePerKwMain).map(claimMain => {
11681168
val sig = keyManager.sign(claimMain, keyManager.paymentPoint(channelKeyPath), TxOwner.Local, params.commitmentFormat)
11691169
Transactions.addSigs(claimMain, sig)
11701170
})
@@ -1300,7 +1300,7 @@ object Helpers {
13001300
})
13011301
}
13021302
case _: AnchorOutputsCommitmentFormat => withTxGenerationLog("remote-main-delayed") {
1303-
Transactions.makeClaimRemoteDelayedOutputTx(commitTx, localParams.dustLimit, localPaymentPoint, finalScriptPubKey, feerateMain, commitmentFormat).map(claimMain => {
1303+
Transactions.makeClaimRemoteDelayedOutputTx(commitTx, localParams.dustLimit, localPaymentPoint, finalScriptPubKey, feerateMain).map(claimMain => {
13041304
val sig = keyManager.sign(claimMain, keyManager.paymentPoint(channelKeyPath), TxOwner.Local, commitmentFormat)
13051305
Transactions.addSigs(claimMain, sig)
13061306
})
@@ -1310,7 +1310,7 @@ object Helpers {
13101310

13111311
// then we punish them by stealing their main output
13121312
val mainPenaltyTx = withTxGenerationLog("main-penalty") {
1313-
Transactions.makeMainPenaltyTx(commitTx, localParams.dustLimit, remoteRevocationPubkey, finalScriptPubKey, localParams.toSelfDelay, remoteDelayedPaymentPubkey, feeratePenalty, commitmentFormat).map(txinfo => {
1313+
Transactions.makeMainPenaltyTx(commitTx, localParams.dustLimit, remoteRevocationPubkey, finalScriptPubKey, localParams.toSelfDelay, remoteDelayedPaymentPubkey, feeratePenalty).map(txinfo => {
13141314
val sig = keyManager.sign(txinfo, keyManager.revocationPoint(channelKeyPath), remotePerCommitmentSecret, TxOwner.Local, commitmentFormat)
13151315
Transactions.addSigs(txinfo, sig)
13161316
})

0 commit comments

Comments
 (0)