mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-06 19:54:08 +02:00
input: add new constructor to support CSV and CLTV locked inputs
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
8cfb53f64a
commit
2f27fa370b
@@ -90,6 +90,7 @@ type inputKit struct {
|
|||||||
signDesc SignDescriptor
|
signDesc SignDescriptor
|
||||||
heightHint uint32
|
heightHint uint32
|
||||||
blockToMaturity uint32
|
blockToMaturity uint32
|
||||||
|
cltvExpiry uint32
|
||||||
|
|
||||||
// unconfParent contains information about a potential unconfirmed
|
// unconfParent contains information about a potential unconfirmed
|
||||||
// parent transaction.
|
// parent transaction.
|
||||||
@@ -111,7 +112,7 @@ func (i *inputKit) RequiredTxOut() *wire.TxOut {
|
|||||||
// must be used in the transaction including it. This will be false for the
|
// must be used in the transaction including it. This will be false for the
|
||||||
// base input type since we can re-sign for any lock time.
|
// base input type since we can re-sign for any lock time.
|
||||||
func (i *inputKit) RequiredLockTime() (uint32, bool) {
|
func (i *inputKit) RequiredLockTime() (uint32, bool) {
|
||||||
return 0, false
|
return i.cltvExpiry, i.cltvExpiry > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// WitnessType returns the type of witness that must be generated to spend the
|
// WitnessType returns the type of witness that must be generated to spend the
|
||||||
@@ -196,6 +197,25 @@ func NewCsvInput(outpoint *wire.OutPoint, witnessType WitnessType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewCsvInputWithCltv assembles a new csv and cltv locked input that can be
|
||||||
|
// used to construct a sweep transaction.
|
||||||
|
func NewCsvInputWithCltv(outpoint *wire.OutPoint, witnessType WitnessType,
|
||||||
|
signDescriptor *SignDescriptor, heightHint uint32,
|
||||||
|
csvDelay uint32, cltvExpiry uint32) *BaseInput {
|
||||||
|
|
||||||
|
return &BaseInput{
|
||||||
|
inputKit{
|
||||||
|
outpoint: *outpoint,
|
||||||
|
witnessType: witnessType,
|
||||||
|
signDesc: *signDescriptor,
|
||||||
|
heightHint: heightHint,
|
||||||
|
blockToMaturity: csvDelay,
|
||||||
|
cltvExpiry: cltvExpiry,
|
||||||
|
unconfParent: nil,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CraftInputScript returns a valid set of input scripts allowing this output
|
// CraftInputScript returns a valid set of input scripts allowing this output
|
||||||
// to be spent. The returned input scripts should target the input at location
|
// to be spent. The returned input scripts should target the input at location
|
||||||
// txIndex within the passed transaction. The input scripts generated by this
|
// txIndex within the passed transaction. The input scripts generated by this
|
||||||
|
Reference in New Issue
Block a user