diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go index 3b25abc75..e30eec954 100644 --- a/contractcourt/chain_arbitrator.go +++ b/contractcourt/chain_arbitrator.go @@ -113,8 +113,7 @@ type ChainArbitratorConfig struct { // the process of incubation. This is used when a resolver wishes to // pass off the output to the nursery as we're only waiting on an // absolute/relative item block. - IncubateOutputs func(wire.OutPoint, *lnwallet.CommitOutputResolution, - *lnwallet.OutgoingHtlcResolution, + IncubateOutputs func(wire.OutPoint, *lnwallet.OutgoingHtlcResolution, *lnwallet.IncomingHtlcResolution, uint32) error // PreimageDB is a global store of all known pre-images. We'll use this diff --git a/contractcourt/channel_arbitrator_test.go b/contractcourt/channel_arbitrator_test.go index 599028736..af4681a30 100644 --- a/contractcourt/channel_arbitrator_test.go +++ b/contractcourt/channel_arbitrator_test.go @@ -301,7 +301,7 @@ func createTestChannelArbitrator(t *testing.T, log ArbitratorLog) (*chanArbTestC spendChan: make(chan *chainntnfs.SpendDetail), confChan: make(chan *chainntnfs.TxConfirmation), }, - IncubateOutputs: func(wire.OutPoint, *lnwallet.CommitOutputResolution, + IncubateOutputs: func(wire.OutPoint, *lnwallet.OutgoingHtlcResolution, *lnwallet.IncomingHtlcResolution, uint32) error { diff --git a/contractcourt/htlc_success_resolver.go b/contractcourt/htlc_success_resolver.go index 73d370632..c13c52e87 100644 --- a/contractcourt/htlc_success_resolver.go +++ b/contractcourt/htlc_success_resolver.go @@ -211,7 +211,7 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) { h, h.htlc.RHash[:]) err := h.IncubateOutputs( - h.ChanPoint, nil, nil, &h.htlcResolution, + h.ChanPoint, nil, &h.htlcResolution, h.broadcastHeight, ) if err != nil { diff --git a/contractcourt/htlc_timeout_resolver.go b/contractcourt/htlc_timeout_resolver.go index 2469f5318..439babc4e 100644 --- a/contractcourt/htlc_timeout_resolver.go +++ b/contractcourt/htlc_timeout_resolver.go @@ -247,7 +247,7 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) { h.htlcResolution.ClaimOutpoint) err := h.IncubateOutputs( - h.ChanPoint, nil, &h.htlcResolution, nil, + h.ChanPoint, &h.htlcResolution, nil, h.broadcastHeight, ) if err != nil { diff --git a/contractcourt/htlc_timeout_resolver_test.go b/contractcourt/htlc_timeout_resolver_test.go index 981cefc41..1e3daa59c 100644 --- a/contractcourt/htlc_timeout_resolver_test.go +++ b/contractcourt/htlc_timeout_resolver_test.go @@ -216,7 +216,6 @@ func TestHtlcTimeoutResolver(t *testing.T) { Notifier: notifier, PreimageDB: witnessBeacon, IncubateOutputs: func(wire.OutPoint, - *lnwallet.CommitOutputResolution, *lnwallet.OutgoingHtlcResolution, *lnwallet.IncomingHtlcResolution, uint32) error { diff --git a/server.go b/server.go index ccdd13ae0..c4c997f56 100644 --- a/server.go +++ b/server.go @@ -847,7 +847,6 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, return nil }, IncubateOutputs: func(chanPoint wire.OutPoint, - commitRes *lnwallet.CommitOutputResolution, outHtlcRes *lnwallet.OutgoingHtlcResolution, inHtlcRes *lnwallet.IncomingHtlcResolution, broadcastHeight uint32) error { @@ -864,7 +863,7 @@ func newServer(listenAddrs []net.Addr, chanDB *channeldb.DB, } return s.utxoNursery.IncubateOutputs( - chanPoint, commitRes, outRes, inRes, + chanPoint, outRes, inRes, broadcastHeight, ) }, diff --git a/utxonursery.go b/utxonursery.go index b08cf0e2a..2e749130f 100644 --- a/utxonursery.go +++ b/utxonursery.go @@ -330,7 +330,6 @@ func (u *utxoNursery) Stop() error { // they're CLTV absolute time locked, or if they're CSV relative time locked. // Once all outputs reach maturity, they'll be swept back into the wallet. func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint, - commitResolution *lnwallet.CommitOutputResolution, outgoingHtlcs []lnwallet.OutgoingHtlcResolution, incomingHtlcs []lnwallet.IncomingHtlcResolution, broadcastHeight uint32) error { @@ -352,8 +351,6 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint, numHtlcs := len(incomingHtlcs) + len(outgoingHtlcs) var ( - hasCommit bool - // Kid outputs can be swept after an initial confirmation // followed by a maturity period.Baby outputs are two stage and // will need to wait for an absolute time out to reach a @@ -364,28 +361,6 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint, // 1. Build all the spendable outputs that we will try to incubate. - // It could be that our to-self output was below the dust limit. In - // that case the commit resolution would be nil and we would not have - // that output to incubate. - if commitResolution != nil { - hasCommit = true - selfOutput := makeKidOutput( - &commitResolution.SelfOutPoint, - &chanPoint, - commitResolution.MaturityDelay, - input.CommitmentTimeLock, - &commitResolution.SelfOutputSignDesc, - 0, - ) - - // We'll skip any zero valued outputs as this indicates we - // don't have a settled balance within the commitment - // transaction. - if selfOutput.Amount() > 0 { - kidOutputs = append(kidOutputs, selfOutput) - } - } - // TODO(roasbeef): query and see if we already have, if so don't add? // For each incoming HTLC, we'll register a kid output marked as a @@ -436,8 +411,8 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint, // * need ability to cancel in the case that we learn of pre-image or // remote party pulls - utxnLog.Infof("Incubating Channel(%s) has-commit=%v, num-htlcs=%d", - chanPoint, hasCommit, numHtlcs) + utxnLog.Infof("Incubating Channel(%s) num-htlcs=%d", + chanPoint, numHtlcs) u.mu.Lock() defer u.mu.Unlock() @@ -538,8 +513,6 @@ func (u *utxoNursery) NurseryReport( // Preschool outputs are awaiting the // confirmation of the commitment transaction. switch kid.WitnessType() { - case input.CommitmentTimeLock: - report.AddLimboCommitment(&kid) case input.HtlcAcceptedSuccessSecondLevel: // An HTLC output on our commitment transaction @@ -561,11 +534,6 @@ func (u *utxoNursery) NurseryReport( // We can distinguish them via their witness // types. switch kid.WitnessType() { - case input.CommitmentTimeLock: - // The commitment transaction has been - // confirmed, and we are waiting the CSV - // delay to expire. - report.AddLimboCommitment(&kid) case input.HtlcOfferedRemoteTimeout: // This is an HTLC output on the @@ -590,11 +558,6 @@ func (u *utxoNursery) NurseryReport( // will contribute towards the recovered // balance. switch kid.WitnessType() { - case input.CommitmentTimeLock: - // The commitment output was - // successfully swept back into a - // regular p2wkh output. - report.AddRecoveredCommitment(&kid) case input.HtlcAcceptedSuccessSecondLevel: fallthrough @@ -1071,11 +1034,6 @@ type contractMaturityReport struct { // recoveredBalance is the total value that has been successfully swept // back to the user's wallet. recoveredBalance btcutil.Amount - - // maturityHeight is the absolute block height that this output will - // mature at. - maturityHeight uint32 - // htlcs records a maturity report for each htlc output in this channel. htlcs []htlcMaturityReport } @@ -1100,26 +1058,6 @@ type htlcMaturityReport struct { stage uint32 } -// AddLimboCommitment adds an incubating commitment output to maturity -// report's htlcs, and contributes its amount to the limbo balance. -func (c *contractMaturityReport) AddLimboCommitment(kid *kidOutput) { - c.limboBalance += kid.Amount() - - // If the confirmation height is set, then this means the contract has - // been confirmed, and we know the final maturity height. - if kid.ConfHeight() != 0 { - c.maturityHeight = kid.BlocksToMaturity() + kid.ConfHeight() - } -} - -// AddRecoveredCommitment adds a graduated commitment output to maturity -// report's htlcs, and contributes its amount to the recovered balance. -func (c *contractMaturityReport) AddRecoveredCommitment(kid *kidOutput) { - c.recoveredBalance += kid.Amount() - - c.maturityHeight = kid.BlocksToMaturity() + kid.ConfHeight() -} - // AddLimboStage1TimeoutHtlc adds an htlc crib output to the maturity report's // htlcs, and contributes its amount to the limbo balance. func (c *contractMaturityReport) AddLimboStage1TimeoutHtlc(baby *babyOutput) { diff --git a/utxonursery_test.go b/utxonursery_test.go index 6671c0701..6b0d6de00 100644 --- a/utxonursery_test.go +++ b/utxonursery_test.go @@ -650,7 +650,6 @@ func incubateTestOutput(t *testing.T, nursery *utxoNursery, // Hand off to nursery. err := nursery.IncubateOutputs( testChanPoint, - nil, []lnwallet.OutgoingHtlcResolution{*outgoingRes}, nil, 0, ) @@ -839,59 +838,6 @@ func testNurseryOutgoingHtlcSuccessOnRemote(t *testing.T, ctx.finish() } -func TestNurseryCommitSuccessOnLocal(t *testing.T) { - testRestartLoop(t, testNurseryCommitSuccessOnLocal) -} - -func testNurseryCommitSuccessOnLocal(t *testing.T, - checkStartStop func(func()) bool) { - - ctx := createNurseryTestContext(t, checkStartStop) - - commitRes := createCommitmentRes() - - // Hand off to nursery. - err := ctx.nursery.IncubateOutputs( - testChanPoint, - commitRes, nil, nil, 0, - ) - if err != nil { - t.Fatal(err) - } - - // Verify that commitment output is showing up in nursery report as - // limbo balance. - assertNurseryReport(t, ctx.nursery, 0, 0, 10000) - - ctx.restart() - - // Notify confirmation of the commitment tx. - err = ctx.notifier.ConfirmTx(&commitRes.SelfOutPoint.Hash, 124) - if err != nil { - t.Fatal(err) - } - - // Wait for output to be promoted from PSCL to KNDR. - select { - case <-ctx.store.preschoolToKinderChan: - case <-time.After(defaultTestTimeout): - t.Fatalf("output not promoted to KNDR") - } - - ctx.restart() - - // Notify arrival of block where commit output CSV expires. - ctx.notifyEpoch(126) - - // Check final sweep into wallet. - testSweep(t, ctx, func() { - // Check limbo balance after sweep publication - assertNurseryReport(t, ctx.nursery, 0, 0, 10000) - }) - - ctx.finish() -} - func testSweepHtlc(t *testing.T, ctx *nurseryTestContext) { testSweep(t, ctx, func() { // Verify stage in nursery report. HTLCs should now both still