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,
|
f.coinSource, extraInputs,
|
||||||
)
|
)
|
||||||
signDesc := input.SignDescriptor{
|
signDesc := input.SignDescriptor{
|
||||||
HashType: txscript.SigHashAll,
|
|
||||||
SigHashes: txscript.NewTxSigHashes(
|
SigHashes: txscript.NewTxSigHashes(
|
||||||
fundingTx, prevOutFetcher,
|
fundingTx, prevOutFetcher,
|
||||||
),
|
),
|
||||||
@@ -136,6 +135,13 @@ func (f *FullIntent) CompileFundingTx(extraInputs []*wire.TxIn,
|
|||||||
}
|
}
|
||||||
signDesc.InputIndex = i
|
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
|
// Finally, we'll sign the input as is, and populate the input
|
||||||
// with the witness and sigScript (if needed).
|
// with the witness and sigScript (if needed).
|
||||||
inputScript, err := f.signer.ComputeInputScript(
|
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
|
// 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
|
// 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,
|
func NewSegWitV0DualFundingPrevOutputFetcher(localSource CoinSource,
|
||||||
remoteInputs []*wire.TxIn) txscript.PrevOutputFetcher {
|
remoteInputs []*wire.TxIn) txscript.PrevOutputFetcher {
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user