walletrpc: add p2tr to NextAddr and BumpFee RPCs

This commit is contained in:
Oliver Gugger 2022-06-10 14:03:46 +02:00
parent 9dea4f3b5e
commit 36d6656d0d
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -542,6 +542,9 @@ func (w *WalletKit) NextAddr(ctx context.Context,
case AddressType_HYBRID_NESTED_WITNESS_PUBKEY_HASH:
return nil, fmt.Errorf("invalid address type for next "+
"address: %v", req.Type)
case AddressType_TAPROOT_PUBKEY:
addrType = lnwallet.TaprootPubkey
}
addr, err := w.cfg.Wallet.NewAddress(addrType, req.Change, account)
@ -858,16 +861,6 @@ func (w *WalletKit) BumpFee(ctx context.Context,
"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{
Output: &wire.TxOut{
PkScript: utxo.PkScript,
@ -876,6 +869,19 @@ func (w *WalletKit) BumpFee(ctx context.Context,
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
// with an unconfirmed transaction.
_, currentHeight, err := w.cfg.Chain.GetBestBlock()
@ -884,8 +890,9 @@ func (w *WalletKit) BumpFee(ctx context.Context,
err)
}
input := input.NewBaseInput(op, witnessType, signDesc, uint32(currentHeight))
if _, err = w.cfg.Sweeper.SweepInput(input, sweep.Params{Fee: feePreference}); err != nil {
inp := input.NewBaseInput(op, witnessType, signDesc, uint32(currentHeight))
sweepParams := sweep.Params{Fee: feePreference}
if _, err = w.cfg.Sweeper.SweepInput(inp, sweepParams); err != nil {
return nil, err
}