multi: formatting and comment fixes

This commit is contained in:
Oliver Gugger committed 2022-02-10 11:02:02 +01:00
1 parent ffee7d1bcf
commit 895a2e497b
160 files changed
+159 -260

No files matched your search

-1
View File
@@ -125,7 +125,6 @@ func (c *anchorResolver) Resolve() (ContractResolver, error) {
select {
case sweepRes := <-resultChan:
switch sweepRes.Err {
// Anchor was swept successfully.
case nil:
sweepTxID := sweepRes.Tx.TxHash()
+2 -3
View File
@@ -532,7 +532,7 @@ func (b *BreachArbiter) waitForSpendEvent(breachInfo *retributionInfo,
// spends it to the second level, and mutates the breach output into one that
// is able to properly sweep that second level output. We'll use this function
// when we go to sweep a breached commitment transaction, but the cheating
// party has already attempted to take it to the second level
// party has already attempted to take it to the second level.
func convertToSecondLevelRevoke(bo *breachedOutput, breachInfo *retributionInfo,
spendDetails *chainntnfs.SpendDetail) {
@@ -625,7 +625,6 @@ func updateBreachInfo(breachInfo *retributionInfo, spends []spend) (
// count the total and revoked funds swept depending on the
// input type.
switch breachedOutput.witnessType {
// If the output being revoked is the remote commitment
// output or an offered HTLC output, it's amount
// contributes to the value of funds being revoked from
@@ -758,7 +757,6 @@ justiceTxBroadcast:
Loop:
for {
select {
case spends := <-spendChan:
// Update the breach info with the new spends.
@@ -1333,6 +1331,7 @@ func (b *BreachArbiter) createJusticeTx(
// createSweepTx creates a tx that sweeps the passed inputs back to our wallet.
func (b *BreachArbiter) createSweepTx(inputs []input.Input) (*wire.MsgTx,
error) {
if len(inputs) == 0 {
return nil, nil
}
-2
View File
@@ -1949,7 +1949,6 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
maxIndex = uint32(len(forceCloseTx.TxOut)) - 1
)
for i := 0; i < 2; i++ {
var tx *wire.MsgTx
select {
case tx = <-publTx:
@@ -1989,7 +1988,6 @@ func TestBreachDelayedJusticeConfirmation(t *testing.T) {
}
select {
// The published tx should spend the same inputs as our second split.
case tx := <-publTx:
require.Len(t, tx.TxIn, len(splits[1].TxIn))
+1 -1
View File
@@ -181,7 +181,7 @@ const (
// | |
// | |-> StateFullyResolved: contract resolutions empty
// |
// |-> StateFullyResolved: coop/breach(legacy) close trigger
// |-> StateFullyResolved: coop/breach(legacy) close trigger.
// StateDefault is the default state. In this state, no major actions
// need to be executed.
-2
View File
@@ -429,7 +429,6 @@ func (c *ChainArbitrator) getArbChannel(
// This is only to be done once all contracts which were live on the channel
// before hitting the chain have been resolved.
func (c *ChainArbitrator) ResolveContract(chanPoint wire.OutPoint) error {
log.Infof("Marking ChannelPoint(%v) fully resolved", chanPoint)
// First, we'll we'll mark the channel as fully closed from the PoV of
@@ -874,7 +873,6 @@ func (c *ChainArbitrator) rebroadcast(channel *channeldb.OpenChannel,
}
switch {
// This can happen for channels that had their closing tx published
// before we started storing it to disk.
case err == channeldb.ErrNoCloseTx:
-2
View File
@@ -787,7 +787,6 @@ func (c *chainWatcher) handleKnownRemoteState(
)
switch {
// If we had no log entry at this height, this was not a revoked state.
case err == channeldb.ErrLogEntryNotFound:
return false, nil
@@ -869,7 +868,6 @@ func (c *chainWatcher) handleUnknownRemoteState(
"sweep our funds...",
commitPoint.SerializeCompressed(),
c.cfg.chanState.FundingOutpoint)
} else {
log.Infof("ChannelPoint(%v) is tweakless, "+
"moving to sweep directly on chain",
+2 -4
View File
@@ -1548,7 +1548,6 @@ func TestChannelArbitratorForceCloseBreachedChannel(t *testing.T) {
// TestChannelArbitratorCommitFailure tests that the channel arbitrator is able
// to recover from a failed CommitState call at restart.
func TestChannelArbitratorCommitFailure(t *testing.T) {
testCases := []struct {
// closeType is the type of channel close we want ot test.
@@ -2221,6 +2220,7 @@ func TestRemoteCloseInitiator(t *testing.T) {
if !alice.State().HasChanStatus(
channeldb.ChanStatusRemoteCloseInitiator,
) {
t.Fatalf("expected remote close initiator, "+
"got: %v", alice.State().ChanStatus())
}
@@ -2350,7 +2350,6 @@ func TestFindCommitmentDeadline(t *testing.T) {
require.Equal(t, tc.deadline, deadline)
})
}
}
// TestSweepAnchors checks the sweep transactions are created using the
@@ -2473,7 +2472,6 @@ func TestSweepAnchors(t *testing.T) {
t, expectedRemoteDeadline, deadlines[2],
"remote deadline not matched",
)
}
// TestChannelArbitratorAnchors asserts that the commitment tx anchor is swept.
@@ -2702,7 +2700,6 @@ func TestChannelArbitratorAnchors(t *testing.T) {
htlcWithPreimage.RefundTimeout-heightHint,
chanArbCtx.sweeper.deadlines[1],
)
}
// putResolverReportInChannel returns a put report function which will pipe
@@ -2738,6 +2735,7 @@ type mockChannel struct {
func (m *mockChannel) NewAnchorResolutions() (*lnwallet.AnchorResolutions,
error) {
if m.anchorResolutions != nil {
return m.anchorResolutions, nil
}
-1
View File
@@ -262,7 +262,6 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) {
// commitment this is.
var witnessType input.WitnessType
switch {
// Delayed output to us on our local commitment for a channel lease in
// which we are the initiator.
case isLocalCommitTx && c.hasCLTV():
@@ -347,7 +347,6 @@ func testCommitSweepResolverDelay(t *testing.T, sweepErr error) {
t.Fatalf("unexpected resolver report. want=%v got=%v",
expectedReport, report)
}
}
// TestCommitSweepResolverDelay tests resolution of a direct commitment output
@@ -180,7 +180,6 @@ func (h *htlcIncomingContestResolver) Resolve() (ContractResolver, error) {
// Take action based on the type of resolution we have
// received.
switch resolution := e.(type) {
// If the htlc resolution was a settle, apply the
// preimage and return a success resolver.
case *invoices.HtlcSettleResolution:
@@ -442,7 +441,6 @@ func (h *htlcIncomingContestResolver) SupplementState(_ *channeldb.OpenChannel)
// decodePayload (re)decodes the hop payload of a received htlc.
func (h *htlcIncomingContestResolver) decodePayload() (*hop.Payload, error) {
onionReader := bytes.NewReader(h.htlc.OnionBlob)
iterator, err := h.OnionProcessor.ReconstructHopIterator(
onionReader, h.htlc.RHash[:],
@@ -140,6 +140,7 @@ func TestHtlcIncomingResolverExitSettle(t *testing.T) {
if !bytes.Equal(
ctx.onionProcessor.offeredOnionBlob, testOnionBlob,
) {
t.Fatal("unexpected onion blob")
}
}
@@ -389,7 +389,6 @@ func TestHtlcSuccessSecondStageResolutionSweeper(t *testing.T) {
SpendingHeight: 10,
}
return nil
},
// incubating=true is used to signal that the
// second-level transaction was confirmed.
@@ -555,7 +554,6 @@ func runFromCheckpoint(t *testing.T, ctx *htlcResolverTestContext,
t.Fatalf("expected checkpoint to be have "+
"incubating=%v, had %v", cp.incubating,
incubating)
}
// Check we go the expected reports.
@@ -595,7 +593,6 @@ func runFromCheckpoint(t *testing.T, ctx *htlcResolverTestContext,
if err := cp.preCheckpoint(ctx, resumed); err != nil {
t.Fatalf("failure at stage %d: %v", i, err)
}
}
resumed = false
-2
View File
@@ -329,7 +329,6 @@ func (h *htlcTimeoutResolver) Resolve() (ContractResolver, error) {
// transaction.
func (h *htlcTimeoutResolver) spendHtlcOutput() (*chainntnfs.SpendDetail, error) {
switch {
// If we have non-nil SignDetails, this means that have a 2nd level
// HTLC transaction that is signed using sighash SINGLE|ANYONECANPAY
// (the case for anchor type channels). In this case we can re-sign it
@@ -441,7 +440,6 @@ func (h *htlcTimeoutResolver) handleCommitSpend(
)
switch {
// If the sweeper is handling the second level transaction, wait for
// the CSV and possible CLTV lock to expire, before sweeping the output
// on the second-level.
@@ -138,6 +138,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
templateTx.TxIn[0].Witness = witness
@@ -169,6 +170,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
@@ -206,6 +208,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
@@ -239,6 +242,7 @@ func TestHtlcTimeoutResolver(t *testing.T) {
if reflect.DeepEqual(
templateTx.TxIn[0].Witness, witness,
) {
return templateTx, nil
}
-3
View File
@@ -291,7 +291,6 @@ func (ns *NurseryStore) Incubate(kids []kidOutput, babies []babyOutput) error {
// will be stored as it waits out the kidOutput's CSV delay.
func (ns *NurseryStore) CribToKinder(bby *babyOutput) error {
return kvdb.Update(ns.db, func(tx kvdb.RwTx) error {
// First, retrieve or create the channel bucket corresponding to
// the baby output's origin channel point.
chanPoint := bby.OriginChanPoint()
@@ -472,7 +471,6 @@ func (ns *NurseryStore) PreschoolToKinder(kid *kidOutput,
// pruned from the height index as outputs are removed.
func (ns *NurseryStore) GraduateKinder(height uint32, kid *kidOutput) error {
return kvdb.Update(ns.db, func(tx kvdb.RwTx) error {
hghtBucket := ns.getHeightBucket(tx, height)
if hghtBucket == nil {
// Nothing to delete, bucket has already been removed.
@@ -597,7 +595,6 @@ func (ns *NurseryStore) FetchClass(
func (ns *NurseryStore) FetchPreschools() ([]kidOutput, error) { // nolint:golint
var kids []kidOutput
if err := kvdb.View(ns.db, func(tx kvdb.RTx) error {
// Retrieve the existing chain bucket for this nursery store.
chainBucket := tx.ReadBucket(ns.pfxChainKey)
if chainBucket == nil {
+3 -2
View File
@@ -884,7 +884,8 @@ func (u *UtxoNursery) sweepCribOutput(classHeight uint32, baby *babyOutput) erro
// notification for an htlc timeout transaction. If successful, a goroutine
// will be spawned that will transition the provided baby output into the
// kindergarten state within the nursery store.
func (u *UtxoNursery) registerTimeoutConf(baby *babyOutput, heightHint uint32) error {
func (u *UtxoNursery) registerTimeoutConf(baby *babyOutput,
heightHint uint32) error {
birthTxID := baby.timeoutTx.TxHash()
@@ -1052,7 +1053,7 @@ type ContractMaturityReport struct {
}
// HtlcMaturityReport provides a summary of a single htlc output, and is
// embedded as party of the overarching ContractMaturityReport
// embedded as party of the overarching ContractMaturityReport.
type HtlcMaturityReport struct {
// Outpoint is the final output that will be swept back to the wallet.
Outpoint wire.OutPoint