From 2e9a0f8dbe2368886e9a80236589f228ceaebb9c Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 28 Apr 2023 10:18:40 +0200 Subject: [PATCH] multi: use prev output fetcher in sign desc --- cmd/chantools/sweepremoteclosed.go | 9 +++++---- cmd/chantools/sweeptimelock.go | 7 ++++--- cmd/chantools/sweeptimelockmanual.go | 7 ++++--- lnd/signer.go | 11 ++++++----- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cmd/chantools/sweepremoteclosed.go b/cmd/chantools/sweepremoteclosed.go index 5605236..cf11960 100644 --- a/cmd/chantools/sweepremoteclosed.go +++ b/cmd/chantools/sweepremoteclosed.go @@ -223,10 +223,11 @@ func sweepRemoteClosed(extendedKey *hdkeychain.ExtendedKey, apiURL, }) signDescs = append(signDescs, &input.SignDescriptor{ - KeyDesc: *target.keyDesc, - WitnessScript: target.script, - Output: prevTxOut, - HashType: txscript.SigHashAll, + KeyDesc: *target.keyDesc, + WitnessScript: target.script, + Output: prevTxOut, + HashType: txscript.SigHashAll, + PrevOutputFetcher: prevOutFetcher, }) } } diff --git a/cmd/chantools/sweeptimelock.go b/cmd/chantools/sweeptimelock.go index 3821511..c8f0ce2 100644 --- a/cmd/chantools/sweeptimelock.go +++ b/cmd/chantools/sweeptimelock.go @@ -271,9 +271,10 @@ func sweepTimeLock(extendedKey *hdkeychain.ExtendedKey, apiURL string, target.commitPoint, target.delayBasePointDesc.PubKey, ), - WitnessScript: script, - Output: prevTxOut, - HashType: txscript.SigHashAll, + WitnessScript: script, + Output: prevTxOut, + HashType: txscript.SigHashAll, + PrevOutputFetcher: prevOutFetcher, } totalOutputValue += target.value signDescs = append(signDescs, signDesc) diff --git a/cmd/chantools/sweeptimelockmanual.go b/cmd/chantools/sweeptimelockmanual.go index 6b21630..1a30401 100644 --- a/cmd/chantools/sweeptimelockmanual.go +++ b/cmd/chantools/sweeptimelockmanual.go @@ -271,9 +271,10 @@ func sweepTimeLockManual(extendedKey *hdkeychain.ExtendedKey, apiURL string, PkScript: scriptHash, Value: sweepValue, }, - InputIndex: 0, - SigHashes: sigHashes, - HashType: txscript.SigHashAll, + InputIndex: 0, + SigHashes: sigHashes, + PrevOutputFetcher: prevOutFetcher, + HashType: txscript.SigHashAll, } witness, err := input.CommitSpendTimeout(signer, signDesc, sweepTx) if err != nil { diff --git a/lnd/signer.go b/lnd/signer.go index 420fba7..86ac0e6 100644 --- a/lnd/signer.go +++ b/lnd/signer.go @@ -135,11 +135,12 @@ func (s *Signer) AddPartialSignature(packet *psbt.Packet, // Now we add our partial signature. prevOutFetcher := wallet.PsbtPrevOutputFetcher(packet) signDesc := &input.SignDescriptor{ - KeyDesc: keyDesc, - WitnessScript: witnessScript, - Output: utxo, - InputIndex: inputIndex, - HashType: txscript.SigHashAll, + KeyDesc: keyDesc, + WitnessScript: witnessScript, + Output: utxo, + InputIndex: inputIndex, + HashType: txscript.SigHashAll, + PrevOutputFetcher: prevOutFetcher, SigHashes: txscript.NewTxSigHashes( packet.UnsignedTx, prevOutFetcher, ),