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,
Capacity: single.Capacity,
LocalChanCfg: dump.ToChannelConfig(
single.LocalChanCfg,
chainParams, single.LocalChanCfg,
),
RemoteChanCfg: dump.ToChannelConfig(
single.RemoteChanCfg,
chainParams, single.RemoteChanCfg,
),
ShaChainRootDesc: dump.ToKeyDescriptor(
single.ShaChainRootDesc,
chainParams, single.ShaChainRootDesc,
),
}
}

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

@ -3,6 +3,7 @@ package dump
import (
"encoding/hex"
"fmt"
"github.com/btcsuite/btcd/chaincfg"
"net"
"github.com/btcsuite/btcd/btcec"
@ -15,7 +16,7 @@ import (
)
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
@ -89,21 +90,32 @@ type KeyDescriptor struct {
PubKey string
}
func ToChannelConfig(cfg channeldb.ChannelConfig) ChannelConfig {
func ToChannelConfig(params *chaincfg.Params,
cfg channeldb.ChannelConfig) ChannelConfig {
return ChannelConfig{
ChannelConstraints: cfg.ChannelConstraints,
MultiSigKey: ToKeyDescriptor(cfg.MultiSigKey),
RevocationBasePoint: ToKeyDescriptor(cfg.RevocationBasePoint),
PaymentBasePoint: ToKeyDescriptor(cfg.PaymentBasePoint),
DelayBasePoint: ToKeyDescriptor(cfg.DelayBasePoint),
HtlcBasePoint: ToKeyDescriptor(cfg.HtlcBasePoint),
ChannelConstraints: cfg.ChannelConstraints,
MultiSigKey: ToKeyDescriptor(params, cfg.MultiSigKey),
RevocationBasePoint: ToKeyDescriptor(
params, cfg.RevocationBasePoint,
),
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{
Path: fmt.Sprintf(
lndInternalDerivationPath, desc.Family, desc.Index,
lndInternalDerivationPath, params.HDCoinType,
desc.Family, desc.Index,
),
PubKey: PubKeyToString(desc.PubKey),
}

Loading…
Cancel
Save