@@ -36,6 +36,7 @@ type SpendRegistration struct {
36
36
Outpoint * wire.OutPoint
37
37
PkScript []byte
38
38
HeightHint int32
39
+ ErrChan chan <- error
39
40
}
40
41
41
42
// ConfRegistration contains registration details.
@@ -45,18 +46,24 @@ type ConfRegistration struct {
45
46
HeightHint int32
46
47
NumConfs int32
47
48
ConfChan chan * chainntnfs.TxConfirmation
49
+ ErrChan chan <- error
48
50
}
49
51
50
52
func (c * mockChainNotifier ) RegisterSpendNtfn (ctx context.Context ,
51
53
outpoint * wire.OutPoint , pkScript []byte , heightHint int32 ) (
52
54
chan * chainntnfs.SpendDetail , chan error , error ) {
53
55
54
- c .lnd .RegisterSpendChannel <- & SpendRegistration {
56
+ spendErrChan := make (chan error , 1 )
57
+
58
+ reg := & SpendRegistration {
55
59
HeightHint : heightHint ,
56
60
Outpoint : outpoint ,
57
61
PkScript : pkScript ,
62
+ ErrChan : spendErrChan ,
58
63
}
59
64
65
+ c .lnd .RegisterSpendChannel <- reg
66
+
60
67
spendChan := make (chan * chainntnfs.SpendDetail , 1 )
61
68
errChan := make (chan error , 1 )
62
69
@@ -70,6 +77,13 @@ func (c *mockChainNotifier) RegisterSpendNtfn(ctx context.Context,
70
77
case spendChan <- m :
71
78
case <- ctx .Done ():
72
79
}
80
+
81
+ case err := <- spendErrChan :
82
+ select {
83
+ case errChan <- err :
84
+ case <- ctx .Done ():
85
+ }
86
+
73
87
case <- ctx .Done ():
74
88
}
75
89
}()
@@ -129,12 +143,15 @@ func (c *mockChainNotifier) RegisterConfirmationsNtfn(ctx context.Context,
129
143
opts ... lndclient.NotifierOption ) (chan * chainntnfs.TxConfirmation ,
130
144
chan error , error ) {
131
145
146
+ confErrChan := make (chan error , 1 )
147
+
132
148
reg := & ConfRegistration {
133
149
PkScript : pkScript ,
134
150
TxID : txid ,
135
151
HeightHint : heightHint ,
136
152
NumConfs : numConfs ,
137
153
ConfChan : make (chan * chainntnfs.TxConfirmation , 1 ),
154
+ ErrChan : confErrChan ,
138
155
}
139
156
140
157
c .Lock ()
@@ -169,6 +186,13 @@ func (c *mockChainNotifier) RegisterConfirmationsNtfn(ctx context.Context,
169
186
}
170
187
}
171
188
c .Unlock ()
189
+
190
+ case err := <- confErrChan :
191
+ select {
192
+ case errChan <- err :
193
+ case <- ctx .Done ():
194
+ }
195
+
172
196
case <- ctx .Done ():
173
197
}
174
198
}()
0 commit comments