diff --git a/sweepbatcher/log.go b/sweepbatcher/log.go index 20a31361..24d6cc29 100644 --- a/sweepbatcher/log.go +++ b/sweepbatcher/log.go @@ -17,7 +17,8 @@ func init() { UseLogger(build.NewSubLogger("SWEEP", nil)) } -// batchPrefixLogger returns a logger that prefixes all log messages with the ID. +// batchPrefixLogger returns a logger that prefixes all log messages with +// the ID. func batchPrefixLogger(batchID string) btclog.Logger { return build.NewPrefixLog(fmt.Sprintf("[Batch %s]", batchID), log) } diff --git a/sweepbatcher/store.go b/sweepbatcher/store.go index 81f47b4c..aff5ff51 100644 --- a/sweepbatcher/store.go +++ b/sweepbatcher/store.go @@ -82,8 +82,8 @@ func NewSQLStore(db BaseDB, network *chaincfg.Params) *SQLStore { // FetchUnconfirmedSweepBatches fetches all the batches from the database that // are not in a confirmed state. -func (s *SQLStore) FetchUnconfirmedSweepBatches(ctx context.Context) ([]*dbBatch, - error) { +func (s *SQLStore) FetchUnconfirmedSweepBatches(ctx context.Context) ( + []*dbBatch, error) { var batches []*dbBatch diff --git a/sweepbatcher/sweep_batch.go b/sweepbatcher/sweep_batch.go index a784871b..0aa5b4c3 100644 --- a/sweepbatcher/sweep_batch.go +++ b/sweepbatcher/sweep_batch.go @@ -592,9 +592,11 @@ func (b *batch) publishBatch(ctx context.Context) (btcutil.Amount, error) { batchTx.LockTime = uint32(b.currentHeight) var ( - batchAmt btcutil.Amount - prevOuts = make([]*wire.TxOut, 0, len(b.sweeps)) - signDescs = make([]*lndclient.SignDescriptor, 0, len(b.sweeps)) + batchAmt btcutil.Amount + prevOuts = make([]*wire.TxOut, 0, len(b.sweeps)) + signDescs = make( + []*lndclient.SignDescriptor, 0, len(b.sweeps), + ) sweeps = make([]sweep, 0, len(b.sweeps)) fee btcutil.Amount inputCounter int diff --git a/sweepbatcher/sweep_batcher.go b/sweepbatcher/sweep_batcher.go index 9f78734b..bc69d421 100644 --- a/sweepbatcher/sweep_batcher.go +++ b/sweepbatcher/sweep_batcher.go @@ -328,8 +328,8 @@ func (b *Batcher) handleSweep(ctx context.Context, sweep *sweep, if !accepted { return fmt.Errorf("existing sweep %x was not "+ - "accepted by batch %d", sweep.swapHash[:6], - batch.id) + "accepted by batch %d", + sweep.swapHash[:6], batch.id) } // The sweep was updated in the batch, our job is done. @@ -464,6 +464,8 @@ func (b *Batcher) spinUpBatchFromDB(ctx context.Context, batch *batch) error { FeeRate: batch.rbfCache.FeeRate, } + logger := batchPrefixLogger(fmt.Sprintf("%d", batch.id)) + batchKit := batchKit{ id: batch.id, batchTxid: batch.batchTxid, @@ -480,7 +482,7 @@ func (b *Batcher) spinUpBatchFromDB(ctx context.Context, batch *batch) error { verifySchnorrSig: b.VerifySchnorrSig, purger: b.AddSweep, store: b.store, - log: batchPrefixLogger(fmt.Sprintf("%d", batch.id)), + log: logger, quit: b.quit, } @@ -601,15 +603,17 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep, totalSwept, ) + onChainFeePortion := getFeePortionPaidBySweep( + spendTx, feePortionPerSweep, + roundingDifference, sweep, + ) + // Notify the requester of the spend // with the spend details, including the fee // portion for this particular sweep. spendDetail := &SpendDetail{ - Tx: spendTx, - OnChainFeePortion: getFeePortionPaidBySweep( // nolint:lll - spendTx, feePortionPerSweep, - roundingDifference, sweep, - ), + Tx: spendTx, + OnChainFeePortion: onChainFeePortion, } select { diff --git a/sweepbatcher/sweep_batcher_test.go b/sweepbatcher/sweep_batcher_test.go index 74408cfe..afa7ab97 100644 --- a/sweepbatcher/sweep_batcher_test.go +++ b/sweepbatcher/sweep_batcher_test.go @@ -182,7 +182,8 @@ func TestSweepBatcherBatchCreation(t *testing.T) { <-lnd.RegisterSpendChannel require.Eventually(t, func() bool { - // Verify that each batch has the correct number of sweeps in it. + // Verify that each batch has the correct number of sweeps + // in it. for _, batch := range batcher.batches { switch batch.primarySweepID { case sweepReq1.SwapHash: @@ -481,7 +482,9 @@ func TestSweepBatcherSweepReentry(t *testing.T) { }, TxOut: []*wire.TxOut{ { - Value: int64(sweepReq1.Value.ToUnit(btcutil.AmountSatoshi)), + Value: int64(sweepReq1.Value.ToUnit( + btcutil.AmountSatoshi, + )), PkScript: []byte{3, 2, 1}, }, }, @@ -683,7 +686,8 @@ func TestSweepBatcherNonWalletAddr(t *testing.T) { <-lnd.RegisterSpendChannel require.Eventually(t, func() bool { - // Verify that each batch has the correct number of sweeps in it. + // Verify that each batch has the correct number of sweeps + // in it. for _, batch := range batcher.batches { switch batch.primarySweepID { case sweepReq1.SwapHash: