Browse Source

fakechanbackup: fix onion address parsing

Fixes #24 by correctly parsing Tor addresses that contain a .onion
hostname.
pull/33/head
Oliver Gugger 2 months ago
parent
commit
cb42bd1a94
No known key found for this signature in database GPG Key ID: 8E4256593F177720
1 changed files with 20 additions and 2 deletions
  1. +20
    -2
      cmd/chantools/fakechanbackup.go

+ 20
- 2
cmd/chantools/fakechanbackup.go View File

@ -167,9 +167,27 @@ func (c *fakeChanBackupCommand) Execute(_ *cobra.Command, _ []string) error {
if err != nil {
return fmt.Errorf("could not parse pubkey: %s", err)
}
addr, err := net.ResolveTCPAddr("tcp", splitNodeInfo[1])
host, portStr, err := net.SplitHostPort(splitNodeInfo[1])
if err != nil {
return fmt.Errorf("could not parse addr: %s", err)
return fmt.Errorf("could not split host and port: %v",
err)
}
var addr net.Addr
if tor.IsOnionHost(host) {
port, err := strconv.Atoi(portStr)
if err != nil {
return fmt.Errorf("could not parse port: %v", err)
}
addr = &tor.OnionAddr{
OnionService: host,
Port: port,
}
} else {
addr, err = net.ResolveTCPAddr("tcp", splitNodeInfo[1])
if err != nil {
return fmt.Errorf("could not parse addr: %s", err)
}
}
// Parse the short channel ID.

Loading…
Cancel
Save