diff --git a/htlcswitch/hodl/config.go b/htlcswitch/hodl/config.go index e14eb7ea..22a65b52 100644 --- a/htlcswitch/hodl/config.go +++ b/htlcswitch/hodl/config.go @@ -21,6 +21,8 @@ type Config struct { FailOutgoing bool `long:"fail-outgoing" description:"Instructs the node to drop outgoing FAILs before applying them to the channel state"` Commit bool `long:"commit" description:"Instructs the node to add HTLCs to its local commitment state and to open circuits for any ADDs, but abort before committing the changes"` + + BogusSettle bool `long:"bogus-settle" description:"Instructs the node to settle back any incoming HTLC with a bogus preimage"` } // Mask extracts the flags specified in the configuration, composing a Mask from @@ -52,6 +54,9 @@ func (c *Config) Mask() Mask { if c.Commit { flags = append(flags, Commit) } + if c.BogusSettle { + flags = append(flags, BogusSettle) + } // NOTE: The value returned here will only honor the configuration if // the debug build flag is present. In production, this method always diff --git a/htlcswitch/hodl/flags.go b/htlcswitch/hodl/flags.go index 688999f3..7fed7d09 100644 --- a/htlcswitch/hodl/flags.go +++ b/htlcswitch/hodl/flags.go @@ -51,6 +51,10 @@ const ( // Commit drops all HTLC after any outgoing circuits have been // opened, but before the in-memory commitment state is persisted. Commit + + // BogusSettle attempts to settle back any incoming HTLC for which we + // are the exit node with a bogus preimage. + BogusSettle ) // String returns a human-readable identifier for a given Flag. @@ -72,6 +76,8 @@ func (f Flag) String() string { return "FailOutgoing" case Commit: return "Commit" + case BogusSettle: + return "BogusSettle" default: return "UnknownHodlFlag" } @@ -98,6 +104,8 @@ func (f Flag) Warning() string { msg = "will not update channel state with downstream FAIL" case Commit: msg = "will not commit pending channel updates" + case BogusSettle: + msg = "will settle HTLC with bogus preimage" default: msg = "incorrect hodl flag usage" } diff --git a/htlcswitch/hodl/mask_test.go b/htlcswitch/hodl/mask_test.go index 7becd457..cf29d19b 100644 --- a/htlcswitch/hodl/mask_test.go +++ b/htlcswitch/hodl/mask_test.go @@ -67,6 +67,7 @@ var hodlMaskTests = []struct { hodl.SettleOutgoing, hodl.FailOutgoing, hodl.Commit, + hodl.BogusSettle, ), flags: map[hodl.Flag]struct{}{ hodl.ExitSettle: {}, @@ -77,6 +78,7 @@ var hodlMaskTests = []struct { hodl.SettleOutgoing: {}, hodl.FailOutgoing: {}, hodl.Commit: {}, + hodl.BogusSettle: {}, }, }, }