Skip to content

Commit d2dfd07

Browse files
committed
Fixup: formatting and minor fixes
1 parent 4df0266 commit d2dfd07

File tree

7 files changed

+25
-37
lines changed

7 files changed

+25
-37
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ case class Commitments(params: ChannelParams,
11441144
val fundingScript = Script.write(Scripts.multiSig2of2(localFundingKey, remoteFundingKey))
11451145
commitment.commitInput match {
11461146
case InputInfo.SegwitInput(_, _, redeemScript) => redeemScript == fundingScript
1147-
case _ => false
1147+
case _: InputInfo.TaprootInput => false
11481148
}
11491149
}
11501150
}

eclair-core/src/main/scala/fr/acinq/eclair/channel/publish/ReplaceableTxFunder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private class ReplaceableTxFunder(nodeParams: NodeParams,
360360
// We create a PSBT with the non-wallet input already signed:
361361
val witnessScript = locallySignedTx.txInfo.input match {
362362
case InputInfo.SegwitInput(_, _, redeemScript) => fr.acinq.bitcoin.Script.parse(redeemScript)
363-
case _ => null
363+
case _: InputInfo.TaprootInput => null
364364
}
365365
val psbt = new Psbt(locallySignedTx.txInfo.tx)
366366
.updateWitnessInput(

eclair-core/src/main/scala/fr/acinq/eclair/transactions/Transactions.scala

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = {

eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version0/ChannelCodecs0.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,10 @@ private[channel] object ChannelCodecs0 {
125125
closingTx => closingTx.tx
126126
)
127127

128-
private val legacyInputInfoCodec: Codec[InputInfo.SegwitInput] = (
128+
val inputInfoCodec: Codec[InputInfo] = (
129129
("outPoint" | outPointCodec) ::
130130
("txOut" | txOutCodec) ::
131-
("redeemScript" | varsizebinarydata)).as[InputInfo.SegwitInput].decodeOnly
132-
133-
val inputInfoCodec: Codec[InputInfo] = legacyInputInfoCodec.upcast[InputInfo]
131+
("redeemScript" | varsizebinarydata)).as[InputInfo.SegwitInput].upcast[InputInfo].decodeOnly
134132

135133
private val defaultConfirmationTarget: Codec[ConfirmationTarget.Absolute] = provide(ConfirmationTarget.Absolute(BlockHeight(0)))
136134

eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version1/ChannelCodecs1.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,10 @@ private[channel] object ChannelCodecs1 {
9797
closingTx => closingTx.tx
9898
)
9999

100-
private val legacyInputInfoCodec: Codec[InputInfo.SegwitInput] = (
100+
val inputInfoCodec: Codec[InputInfo] = (
101101
("outPoint" | outPointCodec) ::
102102
("txOut" | txOutCodec) ::
103-
("redeemScript" | lengthDelimited(bytes))).as[InputInfo.SegwitInput].decodeOnly
104-
105-
val inputInfoCodec: Codec[InputInfo] = legacyInputInfoCodec.upcast[InputInfo]
103+
("redeemScript" | lengthDelimited(bytes))).as[InputInfo.SegwitInput].upcast[InputInfo].decodeOnly
106104

107105
private val defaultConfirmationTarget: Codec[ConfirmationTarget.Absolute] = provide(ConfirmationTarget.Absolute(BlockHeight(0)))
108106

eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version2/ChannelCodecs2.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ private[channel] object ChannelCodecs2 {
101101

102102
val txCodec: Codec[Transaction] = lengthDelimited(bytes.xmap(d => Transaction.read(d.toArray), d => Transaction.write(d)))
103103

104-
private val legacyInputInfoCodec: Codec[InputInfo.SegwitInput] = (
104+
val inputInfoCodec: Codec[InputInfo] = (
105105
("outPoint" | outPointCodec) ::
106106
("txOut" | txOutCodec) ::
107-
("redeemScript" | lengthDelimited(bytes))).as[InputInfo.SegwitInput].decodeOnly
108-
109-
val inputInfoCodec: Codec[InputInfo] = legacyInputInfoCodec.upcast[InputInfo]
107+
("redeemScript" | lengthDelimited(bytes))).as[InputInfo.SegwitInput].upcast[InputInfo].decodeOnly
110108

111109
val outputInfoCodec: Codec[OutputInfo] = (
112110
("index" | uint32) ::

eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version3/ChannelCodecs3.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,10 @@ private[channel] object ChannelCodecs3 {
113113

114114
val txCodec: Codec[Transaction] = lengthDelimited(bytes.xmap(d => Transaction.read(d.toArray), d => Transaction.write(d)))
115115

116-
private val legacyInputInfoCodec: Codec[InputInfo.SegwitInput] = (
116+
val inputInfoCodec: Codec[InputInfo] = (
117117
("outPoint" | outPointCodec) ::
118118
("txOut" | txOutCodec) ::
119-
("redeemScript" | lengthDelimited(bytes))).as[InputInfo.SegwitInput].decodeOnly
120-
121-
val inputInfoCodec: Codec[InputInfo] = legacyInputInfoCodec.upcast[InputInfo]
119+
("redeemScript" | lengthDelimited(bytes))).as[InputInfo.SegwitInput].upcast[InputInfo].decodeOnly
122120

123121
val outputInfoCodec: Codec[OutputInfo] = (
124122
("index" | uint32) ::

0 commit comments

Comments
 (0)