mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-26 16:51:28 +02:00
Merge pull request #6632 from lightningnetwork/addr-type-taproot
walletkit+sweeper: add forgotten P2TR address type
This commit is contained in:
commit
4d7ff6a73c
@ -542,6 +542,9 @@ func (w *WalletKit) NextAddr(ctx context.Context,
|
|||||||
case AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH:
|
case AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH:
|
||||||
return nil, fmt.Errorf("invalid address type for next "+
|
return nil, fmt.Errorf("invalid address type for next "+
|
||||||
"address: %v", req.Type)
|
"address: %v", req.Type)
|
||||||
|
|
||||||
|
case AddressType_TAPROOT_PUBKEY:
|
||||||
|
addrType = lnwallet.TaprootPubkey
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, err := w.cfg.Wallet.NewAddress(addrType, req.Change, account)
|
addr, err := w.cfg.Wallet.NewAddress(addrType, req.Change, account)
|
||||||
@ -858,16 +861,6 @@ func (w *WalletKit) BumpFee(ctx context.Context,
|
|||||||
"transaction")
|
"transaction")
|
||||||
}
|
}
|
||||||
|
|
||||||
var witnessType input.WitnessType
|
|
||||||
switch utxo.AddressType {
|
|
||||||
case lnwallet.WitnessPubKey:
|
|
||||||
witnessType = input.WitnessKeyHash
|
|
||||||
case lnwallet.NestedWitnessPubKey:
|
|
||||||
witnessType = input.NestedWitnessKeyHash
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unknown input witness %v", op)
|
|
||||||
}
|
|
||||||
|
|
||||||
signDesc := &input.SignDescriptor{
|
signDesc := &input.SignDescriptor{
|
||||||
Output: &wire.TxOut{
|
Output: &wire.TxOut{
|
||||||
PkScript: utxo.PkScript,
|
PkScript: utxo.PkScript,
|
||||||
@ -876,6 +869,19 @@ func (w *WalletKit) BumpFee(ctx context.Context,
|
|||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var witnessType input.WitnessType
|
||||||
|
switch utxo.AddressType {
|
||||||
|
case lnwallet.WitnessPubKey:
|
||||||
|
witnessType = input.WitnessKeyHash
|
||||||
|
case lnwallet.NestedWitnessPubKey:
|
||||||
|
witnessType = input.NestedWitnessKeyHash
|
||||||
|
case lnwallet.TaprootPubkey:
|
||||||
|
witnessType = input.TaprootPubKeySpend
|
||||||
|
signDesc.HashType = txscript.SigHashDefault
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown input witness %v", op)
|
||||||
|
}
|
||||||
|
|
||||||
// We'll use the current height as the height hint since we're dealing
|
// We'll use the current height as the height hint since we're dealing
|
||||||
// with an unconfirmed transaction.
|
// with an unconfirmed transaction.
|
||||||
_, currentHeight, err := w.cfg.Chain.GetBestBlock()
|
_, currentHeight, err := w.cfg.Chain.GetBestBlock()
|
||||||
@ -884,8 +890,9 @@ func (w *WalletKit) BumpFee(ctx context.Context,
|
|||||||
err)
|
err)
|
||||||
}
|
}
|
||||||
|
|
||||||
input := input.NewBaseInput(op, witnessType, signDesc, uint32(currentHeight))
|
inp := input.NewBaseInput(op, witnessType, signDesc, uint32(currentHeight))
|
||||||
if _, err = w.cfg.Sweeper.SweepInput(input, sweep.Params{Fee: feePreference}); err != nil {
|
sweepParams := sweep.Params{Fee: feePreference}
|
||||||
|
if _, err = w.cfg.Sweeper.SweepInput(inp, sweepParams); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,8 @@ func (r *RPCKeyRing) FinalizePsbt(packet *psbt.Packet, _ string) error {
|
|||||||
// ones to sign. If there is any input without witness data that we
|
// ones to sign. If there is any input without witness data that we
|
||||||
// cannot sign because it's not our UTXO, this will be a hard failure.
|
// cannot sign because it's not our UTXO, this will be a hard failure.
|
||||||
tx := packet.UnsignedTx
|
tx := packet.UnsignedTx
|
||||||
sigHashes := input.NewTxSigHashesV0Only(tx)
|
prevOutFetcher := basewallet.PsbtPrevOutputFetcher(packet)
|
||||||
|
sigHashes := txscript.NewTxSigHashes(tx, prevOutFetcher)
|
||||||
for idx, txIn := range tx.TxIn {
|
for idx, txIn := range tx.TxIn {
|
||||||
in := packet.Inputs[idx]
|
in := packet.Inputs[idx]
|
||||||
|
|
||||||
|
@ -355,17 +355,6 @@ func (t *txInputSet) tryAddWalletInputsIfNeeded() error {
|
|||||||
// createWalletTxInput converts a wallet utxo into an object that can be added
|
// createWalletTxInput converts a wallet utxo into an object that can be added
|
||||||
// to the other inputs to sweep.
|
// to the other inputs to sweep.
|
||||||
func createWalletTxInput(utxo *lnwallet.Utxo) (input.Input, error) {
|
func createWalletTxInput(utxo *lnwallet.Utxo) (input.Input, error) {
|
||||||
var witnessType input.WitnessType
|
|
||||||
switch utxo.AddressType {
|
|
||||||
case lnwallet.WitnessPubKey:
|
|
||||||
witnessType = input.WitnessKeyHash
|
|
||||||
case lnwallet.NestedWitnessPubKey:
|
|
||||||
witnessType = input.NestedWitnessKeyHash
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("unknown address type %v",
|
|
||||||
utxo.AddressType)
|
|
||||||
}
|
|
||||||
|
|
||||||
signDesc := &input.SignDescriptor{
|
signDesc := &input.SignDescriptor{
|
||||||
Output: &wire.TxOut{
|
Output: &wire.TxOut{
|
||||||
PkScript: utxo.PkScript,
|
PkScript: utxo.PkScript,
|
||||||
@ -374,6 +363,20 @@ func createWalletTxInput(utxo *lnwallet.Utxo) (input.Input, error) {
|
|||||||
HashType: txscript.SigHashAll,
|
HashType: txscript.SigHashAll,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var witnessType input.WitnessType
|
||||||
|
switch utxo.AddressType {
|
||||||
|
case lnwallet.WitnessPubKey:
|
||||||
|
witnessType = input.WitnessKeyHash
|
||||||
|
case lnwallet.NestedWitnessPubKey:
|
||||||
|
witnessType = input.NestedWitnessKeyHash
|
||||||
|
case lnwallet.TaprootPubkey:
|
||||||
|
witnessType = input.TaprootPubKeySpend
|
||||||
|
signDesc.HashType = txscript.SigHashDefault
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unknown address type %v",
|
||||||
|
utxo.AddressType)
|
||||||
|
}
|
||||||
|
|
||||||
// A height hint doesn't need to be set, because we don't monitor these
|
// A height hint doesn't need to be set, because we don't monitor these
|
||||||
// inputs for spend.
|
// inputs for spend.
|
||||||
heightHint := uint32(0)
|
heightHint := uint32(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user