multi: use prev output fetcher where possible
This commit is contained in:
13 files changed
+255
-44
No files matched your search
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/btcsuite/btcd/btcec/v2"
|
||||
"github.com/btcsuite/btcd/btcutil"
|
||||
"github.com/btcsuite/btcd/btcutil/txsort"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
@@ -262,10 +263,14 @@ func (t *backupTask) craftSessionPayload(
|
||||
// information. This will either be contain both the to-local and
|
||||
// to-remote outputs, or only be the to-local output.
|
||||
inputs := t.inputs()
|
||||
for prevOutPoint, input := range inputs {
|
||||
prevOutputFetcher := txscript.NewMultiPrevOutFetcher(nil)
|
||||
for prevOutPoint, inp := range inputs {
|
||||
prevOutputFetcher.AddPrevOut(
|
||||
prevOutPoint, inp.SignDesc().Output,
|
||||
)
|
||||
justiceTxn.AddTxIn(&wire.TxIn{
|
||||
PreviousOutPoint: prevOutPoint,
|
||||
Sequence: input.BlocksToMaturity(),
|
||||
Sequence: inp.BlocksToMaturity(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -284,7 +289,7 @@ func (t *backupTask) craftSessionPayload(
|
||||
}
|
||||
|
||||
// Construct a sighash cache to improve signing performance.
|
||||
hashCache := input.NewTxSigHashesV0Only(justiceTxn)
|
||||
hashCache := txscript.NewTxSigHashes(justiceTxn, prevOutputFetcher)
|
||||
|
||||
// Since the transaction inputs could have been reordered as a result of
|
||||
// the BIP69 sort, create an index mapping each prevout to it's new
|
||||
@@ -303,7 +308,7 @@ func (t *backupTask) craftSessionPayload(
|
||||
|
||||
// Construct the full witness required to spend this input.
|
||||
inputScript, err := inp.CraftInputScript(
|
||||
signer, justiceTxn, hashCache, i,
|
||||
signer, justiceTxn, hashCache, prevOutputFetcher, i,
|
||||
)
|
||||
if err != nil {
|
||||
return hint, nil, err
|
||||
|
||||
Reference in new issue
Block a user