Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip witness of interactive tx parents #2755

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package fr.acinq.eclair.channel.fund

import akka.actor.typed.scaladsl.{ActorContext, Behaviors}
import akka.actor.typed.{ActorRef, Behavior}
import com.softwaremill.quicklens.{ModifyPimp, QuicklensEach}
import fr.acinq.bitcoin.scalacompat.Crypto.PublicKey
import fr.acinq.bitcoin.scalacompat.{KotlinUtils, OutPoint, Satoshi, SatoshiLong, Script, Transaction, TxIn, TxOut}
import fr.acinq.bitcoin.scalacompat.{KotlinUtils, OutPoint, Satoshi, SatoshiLong, Script, ScriptWitness, Transaction, TxIn, TxOut}
import fr.acinq.eclair.blockchain.OnChainChannelFunder
import fr.acinq.eclair.blockchain.fee.FeeratePerKw
import fr.acinq.eclair.channel.fund.InteractiveTxBuilder._
Expand Down Expand Up @@ -295,6 +296,8 @@ private class InteractiveTxFunder(replyTo: ActorRef[InteractiveTxFunder.Response
case _ =>
for {
previousTx <- wallet.getTransaction(txIn.outPoint.txid)
// Strip input witnesses to save space (there is a max size on txs due to lightning message limits).
.map(_.modify(_.txIn.each.witness).setTo(ScriptWitness.empty))
confirmations_opt <- if (fundingParams.requireConfirmedInputs.forLocal) wallet.getTxConfirmations(txIn.outPoint.txid) else Future.successful(None)
} yield {
if (canUseInput(fundingParams, txIn, previousTx, confirmations_opt.getOrElse(0))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class InteractiveTxBuilderSpec extends TestKitBaseClass with AnyFunSuiteLike wit
bob2alice.expectNoMessage(100 millis)
// Alice --- tx_add_input --> Bob
val inputA1 = fwd.forwardAlice2Bob[TxAddInput]
assert(inputA1.previousTx_opt.exists(_.txIn.forall(_.witness == ScriptWitness.empty)), "witnesses must be removed from parent txs to save space")
// Alice <-- tx_add_input --- Bob
val inputB1 = fwd.forwardBob2Alice[TxAddInput]
// Alice --- tx_add_input --> Bob
Expand Down