walletinfo: add private key to dumpaddrs

pull/51/head
Oliver Gugger 2 years ago
parent b30c4ce767
commit bfee0761b6
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

@ -232,18 +232,27 @@ func walletInfo(w *wallet.Wallet, dumpAddrs bool) (*btcec.PublicKey, string,
if !ok {
return fmt.Errorf("key is not a managed pubkey")
}
privKey, err := pka.PrivKey()
if err != nil {
return fmt.Errorf("error deriving priv key: %v",
err)
}
scope, path, _ := pka.DerivationInfo()
scopeAddrs += fmt.Sprintf(
"path=m/%d'/%d'/%d'/%d/%d, pubkey=%x, "+
"addr=%s, hash160=%x\n",
"addr=%s, hash160=%x, priv=%x\n",
scope.Purpose, scope.Coin, path.InternalAccount,
path.Branch, path.Index,
pka.PubKey().SerializeCompressed(),
pka.Address().String(), a.AddrHash(),
privKey.Serialize(),
)
return nil
}
for _, mgr := range w.Manager.ActiveScopedKeyManagers() {
var addrs []waddrmgr.ManagedAddress
err = walletdb.View(
w.Database(), func(tx walletdb.ReadTx) error {
waddrmgrNs := tx.ReadBucket(
@ -251,13 +260,23 @@ func walletInfo(w *wallet.Wallet, dumpAddrs bool) (*btcec.PublicKey, string,
)
return mgr.ForEachAccountAddress(
waddrmgrNs, 0, printAddr,
waddrmgrNs, 0,
func(a waddrmgr.ManagedAddress) error {
addrs = append(addrs, a)
return nil
},
)
},
)
if err != nil {
return nil, "", err
}
for _, addr := range addrs {
if err := printAddr(addr); err != nil {
return nil, "", err
}
}
}
}

Loading…
Cancel
Save