mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-08 14:57:38 +02:00
multi: add p2tr tapscript key path signing capabilities
This commit is contained in:
@@ -61,6 +61,11 @@ type SignDescriptor struct {
|
||||
// script (PkScript).
|
||||
WitnessScript []byte
|
||||
|
||||
// TaprootKeySpend indicates that instead of a witness script being
|
||||
// spent by the signature that results from this signing request, a
|
||||
// taproot key spend is performed instead.
|
||||
TaprootKeySpend bool
|
||||
|
||||
// Output is the target output which should be signed. The PkScript and
|
||||
// Value fields within the output should be properly populated,
|
||||
// otherwise an invalid signature may be generated.
|
||||
|
@@ -2,6 +2,7 @@ package input
|
||||
|
||||
import (
|
||||
"github.com/btcsuite/btcd/blockchain"
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcwallet/waddrmgr"
|
||||
)
|
||||
@@ -643,6 +644,27 @@ func (twe *TxWeightEstimator) AddTapscriptInput(leafWitnessSize int,
|
||||
return twe
|
||||
}
|
||||
|
||||
// AddTaprootKeySpendInput updates the weight estimate to account for an
|
||||
// additional input spending a segwit v1 pay-to-taproot output using the key
|
||||
// spend path. This accepts the sighash type being used since that has an
|
||||
// influence on the total size of the signature.
|
||||
func (twe *TxWeightEstimator) AddTaprootKeySpendInput(
|
||||
hashType txscript.SigHashType) *TxWeightEstimator {
|
||||
|
||||
twe.inputSize += InputSize
|
||||
|
||||
if hashType == txscript.SigHashDefault {
|
||||
twe.inputWitnessSize += TaprootKeyPathWitnessSize
|
||||
} else {
|
||||
twe.inputWitnessSize += TaprootKeyPathCustomSighashWitnessSize
|
||||
}
|
||||
|
||||
twe.inputCount++
|
||||
twe.hasWitness = true
|
||||
|
||||
return twe
|
||||
}
|
||||
|
||||
// AddNestedP2WKHInput updates the weight estimate to account for an additional
|
||||
// input spending a P2SH output with a nested P2WKH redeem script.
|
||||
func (twe *TxWeightEstimator) AddNestedP2WKHInput() *TxWeightEstimator {
|
||||
|
Reference in New Issue
Block a user