sweep+input: add RequiredTxOut to inputs

This is needed to sweep second level HTLC transactions that are signed
using SINGLE|ANYONECANPAY, since the input and ouput must be aligned.
This commit is contained in:
Johan T. Halseth 2020-11-06 19:59:11 +01:00
parent aa8fa9d0cf
commit 985b7838ab
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
2 changed files with 18 additions and 0 deletions

@ -866,6 +866,13 @@ func (bo *breachedOutput) OutPoint() *wire.OutPoint {
return &bo.outpoint return &bo.outpoint
} }
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
// transaction output. This is used in the SINGLE|ANYONECANPAY case to make
// sure any presigned input is still valid by including the output.
func (bo *breachedOutput) RequiredTxOut() *wire.TxOut {
return nil
}
// RequiredLockTime returns whether this input commits to a tx locktime that // RequiredLockTime returns whether this input commits to a tx locktime that
// must be used in the transaction including it. // must be used in the transaction including it.
func (bo *breachedOutput) RequiredLockTime() (uint32, bool) { func (bo *breachedOutput) RequiredLockTime() (uint32, bool) {

@ -15,6 +15,12 @@ type Input interface {
// construct the corresponding transaction input. // construct the corresponding transaction input.
OutPoint() *wire.OutPoint OutPoint() *wire.OutPoint
// RequiredTxOut returns a non-nil TxOut if input commits to a certain
// transaction output. This is used in the SINGLE|ANYONECANPAY case to
// make sure any presigned input is still valid by including the
// output.
RequiredTxOut() *wire.TxOut
// RequiredLockTime returns whether this input commits to a tx locktime // RequiredLockTime returns whether this input commits to a tx locktime
// that must be used in the transaction including it. // that must be used in the transaction including it.
RequiredLockTime() (uint32, bool) RequiredLockTime() (uint32, bool)
@ -79,6 +85,11 @@ func (i *inputKit) OutPoint() *wire.OutPoint {
return &i.outpoint return &i.outpoint
} }
// RequiredTxOut returns a nil for the base input type.
func (i *inputKit) RequiredTxOut() *wire.TxOut {
return nil
}
// RequiredLockTime returns whether this input commits to a tx locktime that // RequiredLockTime returns whether this input commits to a tx locktime that
// 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.