From 5bf9b710fc9207224947ac8e4f2f7595ca2e50fd Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 16 Mar 2022 15:11:14 +0100 Subject: [PATCH] config_builder+rpcwallet: add full net params As a preparation for parsing addresses, we need the full network parameters and not just the coin type in the RPC wallet. --- config_builder.go | 2 +- lnwallet/rpcwallet/rpcwallet.go | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/config_builder.go b/config_builder.go index 0e8ddfa8d..0e1bc5560 100644 --- a/config_builder.go +++ b/config_builder.go @@ -691,7 +691,7 @@ func (d *RPCSignerWalletImpl) BuildChainControl( rpcKeyRing, err := rpcwallet.NewRPCKeyRing( baseKeyRing, walletController, - d.DefaultWalletImpl.cfg.RemoteSigner, walletConfig.CoinType, + d.DefaultWalletImpl.cfg.RemoteSigner, walletConfig.NetParams, ) if err != nil { err := fmt.Errorf("unable to create RPC remote signing wallet "+ diff --git a/lnwallet/rpcwallet/rpcwallet.go b/lnwallet/rpcwallet/rpcwallet.go index ebb11f531..3293e1955 100644 --- a/lnwallet/rpcwallet/rpcwallet.go +++ b/lnwallet/rpcwallet/rpcwallet.go @@ -14,6 +14,7 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/btcutil/psbt" + "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" basewallet "github.com/btcsuite/btcwallet/wallet" @@ -51,7 +52,7 @@ type RPCKeyRing struct { watchOnlyKeyRing keychain.SecretKeyRing - coinType uint32 + netParams *chaincfg.Params rpcTimeout time.Duration @@ -69,7 +70,8 @@ var _ lnwallet.WalletController = (*RPCKeyRing)(nil) // delegates any signing or ECDH operations to the remove signer through RPC. func NewRPCKeyRing(watchOnlyKeyRing keychain.SecretKeyRing, watchOnlyWalletController lnwallet.WalletController, - remoteSigner *lncfg.RemoteSigner, coinType uint32) (*RPCKeyRing, error) { + remoteSigner *lncfg.RemoteSigner, + netParams *chaincfg.Params) (*RPCKeyRing, error) { rpcConn, err := connectRPC( remoteSigner.RPCHost, remoteSigner.TLSCertPath, @@ -83,7 +85,7 @@ func NewRPCKeyRing(watchOnlyKeyRing keychain.SecretKeyRing, return &RPCKeyRing{ WalletController: watchOnlyWalletController, watchOnlyKeyRing: watchOnlyKeyRing, - coinType: coinType, + netParams: netParams, rpcTimeout: remoteSigner.Timeout, signerClient: signrpc.NewSignerClient(rpcConn), walletClient: walletrpc.NewWalletKitClient(rpcConn), @@ -610,7 +612,8 @@ func (r *RPCKeyRing) remoteSign(tx *wire.MsgTx, signDesc *input.SignDescriptor, Bip32Path: []uint32{ keychain.BIP0043Purpose + hdkeychain.HardenedKeyStart, - r.coinType + hdkeychain.HardenedKeyStart, + r.netParams.HDCoinType + + hdkeychain.HardenedKeyStart, uint32(signDesc.KeyDesc.Family) + hdkeychain.HardenedKeyStart, 0,