From cdbde5dd4c186bcbadd9272cfa892deb8176f105 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 7 Sep 2020 13:29:28 +0200 Subject: [PATCH] sweep: do not combine exclusive and non-exclusive inputs --- sweep/bucket_list.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sweep/bucket_list.go b/sweep/bucket_list.go index 4b3c67cd..12361565 100644 --- a/sweep/bucket_list.go +++ b/sweep/bucket_list.go @@ -9,9 +9,20 @@ func (b bucket) tryAdd(input *pendingInput) bool { if exclusiveGroup != nil { for _, input := range b { existingGroup := input.params.ExclusiveGroup - if existingGroup != nil && - *existingGroup == *exclusiveGroup { + // Don't add an exclusive group input if other inputs + // are non-exclusive. The exclusive group input may be + // invalid (for example in the case of commitment + // anchors) and could thereby block sweeping of the + // other inputs. + if existingGroup == nil { + return false + } + + // Don't combine inputs from the same exclusive group. + // Because only one input is valid, this may result in + // txes that are always invalid. + if *existingGroup == *exclusiveGroup { return false } }