@@ -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
@@ -526,14 +526,14 @@ object Helpers {
526526 val channelKeyPath = keyManager.keyPath(commitments.params.localParams, commitments.params.channelConfig)
527527 val localPerCommitmentSecret = keyManager.commitmentSecret(channelKeyPath, commitments.localCommitIndex - 1 )
528528 val localNextPerCommitmentPoint = keyManager.commitmentPoint(channelKeyPath, commitments.localCommitIndex + 1 )
529- val tlvStream : TlvStream [RevokeAndAckTlv ] = if (commitments.params.commitmentFormat.useTaproot) {
530- val nonces = commitments.active.map(c => {
531- val fundingPubkey = keyManager.fundingPublicKey(commitments.params.localParams.fundingKeyPath, c.fundingTxIndex).publicKey
532- keyManager.verificationNonce(c.fundingTxId, fundingPubkey, commitments.localCommitIndex + 1 )
533- })
534- TlvStream (RevokeAndAckTlv .NextLocalNoncesTlv (nonces.map(_._2).toList))
535- } else {
529+ val nonces = commitments.active.filter(_.commitInput.isP2tr).map { c =>
530+ val fundingPubkey = keyManager.fundingPublicKey(commitments.params.localParams.fundingKeyPath, c.fundingTxIndex).publicKey
531+ keyManager.verificationNonce(c.fundingTxId, fundingPubkey, commitments.localCommitIndex + 1 )
532+ }
533+ val tlvStream : TlvStream [RevokeAndAckTlv ] = if (nonces.isEmpty) {
536534 TlvStream .empty
535+ } else {
536+ TlvStream (RevokeAndAckTlv .NextLocalNoncesTlv (nonces.map(_._2).toList))
537537 }
538538 val revocation = RevokeAndAck (
539539 channelId = commitments.channelId,
@@ -723,7 +723,7 @@ object Helpers {
723723 val dummyClosingTxs = Transactions .makeSimpleClosingTxs(commitment.commitInput, commitment.localCommit.spec, SimpleClosingTxFee .PaidByUs (0 sat), currentBlockHeight.toLong, localScriptPubkey, remoteScriptPubkey)
724724 dummyClosingTxs.preferred_opt match {
725725 case Some (dummyTx) =>
726- val dummySignedTx = if (commitment.params.commitmentFormat.useTaproot ) {
726+ val dummySignedTx = if (commitment.commitInput.isP2tr ) {
727727 Transactions .addAggregatedSignature(dummyTx, Transactions .PlaceHolderSig )
728728 } else {
729729 Transactions .addSigs(dummyTx, Transactions .PlaceHolderPubKey , Transactions .PlaceHolderPubKey , Transactions .PlaceHolderSig , Transactions .PlaceHolderSig )
@@ -739,7 +739,7 @@ object Helpers {
739739 case _ => return Left (CannotGenerateClosingTx (commitment.channelId))
740740 }
741741 val localFundingPubKey = keyManager.fundingPublicKey(commitment.localParams.fundingKeyPath, commitment.fundingTxIndex)
742- val tlvs = if (commitment.params.commitmentFormat.useTaproot ) {
742+ val tlvs = if (commitment.commitInput.isP2tr ) {
743743 def partialSign (tx : ClosingTx ) = {
744744 val Right (psig) = keyManager.partialSign(tx, localFundingPubKey, commitment.remoteFundingPubKey, TxOwner .Local , localClosingNonce_opt.get, remoteClosingNonce_opt.get)
745745 psig
@@ -773,7 +773,7 @@ object Helpers {
773773 val closingTxs = Transactions .makeSimpleClosingTxs(commitment.commitInput, commitment.localCommit.spec, closingFee, closingComplete.lockTime, localScriptPubkey, remoteScriptPubkey)
774774 // If our output isn't dust, they must provide a signature for a transaction that includes it.
775775 // Note that we're the closee, so we look for signatures including the closee output.
776- if (commitment.params.commitmentFormat.useTaproot ) {
776+ if (commitment.commitInput.isP2tr ) {
777777 (closingTxs.localAndRemote_opt, closingTxs.localOnly_opt) match {
778778 case (Some (_), Some (_)) if closingComplete.closerAndCloseeOutputsPartialSig_opt.isEmpty && closingComplete.closeeOutputOnlyPartialSig_opt.isEmpty => return Left (MissingCloseSignature (commitment.channelId))
779779 case (Some (_), None ) if closingComplete.closerAndCloseeOutputsPartialSig_opt.isEmpty => return Left (MissingCloseSignature (commitment.channelId))
@@ -789,7 +789,7 @@ object Helpers {
789789 }
790790 }
791791
792- if (commitment.params.commitmentFormat.useTaproot ) {
792+ if (commitment.commitInput.isP2tr ) {
793793 // We choose the closing signature that matches our preferred closing transaction.
794794 val closingTxsWithSigs = Seq (
795795 closingComplete.closerAndCloseeOutputsPartialSig_opt.flatMap(remoteSig => closingTxs.localAndRemote_opt.map(tx => (tx, remoteSig, localSig => ClosingTlv .CloserAndCloseeOutputsPartialSignature (localSig)))),
@@ -838,7 +838,7 @@ object Helpers {
838838 * for their next closing_sig that will match our latest closing_complete.
839839 */
840840 def receiveSimpleClosingSig (keyManager : ChannelKeyManager , commitment : FullCommitment , closingTxs : ClosingTxs , closingSig : ClosingSig , localNonce : Option [(SecretNonce , IndividualNonce )] = None , remoteNonce : Option [IndividualNonce ] = None ): Either [ChannelException , ClosingTx ] = {
841- if (commitment.params.commitmentFormat.useTaproot ) {
841+ if (commitment.commitInput.isP2tr ) {
842842 val closingTxsWithSig = Seq (
843843 closingSig.closerAndCloseeOutputsPartialSig_opt.flatMap(sig => closingTxs.localAndRemote_opt.map(tx => (tx, sig))),
844844 closingSig.closerOutputOnlyPartialSig_opt.flatMap(sig => closingTxs.localOnly_opt.map(tx => (tx, sig))),
@@ -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