From 985b7838ab695af33cb0df3da460cd0876e4638f Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Fri, 6 Nov 2020 19:59:11 +0100 Subject: [PATCH] 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. --- breacharbiter.go | 7 +++++++ input/input.go | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/breacharbiter.go b/breacharbiter.go index 334e72f7..420ca665 100644 --- a/breacharbiter.go +++ b/breacharbiter.go @@ -866,6 +866,13 @@ func (bo *breachedOutput) OutPoint() *wire.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 // must be used in the transaction including it. func (bo *breachedOutput) RequiredLockTime() (uint32, bool) { diff --git a/input/input.go b/input/input.go index 70b6ba93..7c0d79f6 100644 --- a/input/input.go +++ b/input/input.go @@ -15,6 +15,12 @@ type Input interface { // construct the corresponding transaction input. 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 // that must be used in the transaction including it. RequiredLockTime() (uint32, bool) @@ -79,6 +85,11 @@ func (i *inputKit) OutPoint() *wire.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 // 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.