mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-27 22:16:16 +02:00
multi: add p2tr tapscript key path signing capabilities
This commit is contained in:
@@ -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