mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-12 10:30:45 +01:00
Fixup: create and match segwit and taproot inputs explicitly
This commit is contained in:
parent
4031de9092
commit
09bd7e550b
16 changed files with 40 additions and 48 deletions
|
@ -43,7 +43,7 @@ trait SpendFromChannelAddress {
|
|||
inputTx <- appKit.wallet.getTransaction(outPoint.txid)
|
||||
localFundingPubkey = appKit.nodeParams.channelKeyManager.fundingPublicKey(fundingKeyPath, fundingTxIndex)
|
||||
fundingRedeemScript = multiSig2of2(localFundingPubkey.publicKey, remoteFundingPubkey)
|
||||
inputInfo = InputInfo(outPoint, inputTx.txOut(outPoint.index.toInt), fundingRedeemScript)
|
||||
inputInfo = InputInfo.SegwitInput(outPoint, inputTx.txOut(outPoint.index.toInt), fundingRedeemScript)
|
||||
localSig = appKit.nodeParams.channelKeyManager.sign(
|
||||
Transactions.SpliceTx(inputInfo, unsignedTx), // classify as splice, doesn't really matter
|
||||
localFundingPubkey,
|
||||
|
|
|
@ -1025,10 +1025,9 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
|
|||
val parentCommitment = d.commitments.latest.commitment
|
||||
val localFundingPubKey = nodeParams.channelKeyManager.fundingPublicKey(d.commitments.params.localParams.fundingKeyPath, parentCommitment.fundingTxIndex + 1).publicKey
|
||||
val fundingScript = Funding.makeFundingPubKeyScript(localFundingPubKey, msg.fundingPubKey, d.commitments.latest.params.commitmentFormat)
|
||||
val sharedInput = if (d.commitments.latest.commitInput.isP2tr) {
|
||||
Musig2Input(parentCommitment)
|
||||
} else {
|
||||
Multisig2of2Input(parentCommitment)
|
||||
val sharedInput = d.commitments.latest.commitInput match {
|
||||
case _: Transactions.InputInfo.TaprootInput => Musig2Input(parentCommitment)
|
||||
case _ => Multisig2of2Input(parentCommitment)
|
||||
}
|
||||
LiquidityAds.validateRequest(nodeParams.privateKey, d.channelId, fundingScript, msg.feerate, isChannelCreation = false, msg.requestFunding_opt, nodeParams.liquidityAdsConfig.rates_opt, msg.useFeeCredit_opt) match {
|
||||
case Left(t) =>
|
||||
|
@ -1087,10 +1086,9 @@ class Channel(val nodeParams: NodeParams, val wallet: OnChainChannelFunder with
|
|||
case SpliceStatus.SpliceRequested(cmd, spliceInit) =>
|
||||
log.info("our peer accepted our splice request and will contribute {} to the funding transaction", msg.fundingContribution)
|
||||
val parentCommitment = d.commitments.latest.commitment
|
||||
val sharedInput = if (d.commitments.latest.commitInput.isP2tr) {
|
||||
Musig2Input(parentCommitment)
|
||||
} else {
|
||||
Multisig2of2Input(parentCommitment)
|
||||
val sharedInput = d.commitments.latest.commitInput match {
|
||||
case _: Transactions.InputInfo.TaprootInput => Musig2Input(parentCommitment)
|
||||
case _ => Multisig2of2Input(parentCommitment)
|
||||
}
|
||||
val fundingParams = InteractiveTxParams(
|
||||
channelId = d.channelId,
|
||||
|
|
|
@ -112,7 +112,6 @@ object Transactions {
|
|||
sealed trait InputInfo {
|
||||
val outPoint: OutPoint
|
||||
val txOut: TxOut
|
||||
val isP2tr: Boolean = Try(Script.isPay2tr(Script.parse(txOut.publicKeyScript))).getOrElse(false)
|
||||
}
|
||||
|
||||
object InputInfo {
|
||||
|
@ -121,11 +120,6 @@ object Transactions {
|
|||
def apply(outPoint: OutPoint, txOut: TxOut, redeemScript: Seq[ScriptElt]) = new SegwitInput(outPoint, txOut, Script.write(redeemScript))
|
||||
}
|
||||
case class TaprootInput(outPoint: OutPoint, txOut: TxOut, internalKey: XonlyPublicKey, scriptTree_opt: Option[ScriptTree], leaf: ByteVector32) extends InputInfo
|
||||
|
||||
|
||||
def apply(outPoint: OutPoint, txOut: TxOut, redeemScript: ByteVector): SegwitInput = SegwitInput(outPoint, txOut, redeemScript)
|
||||
def apply(outPoint: OutPoint, txOut: TxOut, redeemScript: Seq[ScriptElt]): SegwitInput = SegwitInput(outPoint, txOut, Script.write(redeemScript))
|
||||
//def apply(outPoint: OutPoint, txOut: TxOut, internalKey: XonlyPublicKey, scriptTree_opt: Option[ScriptTree]): TaprootInput = TaprootInput(outPoint, txOut, internalKey, scriptTree_opt)
|
||||
}
|
||||
|
||||
/** Owner of a given transaction (local/remote). */
|
||||
|
@ -756,7 +750,7 @@ object Transactions {
|
|||
)
|
||||
Right(HtlcSuccessTx(input, tx, htlc.paymentHash, htlc.id, ConfirmationTarget.Absolute(BlockHeight(htlc.cltvExpiry.toLong))))
|
||||
case s: CommitmentOutputLink.SegwitLink[InHtlc] =>
|
||||
val input = InputInfo(OutPoint(commitTx, outputIndex), commitTx.txOut(outputIndex), s.redeemScript)
|
||||
val input = InputInfo.SegwitInput(OutPoint(commitTx, outputIndex), commitTx.txOut(outputIndex), s.redeemScript)
|
||||
val tx = Transaction(
|
||||
version = 2,
|
||||
txIn = TxIn(input.outPoint, ByteVector.empty, getHtlcTxInputSequence(commitmentFormat)) :: Nil,
|
||||
|
@ -882,7 +876,7 @@ object Transactions {
|
|||
findPubKeyScriptIndex(commitTx, pubkeyScript) match {
|
||||
case Left(skip) => Left(skip)
|
||||
case Right(outputIndex) =>
|
||||
val input = InputInfo(OutPoint(commitTx, outputIndex), commitTx.txOut(outputIndex), write(redeemScript))
|
||||
val input = InputInfo.SegwitInput(OutPoint(commitTx, outputIndex), commitTx.txOut(outputIndex), write(redeemScript))
|
||||
// unsigned tx
|
||||
val tx = Transaction(
|
||||
version = 2,
|
||||
|
@ -1167,7 +1161,7 @@ object Transactions {
|
|||
* We already have the redeemScript, no need to build it
|
||||
*/
|
||||
def makeHtlcPenaltyTx(commitTx: Transaction, htlcOutputIndex: Int, redeemScript: ByteVector, localDustLimit: Satoshi, localFinalScriptPubKey: ByteVector, feeratePerKw: FeeratePerKw): Either[TxGenerationSkipped, HtlcPenaltyTx] = {
|
||||
val input = InputInfo(OutPoint(commitTx, htlcOutputIndex), commitTx.txOut(htlcOutputIndex), redeemScript)
|
||||
val input = InputInfo.SegwitInput(OutPoint(commitTx, htlcOutputIndex), commitTx.txOut(htlcOutputIndex), redeemScript)
|
||||
// unsigned transaction
|
||||
val tx = Transaction(
|
||||
version = 2,
|
||||
|
|
|
@ -48,7 +48,7 @@ private[channel] object ChannelTypes0 {
|
|||
// modified: we don't use the InputInfo in closing business logic, so we don't need to fill everything (this part
|
||||
// assumes that we only have standard channels, no anchor output channels - which was the case before version2).
|
||||
val input = childTx.txIn.head.outPoint
|
||||
InputInfo(input, parentTx.txOut(input.index.toInt), Nil)
|
||||
InputInfo.SegwitInput(input, parentTx.txOut(input.index.toInt), Nil)
|
||||
}
|
||||
|
||||
case class LocalCommitPublished(commitTx: Transaction, claimMainDelayedOutputTx: Option[Transaction], htlcSuccessTxs: List[Transaction], htlcTimeoutTxs: List[Transaction], claimHtlcDelayedTxs: List[Transaction], irrevocablySpent: Map[OutPoint, TxId]) {
|
||||
|
@ -97,7 +97,7 @@ private[channel] object ChannelTypes0 {
|
|||
val htlcPenaltyTxsNew = htlcPenaltyTxs.map(tx => HtlcPenaltyTx(getPartialInputInfo(commitTx, tx), tx))
|
||||
val claimHtlcDelayedPenaltyTxsNew = claimHtlcDelayedPenaltyTxs.map(tx => {
|
||||
// We don't have all the `InputInfo` data, but it's ok: we only use the tx that is fully signed.
|
||||
ClaimHtlcDelayedOutputPenaltyTx(InputInfo(tx.txIn.head.outPoint, TxOut(Satoshi(0), Nil), Nil), tx)
|
||||
ClaimHtlcDelayedOutputPenaltyTx(InputInfo.SegwitInput(tx.txIn.head.outPoint, TxOut(Satoshi(0), Nil), Nil), tx)
|
||||
})
|
||||
channel.RevokedCommitPublished(commitTx, claimMainOutputTxNew, mainPenaltyTxNew, htlcPenaltyTxsNew, claimHtlcDelayedPenaltyTxsNew, irrevocablySpentNew)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ private[channel] object ChannelTypes0 {
|
|||
* the raw transaction. It provides more information for auditing but is not used for business logic, so we can safely
|
||||
* put dummy values in the migration.
|
||||
*/
|
||||
def migrateClosingTx(tx: Transaction): ClosingTx = ClosingTx(InputInfo(tx.txIn.head.outPoint, TxOut(Satoshi(0), Nil), Nil), tx, None)
|
||||
def migrateClosingTx(tx: Transaction): ClosingTx = ClosingTx(InputInfo.SegwitInput(tx.txIn.head.outPoint, TxOut(Satoshi(0), Nil), Nil), tx, None)
|
||||
|
||||
case class HtlcTxAndSigs(txinfo: HtlcTx, localSig: ByteVector64, remoteSig: ByteVector64)
|
||||
|
||||
|
|
|
@ -600,8 +600,8 @@ class ChannelDataSpec extends TestKitBaseClass with AnyFunSuiteLike with Channel
|
|||
case (current, tx) => Closing.updateRevokedCommitPublished(current, tx)
|
||||
}.copy(
|
||||
claimHtlcDelayedPenaltyTxs = List(
|
||||
ClaimHtlcDelayedOutputPenaltyTx(InputInfo(OutPoint(htlcSuccess, 0), TxOut(2_500 sat, Nil), Nil), Transaction(2, Seq(TxIn(OutPoint(htlcSuccess, 0), ByteVector.empty, 0)), Seq(TxOut(5_000 sat, ByteVector.empty)), 0)),
|
||||
ClaimHtlcDelayedOutputPenaltyTx(InputInfo(OutPoint(htlcTimeout, 0), TxOut(3_000 sat, Nil), Nil), Transaction(2, Seq(TxIn(OutPoint(htlcTimeout, 0), ByteVector.empty, 0)), Seq(TxOut(6_000 sat, ByteVector.empty)), 0))
|
||||
ClaimHtlcDelayedOutputPenaltyTx(InputInfo.SegwitInput(OutPoint(htlcSuccess, 0), TxOut(2_500 sat, Nil), Nil), Transaction(2, Seq(TxIn(OutPoint(htlcSuccess, 0), ByteVector.empty, 0)), Seq(TxOut(5_000 sat, ByteVector.empty)), 0)),
|
||||
ClaimHtlcDelayedOutputPenaltyTx(InputInfo.SegwitInput(OutPoint(htlcTimeout, 0), TxOut(3_000 sat, Nil), Nil), Transaction(2, Seq(TxIn(OutPoint(htlcTimeout, 0), ByteVector.empty, 0)), Seq(TxOut(6_000 sat, ByteVector.empty)), 0))
|
||||
)
|
||||
)
|
||||
assert(!rvk4b.isDone)
|
||||
|
|
|
@ -492,7 +492,7 @@ object CommitmentsSpec {
|
|||
val localFundingPubKey = randomKey().publicKey
|
||||
val remoteFundingPubKey = randomKey().publicKey
|
||||
val fundingTx = Transaction(2, Nil, Seq(TxOut((toLocal + toRemote).truncateToSatoshi, Funding.makeFundingPubKeyScript(localFundingPubKey, remoteFundingPubKey, DefaultCommitmentFormat))), 0)
|
||||
val commitmentInput = Transactions.InputInfo(OutPoint(fundingTx, 0), fundingTx.txOut.head, Scripts.multiSig2of2(localFundingPubKey, remoteFundingPubKey))
|
||||
val commitmentInput = Transactions.InputInfo.SegwitInput(OutPoint(fundingTx, 0), fundingTx.txOut.head, Scripts.multiSig2of2(localFundingPubKey, remoteFundingPubKey))
|
||||
val localCommit = LocalCommit(0, CommitmentSpec(Set.empty, feeRatePerKw, toLocal, toRemote), CommitTxAndRemoteSig(CommitTx(commitmentInput, Transaction(2, Nil, Nil, 0)), ByteVector64.Zeroes), Nil)
|
||||
val remoteCommit = RemoteCommit(0, CommitmentSpec(Set.empty, feeRatePerKw, toRemote, toLocal), randomTxId(), randomKey().publicKey)
|
||||
val localFundingStatus = announcement_opt match {
|
||||
|
@ -517,7 +517,7 @@ object CommitmentsSpec {
|
|||
val localFundingPubKey = randomKey().publicKey
|
||||
val remoteFundingPubKey = randomKey().publicKey
|
||||
val fundingTx = Transaction(2, Nil, Seq(TxOut((toLocal + toRemote).truncateToSatoshi, Funding.makeFundingPubKeyScript(localFundingPubKey, remoteFundingPubKey, DefaultCommitmentFormat))), 0)
|
||||
val commitmentInput = Transactions.InputInfo(OutPoint(fundingTx, 0), fundingTx.txOut.head, Scripts.multiSig2of2(localFundingPubKey, remoteFundingPubKey))
|
||||
val commitmentInput = Transactions.InputInfo.SegwitInput(OutPoint(fundingTx, 0), fundingTx.txOut.head, Scripts.multiSig2of2(localFundingPubKey, remoteFundingPubKey))
|
||||
val localCommit = LocalCommit(0, CommitmentSpec(Set.empty, FeeratePerKw(0 sat), toLocal, toRemote), CommitTxAndRemoteSig(CommitTx(commitmentInput, Transaction(2, Nil, Nil, 0)), ByteVector64.Zeroes), Nil)
|
||||
val remoteCommit = RemoteCommit(0, CommitmentSpec(Set.empty, FeeratePerKw(0 sat), toRemote, toLocal), randomTxId(), randomKey().publicKey)
|
||||
val localFundingStatus = announcement_opt match {
|
||||
|
|
|
@ -229,7 +229,7 @@ class HelpersSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStat
|
|||
)
|
||||
|
||||
def toClosingTx(txOut: Seq[TxOut]): ClosingTx = {
|
||||
ClosingTx(InputInfo(OutPoint(TxId(ByteVector32.Zeroes), 0), TxOut(1000 sat, Nil), Nil), Transaction(2, Nil, txOut, 0), None)
|
||||
ClosingTx(InputInfo.SegwitInput(OutPoint(TxId(ByteVector32.Zeroes), 0), TxOut(1000 sat, Nil), Nil), Transaction(2, Nil, txOut, 0), None)
|
||||
}
|
||||
|
||||
assert(Closing.MutualClose.checkClosingDustAmounts(toClosingTx(allOutputsAboveDust)))
|
||||
|
@ -249,7 +249,7 @@ class HelpersSpec extends TestKitBaseClass with AnyFunSuiteLike with ChannelStat
|
|||
Transaction.read("0200000001c8a8934fb38a44b969528252bc37be66ee166c7897c57384d1e561449e110c93010000006b483045022100dc6c50f445ed53d2fb41067fdcb25686fe79492d90e6e5db43235726ace247210220773d35228af0800c257970bee9cf75175d75217de09a8ecd83521befd040c4ca012102082b751372fe7e3b012534afe0bb8d1f2f09c724b1a10a813ce704e5b9c217ccfdffffff0247ba2300000000001976a914f97a7641228e6b17d4b0b08252ae75bd62a95fe788ace3de24000000000017a914a9fefd4b9a9282a1d7a17d2f14ac7d1eb88141d287f7d50800"),
|
||||
Transaction.read("010000000235a2f5c4fd48672534cce1ac063047edc38683f43c5a883f815d6026cb5f8321020000006a47304402206be5fd61b1702599acf51941560f0a1e1965aa086634b004967747f79788bd6e022002f7f719a45b8b5e89129c40a9d15e4a8ee1e33be3a891cf32e859823ecb7a510121024756c5adfbc0827478b0db042ce09d9b98e21ad80d036e73bd8e7f0ecbc254a2ffffffffb2387d3125bb8c84a2da83f4192385ce329283661dfc70191f4112c67ce7b4d0000000006b483045022100a2c737eab1c039f79238767ccb9bb3e81160e965ef0fc2ea79e8360c61b7c9f702202348b0f2c0ea2a757e25d375d9be183200ce0a79ec81d6a4ebb2ae4dc31bc3c9012102db16a822e2ec3706c58fc880c08a3617c61d8ef706cc8830cfe4561d9a5d52f0ffffffff01808d5b00000000001976a9141210c32def6b64d0d77ba8d99adeb7e9f91158b988ac00000000"),
|
||||
Transaction.read("0100000001b14ba6952c83f6f8c382befbf4e44270f13e479d5a5ff3862ac3a112f103ff2a010000006b4830450221008b097fd69bfa3715fc5e119a891933c091c55eabd3d1ddae63a1c2cc36dc9a3e02205666d5299fa403a393bcbbf4b05f9c0984480384796cdebcf69171674d00809c01210335b592484a59a44f40998d65a94f9e2eecca47e8d1799342112a59fc96252830ffffffff024bf308000000000017a914440668d018e5e0ba550d6e042abcf726694f515c8798dd1801000000001976a91453a503fe151dd32e0503bd9a2fbdbf4f9a3af1da88ac00000000")
|
||||
).map(tx => ClosingTx(InputInfo(tx.txIn.head.outPoint, TxOut(10_000 sat, Nil), Nil), tx, None))
|
||||
).map(tx => ClosingTx(InputInfo.SegwitInput(tx.txIn.head.outPoint, TxOut(10_000 sat, Nil), Nil), tx, None))
|
||||
|
||||
// only mutual close
|
||||
assert(Closing.isClosingTypeAlreadyKnown(
|
||||
|
|
|
@ -106,7 +106,7 @@ class InteractiveTxBuilderSpec extends TestKitBaseClass with AnyFunSuiteLike wit
|
|||
val fundingPubkeyScript: ByteVector = Script.write(Script.pay2wsh(Scripts.multiSig2of2(fundingParamsB.remoteFundingPubKey, fundingParamsA.remoteFundingPubKey)))
|
||||
|
||||
def dummySharedInputB(amount: Satoshi): SharedFundingInput = {
|
||||
val inputInfo = InputInfo(OutPoint(randomTxId(), 3), TxOut(amount, fundingPubkeyScript), Nil)
|
||||
val inputInfo = InputInfo.SegwitInput(OutPoint(randomTxId(), 3), TxOut(amount, fundingPubkeyScript), Nil)
|
||||
val fundingTxIndex = fundingParamsA.sharedInput_opt match {
|
||||
case Some(input: Multisig2of2Input) => input.fundingTxIndex + 1
|
||||
case _ => 0
|
||||
|
@ -2614,7 +2614,7 @@ class InteractiveTxBuilderSpec extends TestKitBaseClass with AnyFunSuiteLike wit
|
|||
val params = createFixtureParams(100_000 sat, 0 sat, FeeratePerKw(5000 sat), 330 sat, 0)
|
||||
val previousCommitment = CommitmentsSpec.makeCommitments(25_000_000 msat, 50_000_000 msat).active.head
|
||||
val fundingTx = Transaction(2, Nil, Seq(TxOut(50_000 sat, Script.pay2wpkh(randomKey().publicKey)), TxOut(20_000 sat, Script.pay2wpkh(randomKey().publicKey))), 0)
|
||||
val sharedInput = Multisig2of2Input(InputInfo(OutPoint(fundingTx, 0), fundingTx.txOut.head, Nil), 0, randomKey().publicKey)
|
||||
val sharedInput = Multisig2of2Input(InputInfo.SegwitInput(OutPoint(fundingTx, 0), fundingTx.txOut.head, Nil), 0, randomKey().publicKey)
|
||||
val bob = params.spawnTxBuilderSpliceBob(params.fundingParamsB.copy(sharedInput_opt = Some(sharedInput)), previousCommitment, wallet)
|
||||
bob ! Start(probe.ref)
|
||||
// Alice --- tx_add_input --> Bob
|
||||
|
|
|
@ -48,7 +48,7 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike {
|
|||
0
|
||||
)
|
||||
val anchorTx = ClaimLocalAnchorOutputTx(
|
||||
InputInfo(OutPoint(commitTx, 0), commitTx.txOut.head, anchorScript),
|
||||
InputInfo.SegwitInput(OutPoint(commitTx, 0), commitTx.txOut.head, anchorScript),
|
||||
Transaction(2, Seq(TxIn(OutPoint(commitTx, 0), ByteVector.empty, 0)), Nil, 0),
|
||||
ConfirmationTarget.Absolute(BlockHeight(0))
|
||||
)
|
||||
|
@ -67,14 +67,14 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike {
|
|||
0
|
||||
)
|
||||
val htlcSuccess = HtlcSuccessWithWitnessData(HtlcSuccessTx(
|
||||
InputInfo(OutPoint(commitTx, 0), commitTx.txOut.head, htlcSuccessScript),
|
||||
InputInfo.SegwitInput(OutPoint(commitTx, 0), commitTx.txOut.head, htlcSuccessScript),
|
||||
Transaction(2, Seq(TxIn(OutPoint(commitTx, 0), ByteVector.empty, 0)), Seq(TxOut(5000 sat, Script.pay2wpkh(PlaceHolderPubKey))), 0),
|
||||
paymentHash,
|
||||
17,
|
||||
ConfirmationTarget.Absolute(BlockHeight(0))
|
||||
), PlaceHolderSig, preimage)
|
||||
val htlcTimeout = HtlcTimeoutWithWitnessData(HtlcTimeoutTx(
|
||||
InputInfo(OutPoint(commitTx, 1), commitTx.txOut.last, htlcTimeoutScript),
|
||||
InputInfo.SegwitInput(OutPoint(commitTx, 1), commitTx.txOut.last, htlcTimeoutScript),
|
||||
Transaction(2, Seq(TxIn(OutPoint(commitTx, 1), ByteVector.empty, 0)), Seq(TxOut(4000 sat, Script.pay2wpkh(PlaceHolderPubKey))), 0),
|
||||
12,
|
||||
ConfirmationTarget.Absolute(BlockHeight(0))
|
||||
|
@ -88,14 +88,14 @@ class ReplaceableTxFunderSpec extends TestKitBaseClass with AnyFunSuiteLike {
|
|||
val htlcSuccessScript = Scripts.htlcReceived(PlaceHolderPubKey, PlaceHolderPubKey, PlaceHolderPubKey, paymentHash, CltvExpiry(0), ZeroFeeHtlcTxAnchorOutputsCommitmentFormat)
|
||||
val htlcTimeoutScript = Scripts.htlcOffered(PlaceHolderPubKey, PlaceHolderPubKey, PlaceHolderPubKey, randomBytes32(), ZeroFeeHtlcTxAnchorOutputsCommitmentFormat)
|
||||
val claimHtlcSuccess = ClaimHtlcSuccessWithWitnessData(ClaimHtlcSuccessTx(
|
||||
InputInfo(OutPoint(TxId(ByteVector32.Zeroes), 3), TxOut(5000 sat, Script.pay2wsh(htlcSuccessScript)), htlcSuccessScript),
|
||||
InputInfo.SegwitInput(OutPoint(TxId(ByteVector32.Zeroes), 3), TxOut(5000 sat, Script.pay2wsh(htlcSuccessScript)), htlcSuccessScript),
|
||||
Transaction(2, Seq(TxIn(OutPoint(TxId(ByteVector32.Zeroes), 3), ByteVector.empty, 0)), Seq(TxOut(5000 sat, Script.pay2wpkh(PlaceHolderPubKey))), 0),
|
||||
paymentHash,
|
||||
5,
|
||||
ConfirmationTarget.Absolute(BlockHeight(0))
|
||||
), preimage)
|
||||
val claimHtlcTimeout = ClaimHtlcTimeoutWithWitnessData(ClaimHtlcTimeoutTx(
|
||||
InputInfo(OutPoint(TxId(ByteVector32.Zeroes), 7), TxOut(5000 sat, Script.pay2wsh(htlcTimeoutScript)), htlcTimeoutScript),
|
||||
InputInfo.SegwitInput(OutPoint(TxId(ByteVector32.Zeroes), 7), TxOut(5000 sat, Script.pay2wsh(htlcTimeoutScript)), htlcTimeoutScript),
|
||||
Transaction(2, Seq(TxIn(OutPoint(TxId(ByteVector32.Zeroes), 7), ByteVector.empty, 0)), Seq(TxOut(5000 sat, Script.pay2wpkh(PlaceHolderPubKey))), 0),
|
||||
7,
|
||||
ConfirmationTarget.Absolute(BlockHeight(0))
|
||||
|
|
|
@ -107,7 +107,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike {
|
|||
|
||||
val confirmBefore = ConfirmationTarget.Absolute(nodeParams.currentBlockHeight + 12)
|
||||
val input = OutPoint(randomTxId(), 3)
|
||||
val cmd = PublishReplaceableTx(ClaimLocalAnchorOutputTx(InputInfo(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), confirmBefore), null, null)
|
||||
val cmd = PublishReplaceableTx(ClaimLocalAnchorOutputTx(InputInfo.SegwitInput(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), confirmBefore), null, null)
|
||||
txPublisher ! cmd
|
||||
val child = factory.expectMsgType[ReplaceableTxPublisherSpawned].actor
|
||||
val p = child.expectMsgType[ReplaceableTxPublisher.Publish]
|
||||
|
@ -119,7 +119,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike {
|
|||
|
||||
val confirmBefore = nodeParams.currentBlockHeight + 12
|
||||
val input = OutPoint(randomTxId(), 3)
|
||||
val anchorTx = ClaimLocalAnchorOutputTx(InputInfo(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), ConfirmationTarget.Priority(ConfirmationPriority.Medium))
|
||||
val anchorTx = ClaimLocalAnchorOutputTx(InputInfo.SegwitInput(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), ConfirmationTarget.Priority(ConfirmationPriority.Medium))
|
||||
val cmd = PublishReplaceableTx(anchorTx, null, null)
|
||||
txPublisher ! cmd
|
||||
val child = factory.expectMsgType[ReplaceableTxPublisherSpawned].actor
|
||||
|
@ -177,7 +177,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike {
|
|||
val attempt2 = factory.expectMsgType[FinalTxPublisherSpawned].actor
|
||||
attempt2.expectMsgType[FinalTxPublisher.Publish]
|
||||
|
||||
val cmd3 = PublishReplaceableTx(ClaimLocalAnchorOutputTx(InputInfo(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, TxOut(20_000 sat, Nil) :: Nil, 0), ConfirmationTarget.Absolute(nodeParams.currentBlockHeight)), null, null)
|
||||
val cmd3 = PublishReplaceableTx(ClaimLocalAnchorOutputTx(InputInfo.SegwitInput(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, TxOut(20_000 sat, Nil) :: Nil, 0), ConfirmationTarget.Absolute(nodeParams.currentBlockHeight)), null, null)
|
||||
txPublisher ! cmd3
|
||||
val attempt3 = factory.expectMsgType[ReplaceableTxPublisherSpawned].actor
|
||||
attempt3.expectMsgType[ReplaceableTxPublisher.Publish]
|
||||
|
@ -199,7 +199,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike {
|
|||
val attempt1 = factory.expectMsgType[FinalTxPublisherSpawned]
|
||||
attempt1.actor.expectMsgType[FinalTxPublisher.Publish]
|
||||
|
||||
val cmd2 = PublishReplaceableTx(ClaimLocalAnchorOutputTx(InputInfo(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, TxOut(20_000 sat, Nil) :: Nil, 0), ConfirmationTarget.Absolute(nodeParams.currentBlockHeight)), null, null)
|
||||
val cmd2 = PublishReplaceableTx(ClaimLocalAnchorOutputTx(InputInfo.SegwitInput(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, TxOut(20_000 sat, Nil) :: Nil, 0), ConfirmationTarget.Absolute(nodeParams.currentBlockHeight)), null, null)
|
||||
txPublisher ! cmd2
|
||||
val attempt2 = factory.expectMsgType[ReplaceableTxPublisherSpawned]
|
||||
attempt2.actor.expectMsgType[ReplaceableTxPublisher.Publish]
|
||||
|
@ -239,7 +239,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike {
|
|||
val target = nodeParams.currentBlockHeight + 12
|
||||
val input = OutPoint(randomTxId(), 7)
|
||||
val paymentHash = randomBytes32()
|
||||
val cmd = PublishReplaceableTx(HtlcSuccessTx(InputInfo(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), paymentHash, 3, ConfirmationTarget.Absolute(target)), null, null)
|
||||
val cmd = PublishReplaceableTx(HtlcSuccessTx(InputInfo.SegwitInput(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), paymentHash, 3, ConfirmationTarget.Absolute(target)), null, null)
|
||||
txPublisher ! cmd
|
||||
val attempt1 = factory.expectMsgType[ReplaceableTxPublisherSpawned]
|
||||
attempt1.actor.expectMsgType[ReplaceableTxPublisher.Publish]
|
||||
|
@ -303,7 +303,7 @@ class TxPublisherSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike {
|
|||
|
||||
val input = OutPoint(randomTxId(), 7)
|
||||
val paymentHash = randomBytes32()
|
||||
val cmd = PublishReplaceableTx(HtlcSuccessTx(InputInfo(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), paymentHash, 3, ConfirmationTarget.Absolute(nodeParams.currentBlockHeight)), null, null)
|
||||
val cmd = PublishReplaceableTx(HtlcSuccessTx(InputInfo.SegwitInput(input, TxOut(25_000 sat, Nil), Nil), Transaction(2, TxIn(input, Nil, 0) :: Nil, Nil, 0), paymentHash, 3, ConfirmationTarget.Absolute(nodeParams.currentBlockHeight)), null, null)
|
||||
txPublisher ! cmd
|
||||
val attempt1 = factory.expectMsgType[ReplaceableTxPublisherSpawned]
|
||||
attempt1.actor.expectMsgType[ReplaceableTxPublisher.Publish]
|
||||
|
|
|
@ -139,7 +139,7 @@ class OpenChannelInterceptorSpec extends ScalaTestWithActorTestKit(ConfigFactory
|
|||
val currentChannels = Seq(
|
||||
Peer.ChannelInfo(TestProbe().ref, SHUTDOWN, DATA_SHUTDOWN(commitments(isOpener = true), Shutdown(randomBytes32(), ByteVector.empty), Shutdown(randomBytes32(), ByteVector.empty), None)),
|
||||
Peer.ChannelInfo(TestProbe().ref, NEGOTIATING, DATA_NEGOTIATING(commitments(), Shutdown(randomBytes32(), ByteVector.empty), Shutdown(randomBytes32(), ByteVector.empty), List(Nil), None)),
|
||||
Peer.ChannelInfo(TestProbe().ref, CLOSING, DATA_CLOSING(commitments(), BlockHeight(0), ByteVector.empty, Nil, ClosingTx(InputInfo(OutPoint(TxId(randomBytes32()), 5), TxOut(100_000 sat, Nil), Nil), Transaction(2, Nil, Nil, 0), None) :: Nil)),
|
||||
Peer.ChannelInfo(TestProbe().ref, CLOSING, DATA_CLOSING(commitments(), BlockHeight(0), ByteVector.empty, Nil, ClosingTx(InputInfo.SegwitInput(OutPoint(TxId(randomBytes32()), 5), TxOut(100_000 sat, Nil), Nil), Transaction(2, Nil, Nil, 0), None) :: Nil)),
|
||||
Peer.ChannelInfo(TestProbe().ref, WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT, DATA_WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT(commitments(), ChannelReestablish(randomBytes32(), 0, 0, randomKey(), randomKey().publicKey))),
|
||||
)
|
||||
peer.expectMessageType[Peer.GetPeerChannels].replyTo ! Peer.PeerChannels(remoteNodeId, currentChannels)
|
||||
|
|
|
@ -72,7 +72,7 @@ class PendingChannelsRateLimiterSpec extends ScalaTestWithActorTestKit(ConfigFac
|
|||
val probe = TestProbe[PendingChannelsRateLimiter.Response]()
|
||||
val nodeParams = TestConstants.Alice.nodeParams.copy(channelConf = TestConstants.Alice.nodeParams.channelConf.copy(maxPendingChannelsPerPeer = maxPendingChannelsPerPeer, maxTotalPendingChannelsPrivateNodes = maxTotalPendingChannelsPrivateNodes, channelOpenerWhitelist = Set(peerOnWhitelistAtLimit)))
|
||||
val tx = Transaction.read("010000000110f01d4a4228ef959681feb1465c2010d0135be88fd598135b2e09d5413bf6f1000000006a473044022074658623424cebdac8290488b76f893cfb17765b7a3805e773e6770b7b17200102202892cfa9dda662d5eac394ba36fcfd1ea6c0b8bb3230ab96220731967bbdb90101210372d437866d9e4ead3d362b01b615d24cc0d5152c740d51e3c55fb53f6d335d82ffffffff01408b0700000000001976a914678db9a7caa2aca887af1177eda6f3d0f702df0d88ac00000000")
|
||||
val closingTx = ClosingTx(InputInfo(tx.txIn.head.outPoint, TxOut(10_000 sat, Nil), Nil), tx, None)
|
||||
val closingTx = ClosingTx(InputInfo.SegwitInput(tx.txIn.head.outPoint, TxOut(10_000 sat, Nil), Nil), tx, None)
|
||||
val channelsOnWhitelistAtLimit: Seq[PersistentChannelData] = Seq(
|
||||
DATA_WAIT_FOR_FUNDING_CONFIRMED(commitments(peerOnWhitelistAtLimit, randomBytes32()), BlockHeight(0), None, Left(FundingCreated(randomBytes32(), TxId(ByteVector32.Zeroes), 3, randomBytes64()))),
|
||||
DATA_WAIT_FOR_CHANNEL_READY(commitments(peerOnWhitelistAtLimit, randomBytes32()), ShortIdAliases(ShortChannelId.generateLocalAlias(), None)),
|
||||
|
|
|
@ -283,7 +283,7 @@ class JsonSerializersSpec extends TestKitBaseClass with AnyFunSuiteLike with Mat
|
|||
}
|
||||
|
||||
test("InputInfo serialization") {
|
||||
val inputInfo = InputInfo(
|
||||
val inputInfo = InputInfo.SegwitInput(
|
||||
outPoint = OutPoint(TxHash.fromValidHex("345b2b05ec046ffe0c14d3b61838c79980713ad1cf8ae7a45c172ce90c9c0b9f"), 42),
|
||||
txOut = TxOut(456651 sat, hex"3c7a66997c681a3de1bae56438abeee4fc50a16554725a430ade1dc8db6bdd76704d45c6151c4051d710cf487e63"),
|
||||
redeemScript = hex"00dc6c50f445ed53d2fb41067fdcb25686fe79492d90e6e5db43235726ace247210220773"
|
||||
|
@ -369,7 +369,7 @@ class JsonSerializersSpec extends TestKitBaseClass with AnyFunSuiteLike with Mat
|
|||
|
||||
test("TransactionWithInputInfo serializer") {
|
||||
// the input info is ignored when serializing to JSON
|
||||
val dummyInputInfo = InputInfo(OutPoint(TxId(ByteVector32.Zeroes), 0), TxOut(Satoshi(0), Nil), Nil)
|
||||
val dummyInputInfo = InputInfo.SegwitInput(OutPoint(TxId(ByteVector32.Zeroes), 0), TxOut(Satoshi(0), Nil), Nil)
|
||||
|
||||
val htlcSuccessTx = Transaction.read("0200000001c8a8934fb38a44b969528252bc37be66ee166c7897c57384d1e561449e110c93010000006b483045022100dc6c50f445ed53d2fb41067fdcb25686fe79492d90e6e5db43235726ace247210220773d35228af0800c257970bee9cf75175d75217de09a8ecd83521befd040c4ca012102082b751372fe7e3b012534afe0bb8d1f2f09c724b1a10a813ce704e5b9c217ccfdffffff0247ba2300000000001976a914f97a7641228e6b17d4b0b08252ae75bd62a95fe788ace3de24000000000017a914a9fefd4b9a9282a1d7a17d2f14ac7d1eb88141d287f7d50800")
|
||||
val htlcSuccessTxInfo = HtlcSuccessTx(dummyInputInfo, htlcSuccessTx, ByteVector32.One, 3, ConfirmationTarget.Absolute(BlockHeight(1105)))
|
||||
|
|
|
@ -699,7 +699,7 @@ object PaymentPacketSpec {
|
|||
val localParams = LocalParams(null, null, null, Long.MaxValue.msat, Some(channelReserve), null, null, 0, isChannelOpener = true, paysCommitTxFees = true, None, None, null)
|
||||
val remoteParams = RemoteParams(randomKey().publicKey, null, UInt64.MaxValue, Some(channelReserve), null, null, maxAcceptedHtlcs = 0, null, null, null, null, null, None)
|
||||
val fundingTx = Transaction(2, Nil, Seq(TxOut(testCapacity, Nil)), 0)
|
||||
val commitInput = InputInfo(OutPoint(fundingTx, 0), fundingTx.txOut.head, Nil)
|
||||
val commitInput = InputInfo.SegwitInput(OutPoint(fundingTx, 0), fundingTx.txOut.head, Nil)
|
||||
val localCommit = LocalCommit(0, null, CommitTxAndRemoteSig(Transactions.CommitTx(commitInput, null), RemoteSignature.FullSignature(null)), Nil)
|
||||
val remoteCommit = RemoteCommit(0, null, null, randomKey().publicKey)
|
||||
val localChanges = LocalChanges(Nil, Nil, Nil)
|
||||
|
|
|
@ -513,7 +513,7 @@ class PostRestartHtlcCleanerSpec extends TestKitBaseClass with FixtureAnyFunSuit
|
|||
// commit we accept it as such, so it simplifies the test.
|
||||
val revokedCommitTx = normal.commitments.latest.localCommit.commitTxAndRemoteSig.commitTx.tx.copy(txOut = Seq(TxOut(4500 sat, Script.pay2wpkh(randomKey().publicKey))))
|
||||
val dummyClaimMainTx = Transaction(2, Seq(TxIn(OutPoint(revokedCommitTx, 0), Nil, 0)), Seq(revokedCommitTx.txOut.head.copy(amount = 4000 sat)), 0)
|
||||
val dummyClaimMain = ClaimRemoteDelayedOutputTx(InputInfo(OutPoint(revokedCommitTx, 0), revokedCommitTx.txOut.head, Nil), dummyClaimMainTx)
|
||||
val dummyClaimMain = ClaimRemoteDelayedOutputTx(InputInfo.SegwitInput(OutPoint(revokedCommitTx, 0), revokedCommitTx.txOut.head, Nil), dummyClaimMainTx)
|
||||
val rcp = RevokedCommitPublished(revokedCommitTx, Some(dummyClaimMain), None, Nil, Nil, Map(revokedCommitTx.txIn.head.outPoint -> revokedCommitTx))
|
||||
DATA_CLOSING(normal.commitments, BlockHeight(0), Script.write(Script.pay2wpkh(randomKey().publicKey)), mutualCloseProposed = Nil, revokedCommitPublished = List(rcp))
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ class ChannelCodecs4Spec extends AnyFunSuite {
|
|||
|
||||
test("encode/decode rbf status") {
|
||||
val channelId = randomBytes32()
|
||||
val fundingInput = InputInfo(OutPoint(randomTxId(), 3), TxOut(175_000 sat, Script.pay2wpkh(randomKey().publicKey)), Nil)
|
||||
val fundingInput = InputInfo.SegwitInput(OutPoint(randomTxId(), 3), TxOut(175_000 sat, Script.pay2wpkh(randomKey().publicKey)), Nil)
|
||||
val fundingTx = SharedTransaction(
|
||||
sharedInput_opt = None,
|
||||
sharedOutput = InteractiveTxBuilder.Output.Shared(UInt64(8), ByteVector.empty, 100_000_600 msat, 74_000_400 msat, 0 msat),
|
||||
|
@ -180,7 +180,7 @@ class ChannelCodecs4Spec extends AnyFunSuite {
|
|||
createdAt = BlockHeight(1000),
|
||||
fundingParams = InteractiveTxParams(channelId = channelId, isInitiator = true, localContribution = 100.sat, remoteContribution = 200.sat,
|
||||
sharedInput_opt = Some(InteractiveTxBuilder.Multisig2of2Input(
|
||||
InputInfo(OutPoint(TxId(ByteVector32.Zeroes), 0), TxOut(1000.sat, Script.pay2wsh(script)), script),
|
||||
InputInfo.SegwitInput(OutPoint(TxId(ByteVector32.Zeroes), 0), TxOut(1000.sat, Script.pay2wsh(script)), script),
|
||||
0,
|
||||
PrivateKey(ByteVector.fromValidHex("02" * 32)).publicKey
|
||||
)),
|
||||
|
|
Loading…
Add table
Reference in a new issue