@@ -138,25 +138,21 @@ object Transactions {
138138 def sighash (txOwner : TxOwner , commitmentFormat : CommitmentFormat ): Int = SIGHASH_ALL
139139
140140 def sign (key : PrivateKey , txOwner : TxOwner , commitmentFormat : CommitmentFormat ): ByteVector64 = {
141- // NB: the tx may have multiple inputs, we will only sign the one provided in txinfo.input. Bear in mind that the
142- // signature will be invalidated if other inputs are added *afterwards* and sighashType was SIGHASH_ALL.
143141 sign(key, sighash(txOwner, commitmentFormat))
144142 }
145143
146144 def sign (key : PrivateKey , sighashType : Int ): ByteVector64 = input match {
147- case _:InputInfo .TaprootInput => ByteVector64 .Zeroes
145+ case _ : InputInfo .TaprootInput => ByteVector64 .Zeroes
148146 case InputInfo .SegwitInput (outPoint, txOut, redeemScript) =>
149147 // NB: the tx may have multiple inputs, we will only sign the one provided in txinfo.input. Bear in mind that the
150148 // signature will be invalidated if other inputs are added *afterwards* and sighashType was SIGHASH_ALL.
151149 val inputIndex = tx.txIn.indexWhere(_.outPoint == outPoint)
152150 val sigDER = Transaction .signInput(tx, inputIndex, redeemScript, sighashType, txOut.amount, SIGVERSION_WITNESS_V0 , key)
153- val sig64 = Crypto .der2compact(sigDER)
154- sig64
151+ Crypto .der2compact(sigDER)
155152 }
156153
157154 def checkSig (sig : ByteVector64 , pubKey : PublicKey , txOwner : TxOwner , commitmentFormat : CommitmentFormat ): Boolean = input match {
158-
159- case _:InputInfo .TaprootInput => false
155+ case _ : InputInfo .TaprootInput => false
160156 case InputInfo .SegwitInput (outPoint, txOut, redeemScript) =>
161157 val sighash = this .sighash(txOwner, commitmentFormat)
162158 val inputIndex = tx.txIn.indexWhere(_.outPoint == outPoint)
@@ -189,7 +185,7 @@ object Transactions {
189185 * The next time we introduce a new type of commitment, we should avoid repeating that mistake and define separate
190186 * types right from the start.
191187 */
192- sealed trait HtlcTx extends ReplaceableTransactionWithInputInfo {
188+ sealed trait HtlcTx /**/ extends ReplaceableTransactionWithInputInfo {
193189 def htlcId : Long
194190 override def sighash (txOwner : TxOwner , commitmentFormat : CommitmentFormat ): Int = commitmentFormat match {
195191 case DefaultCommitmentFormat => SIGHASH_ALL
@@ -905,42 +901,42 @@ object Transactions {
905901 case InputInfo .SegwitInput (_, _, redeemScript) =>
906902 val witness = Scripts .witnessToLocalDelayedWithRevocationSig(revocationSig, redeemScript)
907903 mainPenaltyTx.copy(tx = mainPenaltyTx.tx.updateWitness(0 , witness))
908- case _ => mainPenaltyTx
904+ case _ : InputInfo . TaprootInput => mainPenaltyTx
909905 }
910906
911907 def addSigs (htlcPenaltyTx : HtlcPenaltyTx , revocationSig : ByteVector64 , revocationPubkey : PublicKey ): HtlcPenaltyTx = htlcPenaltyTx.input match {
912908 case InputInfo .SegwitInput (_, _, redeemScript) =>
913909 val witness = Scripts .witnessHtlcWithRevocationSig(revocationSig, revocationPubkey, redeemScript)
914910 htlcPenaltyTx.copy(tx = htlcPenaltyTx.tx.updateWitness(0 , witness))
915- case _ => htlcPenaltyTx
911+ case _ : InputInfo . TaprootInput => htlcPenaltyTx
916912 }
917913
918914 def addSigs (htlcSuccessTx : HtlcSuccessTx , localSig : ByteVector64 , remoteSig : ByteVector64 , paymentPreimage : ByteVector32 , commitmentFormat : CommitmentFormat ): HtlcSuccessTx = htlcSuccessTx.input match {
919915 case InputInfo .SegwitInput (_, _, redeemScript) =>
920916 val witness = witnessHtlcSuccess(localSig, remoteSig, paymentPreimage, redeemScript, commitmentFormat)
921917 htlcSuccessTx.copy(tx = htlcSuccessTx.tx.updateWitness(0 , witness))
922- case _ => htlcSuccessTx
918+ case _ : InputInfo . TaprootInput => htlcSuccessTx
923919 }
924920
925921 def addSigs (htlcTimeoutTx : HtlcTimeoutTx , localSig : ByteVector64 , remoteSig : ByteVector64 , commitmentFormat : CommitmentFormat ): HtlcTimeoutTx = htlcTimeoutTx.input match {
926922 case InputInfo .SegwitInput (_, _, redeemScript) =>
927923 val witness = witnessHtlcTimeout(localSig, remoteSig, redeemScript, commitmentFormat)
928924 htlcTimeoutTx.copy(tx = htlcTimeoutTx.tx.updateWitness(0 , witness))
929- case _ => htlcTimeoutTx
925+ case _ : InputInfo . TaprootInput => htlcTimeoutTx
930926 }
931927
932928 def addSigs (claimHtlcSuccessTx : ClaimHtlcSuccessTx , localSig : ByteVector64 , paymentPreimage : ByteVector32 ): ClaimHtlcSuccessTx = claimHtlcSuccessTx.input match {
933929 case InputInfo .SegwitInput (_, _, redeemScript) =>
934930 val witness = witnessClaimHtlcSuccessFromCommitTx(localSig, paymentPreimage, redeemScript)
935931 claimHtlcSuccessTx.copy(tx = claimHtlcSuccessTx.tx.updateWitness(0 , witness))
936- case _ => claimHtlcSuccessTx
932+ case _ : InputInfo . TaprootInput => claimHtlcSuccessTx
937933 }
938934
939935 def addSigs (claimHtlcTimeoutTx : ClaimHtlcTimeoutTx , localSig : ByteVector64 ): ClaimHtlcTimeoutTx = claimHtlcTimeoutTx.input match {
940936 case InputInfo .SegwitInput (_, _, redeemScript) =>
941937 val witness = witnessClaimHtlcTimeoutFromCommitTx(localSig, redeemScript)
942938 claimHtlcTimeoutTx.copy(tx = claimHtlcTimeoutTx.tx.updateWitness(0 , witness))
943- case _ => claimHtlcTimeoutTx
939+ case _ : InputInfo . TaprootInput => claimHtlcTimeoutTx
944940 }
945941
946942 def addSigs (claimP2WPKHOutputTx : ClaimP2WPKHOutputTx , localPaymentPubkey : PublicKey , localSig : ByteVector64 ): ClaimP2WPKHOutputTx = {
@@ -952,35 +948,35 @@ object Transactions {
952948 case InputInfo .SegwitInput (_, _, redeemScript) =>
953949 val witness = witnessClaimToRemoteDelayedFromCommitTx(localSig, redeemScript)
954950 claimRemoteDelayedOutputTx.copy(tx = claimRemoteDelayedOutputTx.tx.updateWitness(0 , witness))
955- case _ => claimRemoteDelayedOutputTx
951+ case _ : InputInfo . TaprootInput => claimRemoteDelayedOutputTx
956952 }
957953
958954 def addSigs (claimDelayedOutputTx : ClaimLocalDelayedOutputTx , localSig : ByteVector64 ): ClaimLocalDelayedOutputTx = claimDelayedOutputTx.input match {
959955 case InputInfo .SegwitInput (_, _, redeemScript) =>
960956 val witness = witnessToLocalDelayedAfterDelay(localSig, redeemScript)
961957 claimDelayedOutputTx.copy(tx = claimDelayedOutputTx.tx.updateWitness(0 , witness))
962- case _ => claimDelayedOutputTx
958+ case _ : InputInfo . TaprootInput => claimDelayedOutputTx
963959 }
964960
965961 def addSigs (htlcDelayedTx : HtlcDelayedTx , localSig : ByteVector64 ): HtlcDelayedTx = htlcDelayedTx.input match {
966962 case InputInfo .SegwitInput (_, _, redeemScript) =>
967963 val witness = witnessToLocalDelayedAfterDelay(localSig, redeemScript)
968964 htlcDelayedTx.copy(tx = htlcDelayedTx.tx.updateWitness(0 , witness))
969- case _ => htlcDelayedTx
965+ case _ : InputInfo . TaprootInput => htlcDelayedTx
970966 }
971967
972968 def addSigs (claimAnchorOutputTx : ClaimLocalAnchorOutputTx , localSig : ByteVector64 ): ClaimLocalAnchorOutputTx = claimAnchorOutputTx.input match {
973969 case InputInfo .SegwitInput (_, _, redeemScript) =>
974970 val witness = witnessAnchor(localSig, redeemScript)
975971 claimAnchorOutputTx.copy(tx = claimAnchorOutputTx.tx.updateWitness(0 , witness))
976- case _ => claimAnchorOutputTx
972+ case _ : InputInfo . TaprootInput => claimAnchorOutputTx
977973 }
978974
979975 def addSigs (claimHtlcDelayedPenalty : ClaimHtlcDelayedOutputPenaltyTx , revocationSig : ByteVector64 ): ClaimHtlcDelayedOutputPenaltyTx = claimHtlcDelayedPenalty.input match {
980976 case InputInfo .SegwitInput (_, _, redeemScript) =>
981977 val witness = Scripts .witnessToLocalDelayedWithRevocationSig(revocationSig, redeemScript)
982978 claimHtlcDelayedPenalty.copy(tx = claimHtlcDelayedPenalty.tx.updateWitness(0 , witness))
983- case _ => claimHtlcDelayedPenalty
979+ case _ : InputInfo . TaprootInput => claimHtlcDelayedPenalty
984980 }
985981
986982 def addSigs (closingTx : ClosingTx , localFundingPubkey : PublicKey , remoteFundingPubkey : PublicKey , localSig : ByteVector64 , remoteSig : ByteVector64 ): ClosingTx = {
0 commit comments