mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-31 17:51:33 +02:00
multi: use prev output fetcher where possible
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package input
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
)
|
||||
@@ -18,3 +20,25 @@ func NewTxSigHashesV0Only(tx *wire.MsgTx) *txscript.TxSigHashes {
|
||||
nilFetcher := txscript.NewCannedPrevOutputFetcher(nil, 0)
|
||||
return txscript.NewTxSigHashes(tx, nilFetcher)
|
||||
}
|
||||
|
||||
// MultiPrevOutFetcher returns a txscript.MultiPrevOutFetcher for the given set
|
||||
// of inputs.
|
||||
func MultiPrevOutFetcher(inputs []Input) (*txscript.MultiPrevOutFetcher, error) {
|
||||
fetcher := txscript.NewMultiPrevOutFetcher(nil)
|
||||
for _, inp := range inputs {
|
||||
op := inp.OutPoint()
|
||||
desc := inp.SignDesc()
|
||||
|
||||
if op == nil {
|
||||
return nil, fmt.Errorf("missing input outpoint")
|
||||
}
|
||||
|
||||
if desc == nil || desc.Output == nil {
|
||||
return nil, fmt.Errorf("missing input utxo information")
|
||||
}
|
||||
|
||||
fetcher.AddPrevOut(*op, desc.Output)
|
||||
}
|
||||
|
||||
return fetcher, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user