-
Notifications
You must be signed in to change notification settings - Fork 2.3k
rpc: expose invoice features in decodepayreq #3802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a77e111
f342398
5defa42
a168f37
1367187
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ package lnwire | |
| import ( | ||
| "encoding/binary" | ||
| "errors" | ||
| "fmt" | ||
| "io" | ||
| ) | ||
|
|
||
|
|
@@ -95,6 +94,11 @@ const ( | |
| maxAllowedSize = 32764 | ||
| ) | ||
|
|
||
| // IsRequired returns true if the feature bit is even, and false otherwise. | ||
| func (b FeatureBit) IsRequired() bool { | ||
| return b&0x01 == 0x00 | ||
| } | ||
|
|
||
| // Features is a mapping of known feature bits to a descriptive name. All known | ||
| // feature bits must be assigned a name in this mapping, and feature bit pairs | ||
| // must be assigned together for correct behavior. | ||
|
|
@@ -362,9 +366,9 @@ func (fv *FeatureVector) UnknownRequiredFeatures() []FeatureBit { | |
| func (fv *FeatureVector) Name(bit FeatureBit) string { | ||
| name, known := fv.featureNames[bit] | ||
| if !known { | ||
| name = "unknown" | ||
| return "unknown" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the commit message: Perhaps we should leave displaying the bit for unknown features?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the bit is exposed separately in the rpc, wouldn't it be redundant? |
||
| } | ||
| return fmt.Sprintf("%s(%d)", name, bit) | ||
| return name | ||
| } | ||
|
|
||
| // IsKnown returns whether this feature bit represents a known feature. | ||
|
|
@@ -384,6 +388,15 @@ func (fv *FeatureVector) isFeatureBitPair(bit FeatureBit) bool { | |
| return known1 && known2 && name1 == name2 | ||
| } | ||
|
|
||
| // Features returns the set of raw features contained in the feature vector. | ||
| func (fv *FeatureVector) Features() map[FeatureBit]struct{} { | ||
| fs := make(map[FeatureBit]struct{}, len(fv.RawFeatureVector.features)) | ||
| for b := range fv.RawFeatureVector.features { | ||
| fs[b] = struct{}{} | ||
| } | ||
| return fs | ||
| } | ||
|
|
||
| // Clone copies a feature vector, carrying over its feature bits. The feature | ||
| // names are not copied. | ||
| func (fv *FeatureVector) Clone() *FeatureVector { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.