Show correct coin type in derivation path

pull/3/head
Oliver Gugger 4 years ago
parent b63fa3ae7d
commit 543aacad35
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -69,13 +69,13 @@ func dumpChannelBackup(multiFile *chanbackup.MultiFile,
Addresses: single.Addresses, Addresses: single.Addresses,
Capacity: single.Capacity, Capacity: single.Capacity,
LocalChanCfg: dump.ToChannelConfig( LocalChanCfg: dump.ToChannelConfig(
single.LocalChanCfg, chainParams, single.LocalChanCfg,
), ),
RemoteChanCfg: dump.ToChannelConfig( RemoteChanCfg: dump.ToChannelConfig(
single.RemoteChanCfg, chainParams, single.RemoteChanCfg,
), ),
ShaChainRootDesc: dump.ToKeyDescriptor( ShaChainRootDesc: dump.ToKeyDescriptor(
single.ShaChainRootDesc, chainParams, single.ShaChainRootDesc,
), ),
} }
} }

@ -70,10 +70,10 @@ func dumpChannelInfo(chanDb *channeldb.DB) error {
TotalMSatReceived: channel.TotalMSatReceived, TotalMSatReceived: channel.TotalMSatReceived,
PerCommitPoint: dump.PubKeyToString(perCommitPoint), PerCommitPoint: dump.PubKeyToString(perCommitPoint),
LocalChanCfg: dump.ToChannelConfig( LocalChanCfg: dump.ToChannelConfig(
channel.LocalChanCfg, chainParams, channel.LocalChanCfg,
), ),
RemoteChanCfg: dump.ToChannelConfig( RemoteChanCfg: dump.ToChannelConfig(
channel.RemoteChanCfg, chainParams, channel.RemoteChanCfg,
), ),
LocalCommitment: channel.LocalCommitment, LocalCommitment: channel.LocalCommitment,
RemoteCommitment: channel.RemoteCommitment, RemoteCommitment: channel.RemoteCommitment,

@ -3,6 +3,7 @@ package dump
import ( import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/btcsuite/btcd/chaincfg"
"net" "net"
"github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/btcec"
@ -15,7 +16,7 @@ import (
) )
const ( const (
lndInternalDerivationPath = "m/1017'/0'/%d'/0/%d" lndInternalDerivationPath = "m/1017'/%d'/%d'/0/%d"
) )
// BackupSingle is the information we want to dump from an lnd channel backup // BackupSingle is the information we want to dump from an lnd channel backup
@ -89,21 +90,32 @@ type KeyDescriptor struct {
PubKey string PubKey string
} }
func ToChannelConfig(cfg channeldb.ChannelConfig) ChannelConfig { func ToChannelConfig(params *chaincfg.Params,
cfg channeldb.ChannelConfig) ChannelConfig {
return ChannelConfig{ return ChannelConfig{
ChannelConstraints: cfg.ChannelConstraints, ChannelConstraints: cfg.ChannelConstraints,
MultiSigKey: ToKeyDescriptor(cfg.MultiSigKey), MultiSigKey: ToKeyDescriptor(params, cfg.MultiSigKey),
RevocationBasePoint: ToKeyDescriptor(cfg.RevocationBasePoint), RevocationBasePoint: ToKeyDescriptor(
PaymentBasePoint: ToKeyDescriptor(cfg.PaymentBasePoint), params, cfg.RevocationBasePoint,
DelayBasePoint: ToKeyDescriptor(cfg.DelayBasePoint), ),
HtlcBasePoint: ToKeyDescriptor(cfg.HtlcBasePoint), PaymentBasePoint: ToKeyDescriptor(
params, cfg.PaymentBasePoint,
),
DelayBasePoint: ToKeyDescriptor(
params, cfg.DelayBasePoint,
),
HtlcBasePoint: ToKeyDescriptor(params, cfg.HtlcBasePoint),
} }
} }
func ToKeyDescriptor(desc keychain.KeyDescriptor) KeyDescriptor { func ToKeyDescriptor(params *chaincfg.Params,
desc keychain.KeyDescriptor) KeyDescriptor {
return KeyDescriptor{ return KeyDescriptor{
Path: fmt.Sprintf( Path: fmt.Sprintf(
lndInternalDerivationPath, desc.Family, desc.Index, lndInternalDerivationPath, params.HDCoinType,
desc.Family, desc.Index,
), ),
PubKey: PubKeyToString(desc.PubKey), PubKey: PubKeyToString(desc.PubKey),
} }

Loading…
Cancel
Save