chanfunding: fix sighash type for p2tr inputs
This commit fixes the default sighash type for p2tr channel funding transaction inputs.
This commit is contained in:
1 file changed
+10
-2
@@ -111,7 +111,6 @@ func (f *FullIntent) CompileFundingTx(extraInputs []*wire.TxIn,
|
||||
f.coinSource, extraInputs,
|
||||
)
|
||||
signDesc := input.SignDescriptor{
|
||||
HashType: txscript.SigHashAll,
|
||||
SigHashes: txscript.NewTxSigHashes(
|
||||
fundingTx, prevOutFetcher,
|
||||
),
|
||||
@@ -136,6 +135,13 @@ func (f *FullIntent) CompileFundingTx(extraInputs []*wire.TxIn,
|
||||
}
|
||||
signDesc.InputIndex = i
|
||||
|
||||
// We support spending a p2tr input ourselves. But not as part
|
||||
// of their inputs.
|
||||
signDesc.HashType = txscript.SigHashAll
|
||||
if txscript.IsPayToTaproot(info.PkScript) {
|
||||
signDesc.HashType = txscript.SigHashDefault
|
||||
}
|
||||
|
||||
// Finally, we'll sign the input as is, and populate the input
|
||||
// with the witness and sigScript (if needed).
|
||||
inputScript, err := f.signer.ComputeInputScript(
|
||||
@@ -398,7 +404,9 @@ var _ txscript.PrevOutputFetcher = (*SegWitV0DualFundingPrevOutputFetcher)(nil)
|
||||
//
|
||||
// NOTE: Since the actual pkScript and amounts aren't passed in, this will just
|
||||
// make sure that nothing will panic when creating a SegWit v0 sighash. But this
|
||||
// code will NOT WORK for transactions that spend any Taproot inputs!
|
||||
// code will NOT WORK for transactions that spend any _remote_ Taproot inputs!
|
||||
// So basically dual-funding won't work with Taproot inputs unless the UTXO info
|
||||
// is exchanged between the peers.
|
||||
func NewSegWitV0DualFundingPrevOutputFetcher(localSource CoinSource,
|
||||
remoteInputs []*wire.TxIn) txscript.PrevOutputFetcher {
|
||||
|
||||
|
||||
Reference in new issue
Block a user