forked from FactomProject/factom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
resolve.go
35 lines (28 loc) · 807 Bytes
/
resolve.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2016 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package factom
import (
"fmt"
netki "github.com/FactomProject/netki-go-partner-client"
)
func ResolveDnsName(addr string) (string, string, error) {
fct, err1 := netki.WalletNameLookup(addr, "fct")
ec, err2 := netki.WalletNameLookup(addr, "fec")
if err1 != nil && err2 != nil {
return fct, ec, fmt.Errorf("%s\n%s", err1, err2)
}
return fct, ec, nil
}
func GetDnsBalance(addr string) (int64, int64, error) {
fct, ec, err := ResolveDnsName(addr)
if err != nil {
return -1, -1, err
}
f, err1 := GetFactoidBalance(fct)
e, err2 := GetECBalance(ec)
if err1 != nil || err2 != nil {
return f, e, fmt.Errorf("%s\n%s\n", err1, err2)
}
return f, e, nil
}