github.com/decred/dcrlnd@v0.7.6/watchtower/config.go (about) 1 package watchtower 2 3 import ( 4 "fmt" 5 "net" 6 "time" 7 8 "github.com/decred/dcrd/chaincfg/chainhash" 9 "github.com/decred/dcrd/chaincfg/v3" 10 "github.com/decred/dcrd/txscript/v4/stdaddr" 11 "github.com/decred/dcrd/wire" 12 "github.com/decred/dcrlnd/keychain" 13 "github.com/decred/dcrlnd/tor" 14 "github.com/decred/dcrlnd/watchtower/lookout" 15 ) 16 17 const ( 18 // DefaultPeerPort is the default server port to which clients can 19 // connect. 20 DefaultPeerPort = 9911 21 22 // DefaultReadTimeout is the default timeout after which the tower will 23 // hang up on a client if nothing is received. 24 DefaultReadTimeout = 15 * time.Second 25 26 // DefaultWriteTimeout is the default timeout after which the tower will 27 // hang up on a client if it is unable to send a message. 28 DefaultWriteTimeout = 15 * time.Second 29 ) 30 31 var ( 32 // DefaultListenAddr is the default watchtower address listening on all 33 // interfaces. 34 DefaultListenAddr = fmt.Sprintf(":%d", DefaultPeerPort) 35 ) 36 37 // Config defines the resources and parameters used to configure a Watchtower. 38 // All nil-able elements besides tor-related ones must be set in order for the 39 // Watchtower to function properly. 40 type Config struct { 41 // NetParams are the network paramters for the chain this watchtower is 42 // monitoring. 43 NetParams *chaincfg.Params 44 45 // ChainHash identifies the chain that the watchtower will be monitoring 46 // for breaches and that will be advertised in the server's Init message 47 // to inbound clients. 48 ChainHash chainhash.Hash 49 50 // BlockFetcher supports the ability to fetch blocks from the network by 51 // hash. 52 BlockFetcher lookout.BlockFetcher 53 54 // DB provides access to persistent storage of sessions and state 55 // updates uploaded by watchtower clients, and the ability to query for 56 // breach hints when receiving new blocks. 57 DB DB 58 59 // EpochRegistrar supports the ability to register for events 60 // corresponding to newly created blocks. 61 EpochRegistrar lookout.EpochRegistrar 62 63 // Net specifies the network type that the watchtower will use to listen 64 // for client connections. Either a clear net or Tor are supported. 65 Net tor.Net 66 67 // NewAddress is used to generate reward addresses, where a cut of 68 // successfully sent funds can be received. 69 NewAddress func() (stdaddr.Address, error) 70 71 // NodeKeyECDH is the ECDH capable wrapper of the key to be used in 72 // accepting new brontide connections. 73 NodeKeyECDH keychain.SingleKeyECDH 74 75 // PublishTx provides the ability to send a signed transaction to the 76 // network. 77 // 78 // TODO(conner): replace with lnwallet.WalletController interface to 79 // have stronger guarantees wrt. returned error types. 80 PublishTx func(*wire.MsgTx, string) error 81 82 // ListenAddrs specifies the listening addresses of the tower. 83 ListenAddrs []net.Addr 84 85 // ExternalIPs specifies the addresses to which clients may connect to 86 // the tower. 87 ExternalIPs []net.Addr 88 89 // ReadTimeout specifies how long a client may go without sending a 90 // message. 91 ReadTimeout time.Duration 92 93 // WriteTimeout specifies how long a client may go without reading a 94 // message from the other end, if the connection has stopped buffering 95 // the server's replies. 96 WriteTimeout time.Duration 97 98 // TorController allows the watchtower to optionally setup an onion hidden 99 // service. 100 TorController *tor.Controller 101 102 // WatchtowerKeyPath allows the watchtower to specify where the private key 103 // for a watchtower hidden service should be stored. 104 WatchtowerKeyPath string 105 106 // Type specifies the hidden service type (V2 or V3) that the watchtower 107 // will create. 108 Type tor.OnionType 109 }