@@ -52,8 +52,14 @@ func (s *treeSigningSessionsStore) Get(roundId string) (*ports.MusigSigningSessi
52
52
func (s * treeSigningSessionsStore ) Delete (roundId string ) {
53
53
s .lock .Lock ()
54
54
defer s .lock .Unlock ()
55
- close (s .nonceCollectedCh [roundId ])
56
- close (s .sigsCollectedCh [roundId ])
55
+
56
+ if _ , exists := s .nonceCollectedCh [roundId ]; exists {
57
+ close (s .nonceCollectedCh [roundId ])
58
+ }
59
+ if _ , exists := s .sigsCollectedCh [roundId ]; exists {
60
+ close (s .sigsCollectedCh [roundId ])
61
+ }
62
+
57
63
delete (s .nonceCollectedCh , roundId )
58
64
delete (s .sigsCollectedCh , roundId )
59
65
delete (s .sessions , roundId )
@@ -72,13 +78,15 @@ func (s *treeSigningSessionsStore) AddNonces(
72
78
if _ , ok := session .Cosigners [pubkey ]; ! ok {
73
79
return fmt .Errorf (`cosigner %s not found for round "%s"` , pubkey , roundId )
74
80
}
81
+ if _ , exists := s .nonceCollectedCh [roundId ]; ! exists {
82
+ return fmt .Errorf ("nonce channel not initialized for round %s" , roundId )
83
+ }
75
84
76
85
s .sessions [roundId ].Nonces [pubkey ] = nonces
77
86
78
87
if len (s .sessions [roundId ].Nonces ) == s .sessions [roundId ].NbCosigners - 1 {
79
88
s .nonceCollectedCh [roundId ] <- struct {}{}
80
89
}
81
-
82
90
return nil
83
91
}
84
92
@@ -95,6 +103,9 @@ func (s *treeSigningSessionsStore) AddSignatures(
95
103
if _ , ok := session .Cosigners [pubkey ]; ! ok {
96
104
return fmt .Errorf (`cosigner %s not found for round "%s"` , pubkey , roundId )
97
105
}
106
+ if _ , exists := s .sigsCollectedCh [roundId ]; ! exists {
107
+ return fmt .Errorf ("signature channel not initialized for round %s" , roundId )
108
+ }
98
109
99
110
s .sessions [roundId ].Signatures [pubkey ] = sigs
100
111
0 commit comments