-
Notifications
You must be signed in to change notification settings - Fork 39
/
chainnet.go
77 lines (68 loc) · 1.65 KB
/
chainnet.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package btc
import (
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/rpcclient"
)
const (
ChainSignet = "signet"
ChainMainnet = "mainnet"
// ComingChat used, similar mainnet's alias.
ChainBitcoin = "bitcoin"
)
func isValidChain(chainnet string) bool {
switch chainnet {
case ChainSignet, ChainBitcoin, ChainMainnet:
return true
default:
return false
}
}
func netParamsOf(chainnet string) (*chaincfg.Params, error) {
switch chainnet {
case ChainSignet:
return &chaincfg.SigNetParams, nil
case ChainMainnet, ChainBitcoin:
return &chaincfg.MainNetParams, nil
}
return nil, ErrUnsupportedChain
}
func scanHostOf(chainnet string) (string, error) {
switch chainnet {
case ChainSignet:
return "https://electrs-pre.coming.chat", nil
case ChainMainnet, ChainBitcoin:
return "https://electrs-mainnet.coming.chat", nil
default:
return "", ErrUnsupportedChain
}
}
func rpcClientOf(chainnet string) (*rpcclient.Client, error) {
switch chainnet {
case ChainSignet:
return rpcclient.New(&rpcclient.ConnConfig{
Host: "115.29.163.193:38332",
User: "auth",
Pass: "bitcoin-b2dd077",
HTTPPostMode: true,
DisableTLS: true,
}, nil)
case ChainMainnet, ChainBitcoin:
return rpcclient.New(&rpcclient.ConnConfig{
Host: "115.29.163.193:8332",
User: "auth",
Pass: "bitcoin-b2dd077",
HTTPPostMode: true,
DisableTLS: true,
}, nil)
}
return nil, ErrUnsupportedChain
}
func nameOf(chainnet string) (string, error) {
switch chainnet {
case ChainSignet:
return "sBTC", nil
case ChainMainnet, ChainBitcoin:
return "BTC", nil
}
return "", ErrUnsupportedChain
}