@@ -740,15 +740,23 @@ func (s *UtxoSweeper) collector() {
740
740
}
741
741
}
742
742
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 ) {
749
750
for outpoint , input := range s .inputs {
750
751
outpoint := outpoint
751
752
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
+
752
760
// Skip inputs that aren't exclusive.
753
761
if input .params .ExclusiveGroup == nil {
754
762
continue
@@ -767,6 +775,8 @@ func (s *UtxoSweeper) removeExclusiveGroup(group uint64) {
767
775
continue
768
776
}
769
777
778
+ log .Debugf ("Removing exclusive group for input %v" , input )
779
+
770
780
// Signal result channels.
771
781
s .signalResult (input , Result {
772
782
Err : ErrExclusiveGroupSpend ,
@@ -1375,14 +1385,11 @@ func (s *UtxoSweeper) handleExistingInput(input *sweepInputMessage,
1375
1385
// different sweeps with the same exclusive group are registered with
1376
1386
// the sweeper to bump the closing transaction (cpfp) when its time
1377
1387
// 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.
1382
1391
var prevExclGroup * uint64
1383
- if oldInput .params .ExclusiveGroup != nil &&
1384
- input .params .ExclusiveGroup == nil {
1385
-
1392
+ if oldInput .params .ExclusiveGroup != nil {
1386
1393
prevExclGroup = new (uint64 )
1387
1394
* prevExclGroup = * oldInput .params .ExclusiveGroup
1388
1395
}
@@ -1401,7 +1408,7 @@ func (s *UtxoSweeper) handleExistingInput(input *sweepInputMessage,
1401
1408
oldInput .listeners = append (oldInput .listeners , input .resultChan )
1402
1409
1403
1410
if prevExclGroup != nil {
1404
- s .removeExclusiveGroup (* prevExclGroup )
1411
+ s .removeExclusiveGroup (* prevExclGroup , input . input . OutPoint () )
1405
1412
}
1406
1413
}
1407
1414
@@ -1493,7 +1500,9 @@ func (s *UtxoSweeper) markInputsSwept(tx *wire.MsgTx, isOurTx bool) {
1493
1500
1494
1501
// Remove all other inputs in this exclusive group.
1495
1502
if input .params .ExclusiveGroup != nil {
1496
- s .removeExclusiveGroup (* input .params .ExclusiveGroup )
1503
+ s .removeExclusiveGroup (
1504
+ * input .params .ExclusiveGroup , outpoint ,
1505
+ )
1497
1506
}
1498
1507
}
1499
1508
}
@@ -1908,7 +1917,9 @@ func (s *UtxoSweeper) markInputSwept(inp *SweeperInput, tx *wire.MsgTx) {
1908
1917
1909
1918
// Remove all other inputs in this exclusive group.
1910
1919
if inp .params .ExclusiveGroup != nil {
1911
- s .removeExclusiveGroup (* inp .params .ExclusiveGroup )
1920
+ s .removeExclusiveGroup (
1921
+ * inp .params .ExclusiveGroup , inp .OutPoint (),
1922
+ )
1912
1923
}
1913
1924
}
1914
1925
0 commit comments