lnd
lnd copied to clipboard
lnrpc/walletrpc: expose pubkey import for taproot addresses over the RPC interface
Today the WalletKit RPC sub-server has support for normal pubkey import: https://github.com/lightningnetwork/lnd/blob/master/lnrpc/walletrpc/walletkit.proto#L93-L102. However, if you attempt to specify that the pubkey should be interpreted as a taproot output, then you'll run into this error message (deep in btcwallet): https://github.com/btcsuite/btcwallet/blob/master/wallet/import.go#L376-L378.
Thankfully, the taproot native ImportTaprootScript method exists for this purpose: https://github.com/btcsuite/btcwallet/blob/master/wallet/import.go#L407-L412.
In order to allow users to import taproot outputs into the wallet for watch-only functionality, we should update the RPC call to route through this new btcwallet call instead iff a taproot address type (for the pubkey) is detected.
Steps To Completion
- [ ] Update the logic in
walletrpc.ImportPubkeyto route to the newImportTaprootScriptcall internally within the wallet.- As this call is very generalized, we'll want to either expose a slimmed down version (import taproot vs taproot script or w/e), or just make all the parameters available in a new nested message only specifies for the taproot output import case.
- [ ] Add new integration tests for watch-only scenarios after the import of a taproot key.
That is an oversight of a recent PR of mine. https://github.com/btcsuite/btcwallet/blob/master/wallet/import.go#L376-L378 should support importing a raw public key as a Taproot address, so that should be fixed.
The ImportTaprootScript was built for importing a p2tr address with a script tree, I don't think that supports BIP86 just yet. But basically on the lnd (walletrpc) side, it should be possible to import both a p2tr BIP86 public key as well as one with a script tree.
The ImportTaprootScript was built for importing a p2tr address with a script tree, I don't think that supports BIP86 just yet.
Cool, I thought maybe it would be possible to just do the BIP 86 tweak computation, then pass that in as the main tapscript tree.
Revolves around manageutxo