mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: move label validation to rpc and simplify validation function
Previously labels with reserved prefixes were added to provide us with a way to identify automatically dispatched loops. This commit moves the validation of these labels to the rpc level so that it will only apply to user-initiated swaps.
This commit is contained in:
parent
15a400b411
commit
7b56804bbe
5 changed files with 16 additions and 21 deletions
|
|
@ -2,6 +2,7 @@ package labels
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -29,16 +30,10 @@ func Validate(label string) error {
|
|||
return ErrLabelTooLong
|
||||
}
|
||||
|
||||
// If the label is shorter than our reserved prefix, it cannot contain
|
||||
// it.
|
||||
if len(label) < len(Reserved) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if our label begins with our reserved prefix. We don't mind if
|
||||
// it has our reserved prefix in another case, we just need to be able
|
||||
// to reserve a subset of labels with this prefix.
|
||||
if label[0:len(Reserved)] == Reserved {
|
||||
if strings.HasPrefix(label, Reserved) {
|
||||
return ErrReservedPrefix
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue