|
|
|
@ -41,7 +41,7 @@ const (
|
|
|
|
|
HtlcV3
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// htlcScript defines an interface for the different HTLC implementations.
|
|
|
|
|
// HtlcScript defines an interface for the different HTLC implementations.
|
|
|
|
|
type HtlcScript interface {
|
|
|
|
|
// genSuccessWitness returns the success script to spend this htlc with
|
|
|
|
|
// the preimage.
|
|
|
|
@ -186,8 +186,8 @@ func NewHtlcV2(cltvExpiry int32, senderKey, receiverKey [33]byte,
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewHtlcV3 returns a new V3 HTLC (P2TR) instance. Internal pubkey generated
|
|
|
|
|
// by both participants must be provided.
|
|
|
|
|
// NewHtlcV3 returns a new V3 HTLC (P2TR) instance. Internal pubkey generated by
|
|
|
|
|
// both participants must be provided.
|
|
|
|
|
func NewHtlcV3(muSig2Version input.MuSig2Version, cltvExpiry int32,
|
|
|
|
|
senderInternalKey, receiverInternalKey, senderKey, receiverKey [33]byte,
|
|
|
|
|
hash lntypes.Hash, chainParams *chaincfg.Params) (*Htlc, error) {
|
|
|
|
@ -524,10 +524,11 @@ func parsePubKey(muSig2Version input.MuSig2Version, key [33]byte) (
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// newHTLCScriptV3 constructs a HtlcScipt with the HTLC V3 taproot script.
|
|
|
|
|
// newHTLCScriptV3 constructs a HtlcScript with the HTLC V3 taproot script.
|
|
|
|
|
func newHTLCScriptV3(muSig2Version input.MuSig2Version, cltvExpiry int32,
|
|
|
|
|
senderInternalKey, receiverInternalKey, senderHtlcKey,
|
|
|
|
|
receiverHtlcKey [33]byte, swapHash lntypes.Hash) (*HtlcScriptV3, error) {
|
|
|
|
|
receiverHtlcKey [33]byte, swapHash lntypes.Hash) (*HtlcScriptV3,
|
|
|
|
|
error) {
|
|
|
|
|
|
|
|
|
|
senderPubKey, err := parsePubKey(muSig2Version, senderHtlcKey)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -539,8 +540,8 @@ func newHTLCScriptV3(muSig2Version input.MuSig2Version, cltvExpiry int32,
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create our success path script, we'll use this separately
|
|
|
|
|
// to generate the success path leaf.
|
|
|
|
|
// Create our success path script, we'll use this separately to generate
|
|
|
|
|
// the success path leaf.
|
|
|
|
|
successPathScript, err := GenSuccessPathScript(
|
|
|
|
|
receiverPubKey, swapHash,
|
|
|
|
|
)
|
|
|
|
@ -674,8 +675,8 @@ func (h *HtlcScriptV3) genControlBlock(leafScript []byte) ([]byte, error) {
|
|
|
|
|
return controlBlock.ToBytes()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// genSuccessWitness returns the success script to spend this htlc with
|
|
|
|
|
// the preimage.
|
|
|
|
|
// genSuccessWitness returns the success script to spend this htlc with the
|
|
|
|
|
// preimage.
|
|
|
|
|
func (h *HtlcScriptV3) genSuccessWitness(
|
|
|
|
|
receiverSig []byte, preimage lntypes.Preimage) (wire.TxWitness, error) {
|
|
|
|
|
|
|
|
|
@ -777,7 +778,7 @@ func (h *HtlcScriptV3) SuccessSequence() uint32 {
|
|
|
|
|
return 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sighash is the signature hash to use for transactions spending from the htlc.
|
|
|
|
|
// SigHash is the signature hash to use for transactions spending from the htlc.
|
|
|
|
|
func (h *HtlcScriptV3) SigHash() txscript.SigHashType {
|
|
|
|
|
return txscript.SigHashDefault
|
|
|
|
|
}
|
|
|
|
|