@@ -286,7 +286,7 @@ object InteractiveTxBuilder {
286
286
localInputs : List [Input .Local ], remoteInputs : List [Input .Remote ],
287
287
localOutputs : List [Output .Local ], remoteOutputs : List [Output .Remote ],
288
288
lockTime : Long ) {
289
- val localAmountIn : MilliSatoshi = sharedInput_opt.map(_.localAmount).getOrElse(0 msat) + localInputs.map(i => i.previousTx. txOut(i.previousTxOutput.toInt) .amount).sum
289
+ val localAmountIn : MilliSatoshi = sharedInput_opt.map(_.localAmount).getOrElse(0 msat) + localInputs.map(i => i.txOut.amount).sum
290
290
val remoteAmountIn : MilliSatoshi = sharedInput_opt.map(_.remoteAmount).getOrElse(0 msat) + remoteInputs.map(_.txOut.amount).sum
291
291
val localAmountOut : MilliSatoshi = sharedOutput.localAmount + localOutputs.map(_.amount).sum
292
292
val remoteAmountOut : MilliSatoshi = sharedOutput.remoteAmount + remoteOutputs.map(_.amount).sum
@@ -814,7 +814,7 @@ private class InteractiveTxBuilder(replyTo: ActorRef[InteractiveTxBuilder.Respon
814
814
// Partially signed PSBT must include spent amounts for all inputs that were signed, and we can "trust" these amounts because they are included
815
815
// in the hash that we signed (see BIP143). If our bitcoin node lied about them, then our signatures are invalid.
816
816
val actualLocalAmountIn = ourWalletInputs.map(i => kmp2scala(response.psbt.getInput(i).getWitnessUtxo.amount)).sum
817
- val expectedLocalAmountIn = unsignedTx.localInputs.map(i => i.previousTx. txOut(i.previousTxOutput.toInt) .amount).sum
817
+ val expectedLocalAmountIn = unsignedTx.localInputs.map(i => i.txOut.amount).sum
818
818
require(actualLocalAmountIn == expectedLocalAmountIn, s " local spent amount $actualLocalAmountIn does not match what we expect ( $expectedLocalAmountIn): bitcoin core may be malicious " )
819
819
val actualLocalAmountOut = ourWalletOutputs.map(i => partiallySignedTx.txOut(i).amount).sum
820
820
val expectedLocalAmountOut = unsignedTx.localOutputs.map {
@@ -888,9 +888,9 @@ object InteractiveTxSigningSession {
888
888
private def shouldSignFirst (isInitiator : Boolean , channelParams : ChannelParams , tx : SharedTransaction ): Boolean = {
889
889
val sharedAmountIn = tx.sharedInput_opt.map(i => i.localAmount + i.remoteAmount + i.htlcAmount).getOrElse(0 msat).truncateToSatoshi
890
890
val (localAmountIn, remoteAmountIn) = if (isInitiator) {
891
- (sharedAmountIn + tx.localInputs.map(i => i.previousTx. txOut(i.previousTxOutput.toInt) .amount).sum, tx.remoteInputs.map(i => i.txOut.amount).sum)
891
+ (sharedAmountIn + tx.localInputs.map(i => i.txOut.amount).sum, tx.remoteInputs.map(i => i.txOut.amount).sum)
892
892
} else {
893
- (tx.localInputs.map(i => i.previousTx. txOut(i.previousTxOutput.toInt) .amount).sum, sharedAmountIn + tx.remoteInputs.map(i => i.txOut.amount).sum)
893
+ (tx.localInputs.map(i => i.txOut.amount).sum, sharedAmountIn + tx.remoteInputs.map(i => i.txOut.amount).sum)
894
894
}
895
895
if (localAmountIn == remoteAmountIn) {
896
896
// When both peers contribute the same amount, the peer with the lowest pubkey must transmit its `tx_signatures` first.
@@ -932,7 +932,7 @@ object InteractiveTxSigningSession {
932
932
}
933
933
val previousOutputs = {
934
934
val sharedOutput = fundingParams.sharedInput_opt.map(sharedInput => sharedInput.info.outPoint -> sharedInput.info.txOut).toMap
935
- val localOutputs = txWithSigs.tx.localInputs.map(i => i.outPoint -> i.previousTx. txOut(i.previousTxOutput.toInt) ).toMap
935
+ val localOutputs = txWithSigs.tx.localInputs.map(i => i.outPoint -> i.txOut).toMap
936
936
val remoteOutputs = txWithSigs.tx.remoteInputs.map(i => i.outPoint -> i.txOut).toMap
937
937
sharedOutput ++ localOutputs ++ remoteOutputs
938
938
}
0 commit comments