@ -72,9 +72,6 @@ type HtlcScript interface {
// redeeming the htlc.
IsSuccessWitness ( witness wire . TxWitness ) bool
// Script returns the htlc script.
Script ( ) [ ] byte
// lockingConditions return the address, pkScript and sigScript (if
// required) for a htlc script.
lockingConditions ( HtlcOutputType , * chaincfg . Params ) ( btcutil . Address ,
@ -88,9 +85,21 @@ type HtlcScript interface {
// timeout case witness.
MaxTimeoutWitnessSize ( ) int
// TimeoutScript returns the redeem script required to unlock the htlc
// after timeout.
TimeoutScript ( ) [ ] byte
// SuccessScript returns the redeem script required to unlock the htlc
// using the preimage.
SuccessScript ( ) [ ] byte
// SuccessSequence returns the sequence to spend this htlc in the
// success case.
SuccessSequence ( ) uint32
// SigHash is the signature hash to use for transactions spending from
// the htlc.
SigHash ( ) txscript . SigHashType
}
// Htlc contains relevant htlc information from the receiver perspective.
@ -445,8 +454,19 @@ func (h *HtlcScriptV1) IsSuccessWitness(witness wire.TxWitness) bool {
return ! isTimeoutTx
}
// Script returns the htlc script.
func ( h * HtlcScriptV1 ) Script ( ) [ ] byte {
// TimeoutScript returns the redeem script required to unlock the htlc after
// timeout.
//
// In the case of HtlcScriptV1, this is the full segwit v0 script.
func ( h * HtlcScriptV1 ) TimeoutScript ( ) [ ] byte {
return h . script
}
// SuccessScript returns the redeem script required to unlock the htlc using
// the preimage.
//
// In the case of HtlcScriptV1, this is the full segwit v0 script.
func ( h * HtlcScriptV1 ) SuccessScript ( ) [ ] byte {
return h . script
}
@ -483,6 +503,11 @@ func (h *HtlcScriptV1) SuccessSequence() uint32 {
return 0
}
// Sighash is the signature hash to use for transactions spending from the htlc.
func ( h * HtlcScriptV1 ) SigHash ( ) txscript . SigHashType {
return txscript . SigHashAll
}
// lockingConditions return the address, pkScript and sigScript (if
// required) for a htlc script.
func ( h * HtlcScriptV1 ) lockingConditions ( htlcOutputType HtlcOutputType ,
@ -586,8 +611,19 @@ func (h *HtlcScriptV2) GenTimeoutWitness(
return witnessStack , nil
}
// Script returns the htlc script.
func ( h * HtlcScriptV2 ) Script ( ) [ ] byte {
// TimeoutScript returns the redeem script required to unlock the htlc after
// timeout.
//
// In the case of HtlcScriptV2, this is the full segwit v0 script.
func ( h * HtlcScriptV2 ) TimeoutScript ( ) [ ] byte {
return h . script
}
// SuccessScript returns the redeem script required to unlock the htlc using
// the preimage.
//
// In the case of HtlcScriptV2, this is the full segwit v0 script.
func ( h * HtlcScriptV2 ) SuccessScript ( ) [ ] byte {
return h . script
}
@ -625,6 +661,11 @@ func (h *HtlcScriptV2) SuccessSequence() uint32 {
return 1
}
// Sighash is the signature hash to use for transactions spending from the htlc.
func ( h * HtlcScriptV2 ) SigHash ( ) txscript . SigHashType {
return txscript . SigHashAll
}
// lockingConditions return the address, pkScript and sigScript (if
// required) for a htlc script.
func ( h * HtlcScriptV2 ) lockingConditions ( htlcOutputType HtlcOutputType ,
@ -794,9 +835,20 @@ func (h *HtlcScriptV3) IsSuccessWitness(witness wire.TxWitness) bool {
return len ( witness ) == 4
}
// Script is not implemented, but necessary to conform to interface.
func ( h * HtlcScriptV3 ) Script ( ) [ ] byte {
return nil
// TimeoutScript returns the redeem script required to unlock the htlc after
// timeout.
//
// In the case of HtlcScriptV3, this is the timeout tapleaf.
func ( h * HtlcScriptV3 ) TimeoutScript ( ) [ ] byte {
return h . timeoutScript
}
// SuccessScript returns the redeem script required to unlock the htlc using
// the preimage.
//
// In the case of HtlcScriptV3, this is the claim tapleaf.
func ( h * HtlcScriptV3 ) SuccessScript ( ) [ ] byte {
return h . claimScript
}
// MaxSuccessWitnessSize returns the maximum witness size for the
@ -837,6 +889,11 @@ func (h *HtlcScriptV3) SuccessSequence() uint32 {
return 1
}
// Sighash is the signature hash to use for transactions spending from the htlc.
func ( h * HtlcScriptV3 ) SigHash ( ) txscript . SigHashType {
return txscript . SigHashDefault
}
// lockingConditions return the address, pkScript and sigScript (if required)
// for a htlc script.
func ( h * HtlcScriptV3 ) lockingConditions ( outputType HtlcOutputType ,