watchtower/blob/type: add new FlagAnchorChannel
This commit is contained in:
parent
ed67ce7678
commit
0477c80732
@ -19,6 +19,11 @@ const (
|
|||||||
// FlagCommitOutputs signals that the blob contains the information
|
// FlagCommitOutputs signals that the blob contains the information
|
||||||
// required to sweep commitment outputs.
|
// required to sweep commitment outputs.
|
||||||
FlagCommitOutputs Flag = 1 << 1
|
FlagCommitOutputs Flag = 1 << 1
|
||||||
|
|
||||||
|
// FlagAnchorChannel signals that this blob is meant to spend an anchor
|
||||||
|
// channel, and therefore must expect a P2WSH-style to-remote output if
|
||||||
|
// one exists.
|
||||||
|
FlagAnchorChannel Flag = 1 << 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// Type returns a Type consisting solely of this flag enabled.
|
// Type returns a Type consisting solely of this flag enabled.
|
||||||
@ -33,6 +38,8 @@ func (f Flag) String() string {
|
|||||||
return "FlagReward"
|
return "FlagReward"
|
||||||
case FlagCommitOutputs:
|
case FlagCommitOutputs:
|
||||||
return "FlagCommitOutputs"
|
return "FlagCommitOutputs"
|
||||||
|
case FlagAnchorChannel:
|
||||||
|
return "FlagAnchorChannel"
|
||||||
default:
|
default:
|
||||||
return "FlagUnknown"
|
return "FlagUnknown"
|
||||||
}
|
}
|
||||||
@ -50,6 +57,11 @@ const (
|
|||||||
// controlled by the user, and does not give the tower a reward.
|
// controlled by the user, and does not give the tower a reward.
|
||||||
TypeAltruistCommit = Type(FlagCommitOutputs)
|
TypeAltruistCommit = Type(FlagCommitOutputs)
|
||||||
|
|
||||||
|
// TypeAltruistAnchorCommit sweeps only commitment outputs from an
|
||||||
|
// anchor commitment to a sweep address controlled by the user, and does
|
||||||
|
// not give the tower a reward.
|
||||||
|
TypeAltruistAnchorCommit = Type(FlagCommitOutputs | FlagAnchorChannel)
|
||||||
|
|
||||||
// TypeRewardCommit sweeps only commitment outputs to a sweep address
|
// TypeRewardCommit sweeps only commitment outputs to a sweep address
|
||||||
// controlled by the user, and pays a negotiated reward to the tower.
|
// controlled by the user, and pays a negotiated reward to the tower.
|
||||||
TypeRewardCommit = Type(FlagCommitOutputs | FlagReward)
|
TypeRewardCommit = Type(FlagCommitOutputs | FlagReward)
|
||||||
@ -70,10 +82,16 @@ func TypeFromFlags(flags ...Flag) Type {
|
|||||||
return typ
|
return typ
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAnchorChannel returns true if the blob type is for an anchor channel.
|
||||||
|
func (t Type) IsAnchorChannel() bool {
|
||||||
|
return t.Has(FlagAnchorChannel)
|
||||||
|
}
|
||||||
|
|
||||||
// knownFlags maps the supported flags to their name.
|
// knownFlags maps the supported flags to their name.
|
||||||
var knownFlags = map[Flag]struct{}{
|
var knownFlags = map[Flag]struct{}{
|
||||||
FlagReward: {},
|
FlagReward: {},
|
||||||
FlagCommitOutputs: {},
|
FlagCommitOutputs: {},
|
||||||
|
FlagAnchorChannel: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a human readable description of a Type.
|
// String returns a human readable description of a Type.
|
||||||
|
@ -18,17 +18,17 @@ var typeStringTests = []typeStringTest{
|
|||||||
{
|
{
|
||||||
name: "commit no-reward",
|
name: "commit no-reward",
|
||||||
typ: blob.TypeAltruistCommit,
|
typ: blob.TypeAltruistCommit,
|
||||||
expStr: "[FlagCommitOutputs|No-FlagReward]",
|
expStr: "[No-FlagAnchorChannel|FlagCommitOutputs|No-FlagReward]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "commit reward",
|
name: "commit reward",
|
||||||
typ: blob.TypeRewardCommit,
|
typ: blob.TypeRewardCommit,
|
||||||
expStr: "[FlagCommitOutputs|FlagReward]",
|
expStr: "[No-FlagAnchorChannel|FlagCommitOutputs|FlagReward]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "unknown flag",
|
name: "unknown flag",
|
||||||
typ: unknownFlag.Type(),
|
typ: unknownFlag.Type(),
|
||||||
expStr: "0000000000010000[No-FlagCommitOutputs|No-FlagReward]",
|
expStr: "0000000000010000[No-FlagAnchorChannel|No-FlagCommitOutputs|No-FlagReward]",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user