Skip to content

Commit 905adb8

Browse files
committed
withdraw: check error from RegisterSpendNtfn before using channels
handleWithdrawal did not check the error returned by RegisterSpendNtfn before spawning a goroutine to read from the notification channels. If registration failed, spentChan would be nil and the goroutine would block forever on a nil channel read. Add the missing error check so the function returns early on registration failure.
1 parent cae5914 commit 905adb8

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

staticaddr/withdraw/manager.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ func (m *Manager) handleWithdrawal(ctx context.Context,
676676
ctx, &d.OutPoint, addrParams.PkScript,
677677
int32(d.ConfirmationHeight),
678678
)
679+
if err != nil {
680+
return fmt.Errorf("unable to register spend ntfn: %w", err)
681+
}
679682

680683
go func() {
681684
select {

0 commit comments

Comments
 (0)