Skip to content

Commit 58e157c

Browse files
authored
Merge pull request #692 from hieblmi/static-addr-dependencies
StaticAddr: Dependencies
2 parents 59e5460 + fdf77ed commit 58e157c

File tree

4 files changed

+270
-161
lines changed

4 files changed

+270
-161
lines changed

staticaddr/protocol_version.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package staticaddr
2+
3+
import (
4+
looprpc "github.com/lightninglabs/loop/swapserverrpc"
5+
)
6+
7+
// AddressProtocolVersion represents the protocol version (declared on rpc
8+
// level) that the client declared to us.
9+
type AddressProtocolVersion uint32
10+
11+
const (
12+
// ProtocolVersion_V0 indicates that the client is a legacy version
13+
// that did not report its protocol version.
14+
ProtocolVersion_V0 AddressProtocolVersion = 0
15+
16+
// stableRPCProtocolVersion defines the current stable RPC protocol
17+
// version.
18+
stableRPCProtocolVersion = looprpc.StaticAddressProtocolVersion_V0
19+
)
20+
21+
var (
22+
// currentRPCProtocolVersion holds the version of the RPC protocol
23+
// that the client selected to use for new swaps. Shouldn't be lower
24+
// than the previous protocol version.
25+
currentRPCProtocolVersion = stableRPCProtocolVersion
26+
)
27+
28+
// CurrentRPCProtocolVersion returns the RPC protocol version selected to be
29+
// used for new swaps.
30+
func CurrentRPCProtocolVersion() looprpc.StaticAddressProtocolVersion {
31+
return currentRPCProtocolVersion
32+
}
33+
34+
// Valid returns true if the value of the AddressProtocolVersion is valid.
35+
func (p AddressProtocolVersion) Valid() bool {
36+
return p <= AddressProtocolVersion(stableRPCProtocolVersion)
37+
}
38+
39+
// String returns the string representation of a protocol version.
40+
func (p AddressProtocolVersion) String() string {
41+
switch p {
42+
case ProtocolVersion_V0:
43+
return "V0"
44+
45+
default:
46+
return "Unknown"
47+
}
48+
}

swap/keychain.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ var (
44
// KeyFamily is the key family used to generate keys that allow
55
// spending of the htlc.
66
KeyFamily = int32(99)
7+
8+
// StaticAddressKeyFamily is the key family used to generate static
9+
// address keys.
10+
StaticAddressKeyFamily = int32(42060)
711
)

0 commit comments

Comments
 (0)