@@ -740,15 +740,23 @@ func (s *UtxoSweeper) collector() {
740740 }
741741}
742742
743- // removeExclusiveGroup removes all inputs in the given exclusive group. This
744- // function is called when one of the exclusive group inputs has been spent. The
745- // other inputs won't ever be spendable and can be removed. This also prevents
746- // them from being part of future sweep transactions that would fail. In
747- // addition sweep transactions of those inputs will be removed from the wallet.
748- func (s * UtxoSweeper ) removeExclusiveGroup (group uint64 ) {
743+ // removeExclusiveGroup removes all inputs in the given exclusive group except
744+ // the input speified by the outpoint. This function is called when one of the
745+ // exclusive group inputs has been spent or updated. The other inputs won't ever
746+ // be spendable and can be removed. This also prevents them from being part of
747+ // future sweep transactions that would fail. In addition sweep transactions of
748+ // those inputs will be removed from the wallet.
749+ func (s * UtxoSweeper ) removeExclusiveGroup (group uint64 , op wire.OutPoint ) {
749750 for outpoint , input := range s .inputs {
750751 outpoint := outpoint
751752
753+ // Skip the input that caused the exclusive group to be removed.
754+ if outpoint == op {
755+ log .Debugf ("Skipped removing exclusive input %v" , input )
756+
757+ continue
758+ }
759+
752760 // Skip inputs that aren't exclusive.
753761 if input .params .ExclusiveGroup == nil {
754762 continue
@@ -767,6 +775,8 @@ func (s *UtxoSweeper) removeExclusiveGroup(group uint64) {
767775 continue
768776 }
769777
778+ log .Debugf ("Removing exclusive group for input %v" , input )
779+
770780 // Signal result channels.
771781 s .signalResult (input , Result {
772782 Err : ErrExclusiveGroupSpend ,
@@ -1375,14 +1385,11 @@ func (s *UtxoSweeper) handleExistingInput(input *sweepInputMessage,
13751385 // different sweeps with the same exclusive group are registered with
13761386 // the sweeper to bump the closing transaction (cpfp) when its time
13771387 // critical. Receiving an input which was already registered with the
1378- // sweeper but now without an exclusive group means non of the previous
1379- // inputs were used as CPFP, so we need to make sure we update the
1380- // sweep parameters but also remove all inputs with the same exclusive
1381- // group because the are outdated too.
1388+ // sweeper means non of the previous inputs were used as CPFP, so we
1389+ // need to make sure we update the sweep parameters but also remove all
1390+ // inputs with the same exclusive group because the are outdated too.
13821391 var prevExclGroup * uint64
1383- if oldInput .params .ExclusiveGroup != nil &&
1384- input .params .ExclusiveGroup == nil {
1385-
1392+ if oldInput .params .ExclusiveGroup != nil {
13861393 prevExclGroup = new (uint64 )
13871394 * prevExclGroup = * oldInput .params .ExclusiveGroup
13881395 }
@@ -1401,7 +1408,7 @@ func (s *UtxoSweeper) handleExistingInput(input *sweepInputMessage,
14011408 oldInput .listeners = append (oldInput .listeners , input .resultChan )
14021409
14031410 if prevExclGroup != nil {
1404- s .removeExclusiveGroup (* prevExclGroup )
1411+ s .removeExclusiveGroup (* prevExclGroup , input . input . OutPoint () )
14051412 }
14061413}
14071414
@@ -1493,7 +1500,9 @@ func (s *UtxoSweeper) markInputsSwept(tx *wire.MsgTx, isOurTx bool) {
14931500
14941501 // Remove all other inputs in this exclusive group.
14951502 if input .params .ExclusiveGroup != nil {
1496- s .removeExclusiveGroup (* input .params .ExclusiveGroup )
1503+ s .removeExclusiveGroup (
1504+ * input .params .ExclusiveGroup , outpoint ,
1505+ )
14971506 }
14981507 }
14991508}
@@ -1908,7 +1917,9 @@ func (s *UtxoSweeper) markInputSwept(inp *SweeperInput, tx *wire.MsgTx) {
19081917
19091918 // Remove all other inputs in this exclusive group.
19101919 if inp .params .ExclusiveGroup != nil {
1911- s .removeExclusiveGroup (* inp .params .ExclusiveGroup )
1920+ s .removeExclusiveGroup (
1921+ * inp .params .ExclusiveGroup , inp .OutPoint (),
1922+ )
19121923 }
19131924}
19141925
0 commit comments