mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-02 09:42:31 +02:00
contraccourt+input: create resolver for timeout second level
In this commit we make the sweeper handle second level transactions for HTLC timeout resolvers for anchor channels.
This commit is contained in:
@@ -305,6 +305,43 @@ func (i *HtlcSecondLevelAnchorInput) CraftInputScript(signer Signer,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// MakeHtlcSecondLevelTimeoutAnchorInput creates an input allowing the sweeper
|
||||
// to spend the HTLC output on our commit using the second level timeout
|
||||
// transaction.
|
||||
func MakeHtlcSecondLevelTimeoutAnchorInput(signedTx *wire.MsgTx,
|
||||
signDetails *SignDetails, heightHint uint32) HtlcSecondLevelAnchorInput {
|
||||
|
||||
// Spend an HTLC output on our local commitment tx using the
|
||||
// 2nd timeout transaction.
|
||||
createWitness := func(signer Signer, txn *wire.MsgTx,
|
||||
hashCache *txscript.TxSigHashes,
|
||||
txinIdx int) (wire.TxWitness, error) {
|
||||
|
||||
desc := signDetails.SignDesc
|
||||
desc.SigHashes = txscript.NewTxSigHashes(txn)
|
||||
desc.InputIndex = txinIdx
|
||||
|
||||
return SenderHtlcSpendTimeout(
|
||||
signDetails.PeerSig, signDetails.SigHashType, signer,
|
||||
&desc, txn,
|
||||
)
|
||||
}
|
||||
|
||||
return HtlcSecondLevelAnchorInput{
|
||||
inputKit: inputKit{
|
||||
outpoint: signedTx.TxIn[0].PreviousOutPoint,
|
||||
witnessType: HtlcOfferedTimeoutSecondLevelInputConfirmed,
|
||||
signDesc: signDetails.SignDesc,
|
||||
heightHint: heightHint,
|
||||
|
||||
// CSV delay is always 1 for these inputs.
|
||||
blockToMaturity: 1,
|
||||
},
|
||||
SignedTx: signedTx,
|
||||
createWitness: createWitness,
|
||||
}
|
||||
}
|
||||
|
||||
// MakeHtlcSecondLevelSuccessAnchorInput creates an input allowing the sweeper
|
||||
// to spend the HTLC output on our commit using the second level success
|
||||
// transaction.
|
||||
|
Reference in New Issue
Block a user