6
6
"strings"
7
7
8
8
"github.com/lightningnetwork/lnd/macaroons"
9
+ "gopkg.in/macaroon.v2"
9
10
)
10
11
11
12
const (
@@ -20,6 +21,11 @@ const (
20
21
// MetaRulesValuePrefix is the static prefix a macaroon caveat value has
21
22
// to mark the beginning of the rules list JSON data.
22
23
MetaRulesValuePrefix = "rules"
24
+
25
+ // CondPrivacy is the name of the custom caveat that will
26
+ // instruct lnd to send all requests with this caveat to this
27
+ // interceptor.
28
+ CondPrivacy = "privacy"
23
29
)
24
30
25
31
var (
35
41
macaroons .CondLndCustom , RuleEnforcerCaveat ,
36
42
MetaRulesValuePrefix )
37
43
44
+ // MetaPrivacyCaveatPrefix is the caveat prefix that will be used to
45
+ // identify the privacy mapper caveat.
46
+ MetaPrivacyCaveatPrefix = fmt .Sprintf ("%s %s" , macaroons .CondLndCustom ,
47
+ CondPrivacy )
48
+
49
+ // MetaPrivacyCaveat is the caveat required to ensure that the
50
+ // privacy mapper is activated as an interceptor for a request.
51
+ MetaPrivacyCaveat = macaroon.Caveat {Id : []byte (MetaPrivacyCaveatPrefix )}
52
+
38
53
// ErrNoMetaInfoCaveat is the error that is returned if a caveat doesn't
39
54
// have the prefix to be recognized as a meta information caveat.
40
55
ErrNoMetaInfoCaveat = fmt .Errorf ("not a meta info caveat" )
@@ -150,3 +165,9 @@ func ParseRuleCaveat(caveat string) (*InterceptRules, error) {
150
165
151
166
return & rules , nil
152
167
}
168
+
169
+ // IsPrivacyCaveat returns true if the given caveat string is a privacy mapper
170
+ // caveat.
171
+ func IsPrivacyCaveat (caveat string ) bool {
172
+ return strings .Contains (caveat , MetaPrivacyCaveatPrefix )
173
+ }
0 commit comments