From bf06dc24c174c38b23e59d22907ac7b26b03e26e Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 17 Jul 2018 09:13:05 +0200 Subject: [PATCH] contractcourt/contract_resolvers: make waitForOutputResolution use confirmed spend --- contractcourt/contract_resolvers.go | 34 +++-------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/contractcourt/contract_resolvers.go b/contractcourt/contract_resolvers.go index 0a0ec5e2b..d863343b9 100644 --- a/contractcourt/contract_resolvers.go +++ b/contractcourt/contract_resolvers.go @@ -169,45 +169,17 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) { // spent, and the spending transaction has been fully confirmed. waitForOutputResolution := func() error { // We first need to register to see when the HTLC output itself - // has been spent so we can wait for the spending transaction - // to confirm. + // has been spent by a confirmed transaction. spendNtfn, err := h.Notifier.RegisterSpendNtfn( &h.htlcResolution.ClaimOutpoint, - h.broadcastHeight, true, + h.broadcastHeight, false, ) if err != nil { return err } - var spendDetail *chainntnfs.SpendDetail select { - case s, ok := <-spendNtfn.Spend: - if !ok { - return fmt.Errorf("notifier quit") - } - - spendDetail = s - - case <-h.Quit: - return fmt.Errorf("quitting") - } - - // Now that the output has been spent, we'll also wait for the - // transaction to be confirmed before proceeding. - confNtfn, err := h.Notifier.RegisterConfirmationsNtfn( - spendDetail.SpenderTxHash, 1, - uint32(spendDetail.SpendingHeight-1), - ) - if err != nil { - return err - } - - log.Infof("%T(%v): waiting for spending (txid=%v) to be fully "+ - "confirmed", h, h.htlcResolution.ClaimOutpoint, - spendDetail.SpenderTxHash) - - select { - case _, ok := <-confNtfn.Confirmed: + case _, ok := <-spendNtfn.Spend: if !ok { return fmt.Errorf("notifier quit") }