lnrpc: allow importing Taproot pubkeys
This commit is contained in:
1 file changed
+15
-3
@@ -17,6 +17,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
|
"github.com/btcsuite/btcd/btcec/v2/schnorr"
|
||||||
"github.com/btcsuite/btcd/btcutil"
|
"github.com/btcsuite/btcd/btcutil"
|
||||||
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
"github.com/btcsuite/btcd/btcutil/hdkeychain"
|
||||||
"github.com/btcsuite/btcd/btcutil/psbt"
|
"github.com/btcsuite/btcd/btcutil/psbt"
|
||||||
@@ -1639,7 +1640,7 @@ func parseAddrType(addrType AddressType,
|
|||||||
// distinction between the standard BIP-0049 address schema (nested witness
|
// distinction between the standard BIP-0049 address schema (nested witness
|
||||||
// pubkeys everywhere) and our own BIP-0049Plus address schema (nested pubkeys
|
// pubkeys everywhere) and our own BIP-0049Plus address schema (nested pubkeys
|
||||||
// externally, witness pubkeys internally).
|
// externally, witness pubkeys internally).
|
||||||
func (w *WalletKit) ImportAccount(ctx context.Context,
|
func (w *WalletKit) ImportAccount(_ context.Context,
|
||||||
req *ImportAccountRequest) (*ImportAccountResponse, error) {
|
req *ImportAccountRequest) (*ImportAccountResponse, error) {
|
||||||
|
|
||||||
accountPubKey, err := hdkeychain.NewKeyFromString(req.ExtendedPublicKey)
|
accountPubKey, err := hdkeychain.NewKeyFromString(req.ExtendedPublicKey)
|
||||||
@@ -1699,13 +1700,24 @@ func (w *WalletKit) ImportAccount(ctx context.Context,
|
|||||||
// of legacy versions (xpub, tpub), an address type must be specified as we
|
// of legacy versions (xpub, tpub), an address type must be specified as we
|
||||||
// intend to not support importing BIP-44 keys into the wallet using the legacy
|
// intend to not support importing BIP-44 keys into the wallet using the legacy
|
||||||
// pay-to-pubkey-hash (P2PKH) scheme.
|
// pay-to-pubkey-hash (P2PKH) scheme.
|
||||||
func (w *WalletKit) ImportPublicKey(ctx context.Context,
|
func (w *WalletKit) ImportPublicKey(_ context.Context,
|
||||||
req *ImportPublicKeyRequest) (*ImportPublicKeyResponse, error) {
|
req *ImportPublicKeyRequest) (*ImportPublicKeyResponse, error) {
|
||||||
|
|
||||||
pubKey, err := btcec.ParsePubKey(req.PublicKey)
|
var (
|
||||||
|
pubKey *btcec.PublicKey
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
switch req.AddressType {
|
||||||
|
case AddressType_TAPROOT_PUBKEY:
|
||||||
|
pubKey, err = schnorr.ParsePubKey(req.PublicKey)
|
||||||
|
|
||||||
|
default:
|
||||||
|
pubKey, err = btcec.ParsePubKey(req.PublicKey)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
addrType, err := parseAddrType(req.AddressType, true)
|
addrType, err := parseAddrType(req.AddressType, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in new issue
Block a user