@@ -36,6 +36,7 @@ type SpendRegistration struct {
3636 Outpoint * wire.OutPoint
3737 PkScript []byte
3838 HeightHint int32
39+ ErrChan chan <- error
3940}
4041
4142// ConfRegistration contains registration details.
@@ -45,18 +46,24 @@ type ConfRegistration struct {
4546 HeightHint int32
4647 NumConfs int32
4748 ConfChan chan * chainntnfs.TxConfirmation
49+ ErrChan chan <- error
4850}
4951
5052func (c * mockChainNotifier ) RegisterSpendNtfn (ctx context.Context ,
5153 outpoint * wire.OutPoint , pkScript []byte , heightHint int32 ) (
5254 chan * chainntnfs.SpendDetail , chan error , error ) {
5355
54- c .lnd .RegisterSpendChannel <- & SpendRegistration {
56+ spendErrChan := make (chan error , 1 )
57+
58+ reg := & SpendRegistration {
5559 HeightHint : heightHint ,
5660 Outpoint : outpoint ,
5761 PkScript : pkScript ,
62+ ErrChan : spendErrChan ,
5863 }
5964
65+ c .lnd .RegisterSpendChannel <- reg
66+
6067 spendChan := make (chan * chainntnfs.SpendDetail , 1 )
6168 errChan := make (chan error , 1 )
6269
@@ -70,6 +77,13 @@ func (c *mockChainNotifier) RegisterSpendNtfn(ctx context.Context,
7077 case spendChan <- m :
7178 case <- ctx .Done ():
7279 }
80+
81+ case err := <- spendErrChan :
82+ select {
83+ case errChan <- err :
84+ case <- ctx .Done ():
85+ }
86+
7387 case <- ctx .Done ():
7488 }
7589 }()
@@ -129,12 +143,15 @@ func (c *mockChainNotifier) RegisterConfirmationsNtfn(ctx context.Context,
129143 opts ... lndclient.NotifierOption ) (chan * chainntnfs.TxConfirmation ,
130144 chan error , error ) {
131145
146+ confErrChan := make (chan error , 1 )
147+
132148 reg := & ConfRegistration {
133149 PkScript : pkScript ,
134150 TxID : txid ,
135151 HeightHint : heightHint ,
136152 NumConfs : numConfs ,
137153 ConfChan : make (chan * chainntnfs.TxConfirmation , 1 ),
154+ ErrChan : confErrChan ,
138155 }
139156
140157 c .Lock ()
@@ -169,6 +186,13 @@ func (c *mockChainNotifier) RegisterConfirmationsNtfn(ctx context.Context,
169186 }
170187 }
171188 c .Unlock ()
189+
190+ case err := <- confErrChan :
191+ select {
192+ case errChan <- err :
193+ case <- ctx .Done ():
194+ }
195+
172196 case <- ctx .Done ():
173197 }
174198 }()
0 commit comments