diff --git a/contractcourt/briefcase.go b/contractcourt/briefcase.go index c4de7cf2..0559d931 100644 --- a/contractcourt/briefcase.go +++ b/contractcourt/briefcase.go @@ -112,7 +112,7 @@ const ( // so yet. StateBroadcastCommit ArbitratorState = 1 - // StateContractClose is a state that indicates the contract has + // StateContractClosed is a state that indicates the contract has // already been "closed". At this point, we can now examine our active // contracts, in order to create the proper resolver for each one. StateContractClosed ArbitratorState = 2 diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go index 34d1d677..940debbb 100644 --- a/contractcourt/chain_watcher.go +++ b/contractcourt/chain_watcher.go @@ -340,7 +340,7 @@ func (c *chainWatcher) closeObserver(spendNtfn *chainntnfs.SpendEvent) { commitSpend, *remoteCommit, ); err != nil { log.Errorf("unable to handle remote "+ - "close for chan_point=%v", + "close for chan_point=%v: %v", c.chanState.FundingOutpoint, err) } @@ -618,7 +618,7 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail return c.chanState.CloseChannel(&closeSummary) } -// CooperativeCloseContext is a transactional object that's used by external +// CooperativeCloseCtx is a transactional object that's used by external // parties to initiate a cooperative closure negotiation. During the // negotiation, we sign multiple versions of a closing transaction, either of // which may be counter signed and broadcast by the remote party at any time. @@ -630,8 +630,12 @@ type CooperativeCloseCtx struct { // watcher to ensure we detect all on-chain spends. potentialCloses chan *channeldb.ChannelCloseSummary + // activeCloses keeps track of all the txid's that we're currently + // watching for. activeCloses map[chainhash.Hash]struct{} + // watchCancel will be closed once *one* of the txid's in the map above + // is confirmed. This will cause all the lingering goroutines to exit. watchCancel chan struct{} watcher *chainWatcher diff --git a/contractcourt/channel_arbitrator.go b/contractcourt/channel_arbitrator.go index 1b775a67..aab4661d 100644 --- a/contractcourt/channel_arbitrator.go +++ b/contractcourt/channel_arbitrator.go @@ -679,20 +679,20 @@ const ( // needs to be taken for a given HTLC. NoAction ChainAction = 0 - // htlcTimeout indicates that the HTLC will timeout soon. As a result, - // we should get ready to sweep it on chain after the timeout. + // HtlcTimeoutAction indicates that the HTLC will timeout soon. As a + // result, we should get ready to sweep it on chain after the timeout. HtlcTimeoutAction = 1 - // HtlcClaim indicates that we should claim the HTLC on chain before - // its timeout period. + // HtlcClaimAction indicates that we should claim the HTLC on chain + // before its timeout period. HtlcClaimAction = 2 - // HtlcFailNow indicates that we should fail an outgoing HTLC + // HtlcFailNowAction indicates that we should fail an outgoing HTLC // immediately by cancelling it backwards as it has no corresponding // output in our commitment transaction. HtlcFailNowAction = 3 - // HtlcOutgoingWatchChain indicates that we can't yet timeout this + // HtlcOutgoingWatchAction indicates that we can't yet timeout this // HTLC, but we had to go to chain on order to resolve an existing // HTLC. In this case, we'll either: time it out once it expires, or // will learn the pre-image if the remote party claims the output. In diff --git a/lnwallet/size.go b/lnwallet/size.go index a9838378..2ac91d76 100644 --- a/lnwallet/size.go +++ b/lnwallet/size.go @@ -257,7 +257,7 @@ const ( AcceptedHtlcScriptSize = 3*1 + 20 + 5*1 + 33 + 7*1 + 20 + 4*1 + 33 + 5*1 + 4 + 5*1 - // AcceptedHtlcTimeoutWitnessSize: 214 + // AcceptedHtlcTimeoutWitnessSize 214 // - number_of_witness_elements: 1 byte // - sender_sig: 73 bytes // - nil_length: 1 byte @@ -333,7 +333,7 @@ const ( // - witness_script (offered_htlc_script) OfferedHtlcTimeoutWitnessSize = 1 + 1 + 1 + 73 + 1 + 73 + 1 + 1 + OfferedHtlcScriptSize - // OfferedHtlcSuccessWitnessSize: 283 bytes + // OfferedHtlcSuccessWitnessSize 283 bytes // - number_of_witness_elements: 1 byte // - nil_length: 1 byte // - receiver_sig: 73 bytes diff --git a/server.go b/server.go index 247987c6..321a9c88 100644 --- a/server.go +++ b/server.go @@ -170,7 +170,11 @@ func newServer(listenAddrs []string, chanDB *channeldb.DB, cc *chainControl, quit: make(chan struct{}), } - s.witnessBeacon = NewPreimageBeacon(s.invoices, chanDB.NewWitnessCache()) + s.witnessBeacon = &preimageBeacon{ + invoices: s.invoices, + wCache: chanDB.NewWitnessCache(), + subscribers: make(map[uint64]*preimageSubcriber), + } // If the debug HTLC flag is on, then we invoice a "master debug" // invoice which all outgoing payments will be sent and all incoming diff --git a/witness_beacon.go b/witness_beacon.go index 6aa30969..6a447588 100644 --- a/witness_beacon.go +++ b/witness_beacon.go @@ -31,18 +31,6 @@ type preimageBeacon struct { subscribers map[uint64]*preimageSubcriber } -// NewPreimageBeacon creates a new preimageBeacon instance given an invoice -// registry and witness cache. -func NewPreimageBeacon(invoices *invoiceRegistry, - wCache *channeldb.WitnessCache) *preimageBeacon { - - return &preimageBeacon{ - invoices: invoices, - wCache: wCache, - subscribers: make(map[uint64]*preimageSubcriber), - } -} - // SubcribeUpdates returns a channel that will be sent upon *each* time a new // preimage is discovered. func (p *preimageBeacon) SubcribeUpdates() *contractcourt.WitnessSubcription {