@@ -660,7 +660,7 @@ object Helpers {
660
660
def firstClosingFee (commitment : FullCommitment , localScriptPubkey : ByteVector , remoteScriptPubkey : ByteVector , feerates : ClosingFeerates )(implicit log : LoggingAdapter ): ClosingFees = {
661
661
// this is just to estimate the weight, it depends on size of the pubkey scripts
662
662
val dummyClosingTx = Transactions .makeClosingTx(commitment.commitInput, localScriptPubkey, remoteScriptPubkey, commitment.localParams.paysClosingFees, Satoshi (0 ), Satoshi (0 ), commitment.localCommit.spec)
663
- val closingWeight = Transaction .weight(Transactions .addSigs(dummyClosingTx, Transactions .PlaceHolderPubKey , commitment.remoteFundingPubKey, Transactions .PlaceHolderSig , Transactions .PlaceHolderSig ).tx)
663
+ val closingWeight = Transaction .weight(dummyClosingTx .addSigs(Transactions .PlaceHolderPubKey , commitment.remoteFundingPubKey, Transactions .PlaceHolderSig , Transactions .PlaceHolderSig ).tx)
664
664
log.info(s " using feerates= $feerates for initial closing tx " )
665
665
feerates.computeFees(closingWeight)
666
666
}
@@ -703,7 +703,7 @@ object Helpers {
703
703
def checkClosingSignature (channelKeys : ChannelKeys , commitment : FullCommitment , localScriptPubkey : ByteVector , remoteScriptPubkey : ByteVector , remoteClosingFee : Satoshi , remoteClosingSig : ByteVector64 )(implicit log : LoggingAdapter ): Either [ChannelException , (ClosingTx , ClosingSigned )] = {
704
704
val (closingTx, closingSigned) = makeClosingTx(channelKeys, commitment, localScriptPubkey, remoteScriptPubkey, ClosingFees (remoteClosingFee, remoteClosingFee, remoteClosingFee))
705
705
if (checkClosingDustAmounts(closingTx)) {
706
- val signedClosingTx = Transactions .addSigs(closingTx, channelKeys.fundingKey(commitment.fundingTxIndex).publicKey, commitment.remoteFundingPubKey, closingSigned.signature, remoteClosingSig)
706
+ val signedClosingTx = closingTx .addSigs(channelKeys.fundingKey(commitment.fundingTxIndex).publicKey, commitment.remoteFundingPubKey, closingSigned.signature, remoteClosingSig)
707
707
Transactions .checkSpendable(signedClosingTx) match {
708
708
case Success (_) => Right (signedClosingTx, closingSigned)
709
709
case _ => Left (InvalidCloseSignature (commitment.channelId, signedClosingTx.tx.txid))
@@ -720,7 +720,7 @@ object Helpers {
720
720
val dummyClosingTxs = Transactions .makeSimpleClosingTxs(commitment.commitInput, commitment.localCommit.spec, SimpleClosingTxFee .PaidByUs (0 sat), currentBlockHeight.toLong, localScriptPubkey, remoteScriptPubkey)
721
721
dummyClosingTxs.preferred_opt match {
722
722
case Some (dummyTx) =>
723
- val dummySignedTx = Transactions .addSigs(dummyTx, Transactions .PlaceHolderPubKey , Transactions .PlaceHolderPubKey , Transactions .PlaceHolderSig , Transactions .PlaceHolderSig )
723
+ val dummySignedTx = dummyTx .addSigs(Transactions .PlaceHolderPubKey , Transactions .PlaceHolderPubKey , Transactions .PlaceHolderSig , Transactions .PlaceHolderSig )
724
724
SimpleClosingTxFee .PaidByUs (Transactions .weight2fee(feerate, dummySignedTx.tx.weight()))
725
725
case None => return Left (CannotGenerateClosingTx (commitment.channelId))
726
726
}
@@ -767,7 +767,7 @@ object Helpers {
767
767
case Some ((closingTx, remoteSig, sigToTlv)) =>
768
768
val localFundingKey = channelKeys.fundingKey(commitment.fundingTxIndex)
769
769
val localSig = closingTx.sign(localFundingKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
770
- val signedClosingTx = Transactions .addSigs(closingTx, localFundingKey.publicKey, commitment.remoteFundingPubKey, localSig, remoteSig)
770
+ val signedClosingTx = closingTx .addSigs(localFundingKey.publicKey, commitment.remoteFundingPubKey, localSig, remoteSig)
771
771
Transactions .checkSpendable(signedClosingTx) match {
772
772
case Failure (_) => Left (InvalidCloseSignature (commitment.channelId, signedClosingTx.tx.txid))
773
773
case Success (_) => Right (signedClosingTx, ClosingSig (commitment.channelId, remoteScriptPubkey, localScriptPubkey, closingComplete.fees, closingComplete.lockTime, TlvStream (sigToTlv(localSig))))
@@ -793,7 +793,7 @@ object Helpers {
793
793
case Some ((closingTx, remoteSig)) =>
794
794
val localFundingKey = channelKeys.fundingKey(commitment.fundingTxIndex)
795
795
val localSig = closingTx.sign(localFundingKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
796
- val signedClosingTx = Transactions .addSigs(closingTx, localFundingKey.publicKey, commitment.remoteFundingPubKey, localSig, remoteSig)
796
+ val signedClosingTx = closingTx .addSigs(localFundingKey.publicKey, commitment.remoteFundingPubKey, localSig, remoteSig)
797
797
Transactions .checkSpendable(signedClosingTx) match {
798
798
case Failure (_) => Left (InvalidCloseSignature (commitment.channelId, signedClosingTx.tx.txid))
799
799
case Success (_) => Right (signedClosingTx)
@@ -874,7 +874,7 @@ object Helpers {
874
874
val mainDelayedTx = withTxGenerationLog(" local-main-delayed" ) {
875
875
Transactions .makeClaimLocalDelayedOutputTx(commitmentKeys, commitTx, commitment.localParams.dustLimit, commitment.remoteParams.toSelfDelay, finalScriptPubKey, feeratePerKwDelayed).map(claimDelayed => {
876
876
val sig = claimDelayed.sign(commitmentKeys.ourDelayedPaymentKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
877
- Transactions .addSigs(claimDelayed, sig)
877
+ claimDelayed .addSigs(sig)
878
878
})
879
879
}
880
880
@@ -932,7 +932,7 @@ object Helpers {
932
932
// We immediately spend incoming htlcs for which we have the preimage.
933
933
Some (txInfo.input.outPoint -> withTxGenerationLog(" htlc-success" ) {
934
934
val localSig = txInfo.sign(commitKeys.ourHtlcKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
935
- Right (Transactions .addSigs(txInfo, localSig, remoteSig, hash2Preimage(paymentHash), commitment.params.commitmentFormat))
935
+ Right (txInfo .addSigs(localSig, remoteSig, hash2Preimage(paymentHash), commitment.params.commitmentFormat))
936
936
})
937
937
} else if (failedIncomingHtlcs.contains(txInfo.htlcId)) {
938
938
// We can ignore incoming htlcs that we started failing: our peer will claim them after the timeout.
@@ -953,7 +953,7 @@ object Helpers {
953
953
// back after the timeout.
954
954
Some (txInfo.input.outPoint -> withTxGenerationLog(" htlc-timeout" ) {
955
955
val localSig = txInfo.sign(commitKeys.ourHtlcKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
956
- Right (Transactions .addSigs(txInfo, localSig, remoteSig, commitment.params.commitmentFormat))
956
+ Right (txInfo .addSigs(localSig, remoteSig, commitment.params.commitmentFormat))
957
957
})
958
958
}.flatten.toMap
959
959
}
@@ -973,7 +973,7 @@ object Helpers {
973
973
// if our peer was able to claim the HTLC output before us (race condition between success and timeout).
974
974
Transactions .makeHtlcDelayedTx(commitKeys, tx, commitment.localParams.dustLimit, commitment.remoteParams.toSelfDelay, finalScriptPubKey, feeratePerKwDelayed).map(claimDelayed => {
975
975
val sig = claimDelayed.sign(commitKeys.ourDelayedPaymentKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
976
- Transactions .addSigs(claimDelayed, sig)
976
+ claimDelayed .addSigs(sig)
977
977
})
978
978
}
979
979
val localCommitPublished1 = localCommitPublished.copy(claimHtlcDelayedTxs = localCommitPublished.claimHtlcDelayedTxs ++ htlcDelayedTx_opt.toSeq)
@@ -1048,13 +1048,13 @@ object Helpers {
1048
1048
case DefaultCommitmentFormat => withTxGenerationLog(" remote-main" ) {
1049
1049
Transactions .makeClaimP2WPKHOutputTx(commitKeys, commitTx, params.localParams.dustLimit, finalScriptPubKey, feeratePerKwMain).map(claimMain => {
1050
1050
val sig = claimMain.sign(ourPaymentKey, TxOwner .Local , params.commitmentFormat, Map .empty)
1051
- Transactions .addSigs(claimMain, commitKeys, sig)
1051
+ claimMain .addSigs(commitKeys, sig)
1052
1052
})
1053
1053
}
1054
1054
case _ : AnchorOutputsCommitmentFormat => withTxGenerationLog(" remote-main-delayed" ) {
1055
1055
Transactions .makeClaimRemoteDelayedOutputTx(commitKeys, commitTx, params.localParams.dustLimit, finalScriptPubKey, feeratePerKwMain).map(claimMain => {
1056
1056
val sig = claimMain.sign(ourPaymentKey, TxOwner .Local , params.commitmentFormat, Map .empty)
1057
- Transactions .addSigs(claimMain, sig)
1057
+ claimMain .addSigs(sig)
1058
1058
})
1059
1059
}
1060
1060
}
@@ -1094,7 +1094,7 @@ object Helpers {
1094
1094
// We immediately spend incoming htlcs for which we have the preimage.
1095
1095
Some (claimHtlcTx.input.outPoint -> withTxGenerationLog(" claim-htlc-success" ) {
1096
1096
val sig = claimHtlcTx.sign(commitKeys.ourHtlcKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
1097
- Right (Transactions .addSigs(claimHtlcTx, sig, hash2Preimage(add.paymentHash)))
1097
+ Right (claimHtlcTx .addSigs(sig, hash2Preimage(add.paymentHash)))
1098
1098
})
1099
1099
} else if (failedIncomingHtlcs.contains(add.id)) {
1100
1100
// We can ignore incoming htlcs that we started failing: our peer will claim them after the timeout.
@@ -1120,7 +1120,7 @@ object Helpers {
1120
1120
}.map(claimHtlcTx => {
1121
1121
Some (claimHtlcTx.input.outPoint -> withTxGenerationLog(" claim-htlc-timeout" ) {
1122
1122
val sig = claimHtlcTx.sign(commitKeys.ourHtlcKey, TxOwner .Local , commitment.params.commitmentFormat, Map .empty)
1123
- Right (Transactions .addSigs(claimHtlcTx, sig))
1123
+ Right (claimHtlcTx .addSigs(sig))
1124
1124
})
1125
1125
})
1126
1126
}.toSeq.flatten.flatten.toMap
@@ -1182,13 +1182,13 @@ object Helpers {
1182
1182
case DefaultCommitmentFormat => withTxGenerationLog(" remote-main" ) {
1183
1183
Transactions .makeClaimP2WPKHOutputTx(commitKeys, commitTx, localParams.dustLimit, finalScriptPubKey, feerateMain).map(claimMain => {
1184
1184
val sig = claimMain.sign(ourPaymentKey, TxOwner .Local , commitmentFormat, Map .empty)
1185
- Transactions .addSigs(claimMain, commitKeys, sig)
1185
+ claimMain .addSigs(commitKeys, sig)
1186
1186
})
1187
1187
}
1188
1188
case _ : AnchorOutputsCommitmentFormat => withTxGenerationLog(" remote-main-delayed" ) {
1189
1189
Transactions .makeClaimRemoteDelayedOutputTx(commitKeys, commitTx, localParams.dustLimit, finalScriptPubKey, feerateMain).map(claimMain => {
1190
1190
val sig = claimMain.sign(ourPaymentKey, TxOwner .Local , commitmentFormat, Map .empty)
1191
- Transactions .addSigs(claimMain, sig)
1191
+ claimMain .addSigs(sig)
1192
1192
})
1193
1193
}
1194
1194
}
@@ -1198,7 +1198,7 @@ object Helpers {
1198
1198
val mainPenaltyTx = withTxGenerationLog(" main-penalty" ) {
1199
1199
Transactions .makeMainPenaltyTx(commitKeys, commitTx, localParams.dustLimit, finalScriptPubKey, localParams.toSelfDelay, feeratePenalty).map(txinfo => {
1200
1200
val sig = txinfo.sign(revocationKey, TxOwner .Local , commitmentFormat, Map .empty)
1201
- Transactions .addSigs(txinfo, sig)
1201
+ txinfo .addSigs(sig)
1202
1202
})
1203
1203
}
1204
1204
@@ -1216,9 +1216,9 @@ object Helpers {
1216
1216
val htlcPenaltyTxs = commitTx.txOut.zipWithIndex.collect { case (txOut, outputIndex) if htlcsRedeemScripts.contains(txOut.publicKeyScript) =>
1217
1217
val htlcRedeemScript = htlcsRedeemScripts(txOut.publicKeyScript)
1218
1218
withTxGenerationLog(" htlc-penalty" ) {
1219
- Transactions .makeHtlcPenaltyTx(commitTx, outputIndex, htlcRedeemScript, localParams.dustLimit, finalScriptPubKey, feeratePenalty).map(htlcPenalty => {
1219
+ Transactions .makeHtlcPenaltyTx(commitKeys, commitTx, outputIndex, htlcRedeemScript, localParams.dustLimit, finalScriptPubKey, feeratePenalty).map(htlcPenalty => {
1220
1220
val sig = htlcPenalty.sign(revocationKey, TxOwner .Local , commitmentFormat, Map .empty)
1221
- Transactions .addSigs(htlcPenalty, commitKeys, sig)
1221
+ htlcPenalty .addSigs(commitKeys, sig)
1222
1222
})
1223
1223
}
1224
1224
}.toList.flatten
@@ -1264,7 +1264,7 @@ object Helpers {
1264
1264
withTxGenerationLog(" htlc-delayed-penalty" ) {
1265
1265
claimHtlcDelayedOutputPenaltyTx.map(htlcDelayedPenalty => {
1266
1266
val sig = htlcDelayedPenalty.sign(revocationKey, TxOwner .Local , params.commitmentFormat, Map .empty)
1267
- val signedTx = Transactions .addSigs(htlcDelayedPenalty, sig)
1267
+ val signedTx = htlcDelayedPenalty .addSigs(sig)
1268
1268
// We need to make sure that the tx is indeed valid.
1269
1269
Transaction .correctlySpends(signedTx.tx, Seq (htlcTx), ScriptFlags .STANDARD_SCRIPT_VERIFY_FLAGS )
1270
1270
log.warning(" txId={} is a 2nd level htlc tx spending revoked commit txId={}: publishing htlc-penalty txId={}" , htlcTx.txid, revokedCommitPublished.commitTx.txid, signedTx.tx.txid)
0 commit comments