diff --git a/fsm/fsm.go b/fsm/fsm.go index abc0d729..6990b750 100644 --- a/fsm/fsm.go +++ b/fsm/fsm.go @@ -7,14 +7,22 @@ import ( "sync" ) -// ErrEventRejected is the error returned when the state machine cannot process -// an event in the state that it is in. var ( - ErrEventRejected = errors.New("event rejected") + // ErrEventRejected is the error returned when the state machine cannot + // process an event in the state that it is in. + ErrEventRejected = errors.New("event rejected") + + // ErrWaitForStateTimedOut is returned when waiting for state times out. ErrWaitForStateTimedOut = errors.New( "timed out while waiting for event", ) - ErrInvalidContextType = errors.New("invalid context") + + // ErrInvalidContextType is returned when an invalid context type is + // passed. + ErrInvalidContextType = errors.New("invalid context") + + // ErrWaitingForStateEarlyAbortError is returned when waiting for state + // is aborted early. ErrWaitingForStateEarlyAbortError = errors.New( "waiting for state early abort", ) @@ -91,7 +99,7 @@ type Observer interface { // StateMachine represents the state machine. type StateMachine struct { - // Context represents the state machine context. + // States represents the state machine states. States States // ActionEntryFunc is a function that is called before an action is diff --git a/instantout/instantout.go b/instantout/instantout.go index cfea1e60..b703b4de 100644 --- a/instantout/instantout.go +++ b/instantout/instantout.go @@ -122,7 +122,7 @@ func (i *InstantOut) createMusig2Session(ctx context.Context, return musig2Sessions, clientNonces, nil } -// getInputReservation returns the input reservation for the instant out. +// getInputReservations returns the input reservations for the instant out. func (i *InstantOut) getInputReservations() (InputReservations, error) { if len(i.Reservations) == 0 { return nil, errors.New("no reservations") diff --git a/instantout/reservation/actions_test.go b/instantout/reservation/actions_test.go index 4f63f4b1..40e6509b 100644 --- a/instantout/reservation/actions_test.go +++ b/instantout/reservation/actions_test.go @@ -313,7 +313,8 @@ func TestSubscribeToConfirmationAction(t *testing.T) { } } -// AsyncWaitForExpiredOrSweptAction tests the AsyncWaitForExpiredOrSweptAction +// TestAsyncWaitForExpiredOrSweptAction tests the +// AsyncWaitForExpiredOrSweptAction // of the reservation state machine. func TestAsyncWaitForExpiredOrSweptAction(t *testing.T) { tests := []struct { @@ -375,7 +376,7 @@ func TestAsyncWaitForExpiredOrSweptAction(t *testing.T) { } } -// TesthandleSubcriptions tests the handleSubcriptions function of the +// TestHandleSubcriptions tests the handleSubcriptions function of the // reservation state machine. func TestHandleSubcriptions(t *testing.T) { var ( diff --git a/interface.go b/interface.go index 67b9f831..10a86bfa 100644 --- a/interface.go +++ b/interface.go @@ -18,7 +18,7 @@ type OutRequest struct { // include the swap and miner fee. Amount btcutil.Amount - // Destination address for the swap. + // DestAddr is the destination address for the swap. DestAddr btcutil.Address // IsExternalAddr indicates whether the provided destination address @@ -428,8 +428,8 @@ type LoopInQuote struct { // sweep the htlc. MinerFee btcutil.Amount - // Time lock delta relative to current block height that swap server - // will accept on the swap initiation call. + // CltvDelta is the time lock delta relative to current block height + // that the swap server will accept on the swap initiation call. CltvDelta int32 } @@ -533,7 +533,7 @@ type ProbeRequest struct { // LastHop is the last hop along the route. LastHop *route.Vertex - // Optional hop hints. + // RouteHints are optional hop hints. RouteHints [][]zpay32.HopHint } diff --git a/liquidity/fees.go b/liquidity/fees.go index 939f0ee9..dbc92acd 100644 --- a/liquidity/fees.go +++ b/liquidity/fees.go @@ -19,8 +19,8 @@ const ( // 1%. defaultRoutingFeePPM = 10000 - // defaultRoutingFeePPM is the default limit we place on routing fees - // for the prepay invoice, expressed as parts per million of prepay + // defaultPrepayRoutingFeePPM is the default limit we place on routing + // fees for the prepay invoice, expressed as parts per million of prepay // volume, 0.5%. defaultPrepayRoutingFeePPM = 5000 diff --git a/liquidity/liquidity.go b/liquidity/liquidity.go index ca210c3d..6858b4c4 100644 --- a/liquidity/liquidity.go +++ b/liquidity/liquidity.go @@ -369,7 +369,7 @@ func (m *Manager) SetParameters(ctx context.Context, return m.saveParams(ctx, req) } -// SetParameters updates our current set of parameters if the new parameters +// setParameters updates our current set of parameters if the new parameters // provided are valid. func (m *Manager) setParameters(ctx context.Context, params Parameters) error { diff --git a/liquidity/parameters.go b/liquidity/parameters.go index 901959c8..7032ff83 100644 --- a/liquidity/parameters.go +++ b/liquidity/parameters.go @@ -409,7 +409,7 @@ func rpcToRule(rule *clientrpc.LiquidityRule) (*SwapRule, error) { } } -// rpcToParameters takes a `LiquidityParameters` and creates a `Parameters` +// RpcToParameters takes a `LiquidityParameters` and creates a `Parameters` // from it. func RpcToParameters(req *clientrpc.LiquidityParameters) (*Parameters, error) { diff --git a/loopd/swapclient_server.go b/loopd/swapclient_server.go index 2cc4f5c6..1345a0b8 100644 --- a/loopd/swapclient_server.go +++ b/loopd/swapclient_server.go @@ -2753,7 +2753,7 @@ func toClientReservation( } } -// marshalFixedpoint marshals a fixed point from the tap rfqmath package to the +// marshalFixedPoint marshals a fixed point from the tap rfqmath package to the // looprpc package. func marshalFixedPoint(bigIntFixedPoint *rfqmath.BigIntFixedPoint, ) *looprpc.FixedPoint { diff --git a/loopdb/loopin.go b/loopdb/loopin.go index 8801b1b4..0982fff0 100644 --- a/loopdb/loopin.go +++ b/loopdb/loopin.go @@ -16,7 +16,7 @@ import ( type LoopInContract struct { SwapContract - // SweepConfTarget specifies the targeted confirmation target for the + // HtlcConfTarget specifies the targeted confirmation target for the // client sweep tx. HtlcConfTarget int32 diff --git a/loopdb/meta.go b/loopdb/meta.go index d445a021..81795769 100644 --- a/loopdb/meta.go +++ b/loopdb/meta.go @@ -9,7 +9,7 @@ import ( ) var ( - // metaBucket stores all the meta information concerning the state of + // metaBucketKey stores all the meta information concerning the state of // the database. metaBucketKey = []byte("metadata") diff --git a/loopdb/protocol_version.go b/loopdb/protocol_version.go index 23262fb0..4674f6c7 100644 --- a/loopdb/protocol_version.go +++ b/loopdb/protocol_version.go @@ -43,7 +43,7 @@ const ( // canceling loop out swaps. ProtocolVersionLoopOutCancel = 7 - // ProtocolVerionProbe indicates that the client is able to request + // ProtocolVersionProbe indicates that the client is able to request // the server to perform a probe to test inbound liquidty. ProtocolVersionProbe ProtocolVersion = 8 diff --git a/loopdb/store.go b/loopdb/store.go index fe9cc267..fe71c19c 100644 --- a/loopdb/store.go +++ b/loopdb/store.go @@ -98,7 +98,7 @@ var ( // value: uint32 confirmation value confirmationsKey = []byte("confirmations") - // liquidtyBucket is a root bucket used to save liquidity manager + // liquidityBucket is a root bucket used to save liquidity manager // related info. liquidityBucket = []byte("liquidity") diff --git a/loopdb/store_mock.go b/loopdb/store_mock.go index 0f3dcc66..93dab268 100644 --- a/loopdb/store_mock.go +++ b/loopdb/store_mock.go @@ -80,7 +80,7 @@ func (s *StoreMock) FetchLoopOutSwaps(ctx context.Context) ([]*LoopOut, error) { return result, nil } -// FetchLoopOutSwaps returns all swaps currently in the store. +// FetchLoopOutSwap returns a swap currently in the store. // // NOTE: Part of the SwapStore interface. func (s *StoreMock) FetchLoopOutSwap(ctx context.Context, @@ -261,7 +261,7 @@ func (s *StoreMock) Close() error { return nil } -// isDone asserts that the store mock has no pending operations. +// IsDone asserts that the store mock has no pending operations. func (s *StoreMock) IsDone() error { select { case <-s.loopOutStoreChan: @@ -312,7 +312,7 @@ func (s *StoreMock) AssertLoopInStored() { } } -// assertLoopInState asserts that a specified state transition is persisted to +// AssertLoopInState asserts that a specified state transition is persisted to // disk. func (s *StoreMock) AssertLoopInState( expectedState SwapState) SwapStateData { diff --git a/loopdb/store_test.go b/loopdb/store_test.go index fc78a987..c0252674 100644 --- a/loopdb/store_test.go +++ b/loopdb/store_test.go @@ -387,8 +387,8 @@ func TestVersionNew(t *testing.T) { } } -// TestVersionNew tests that an existing version zero database is migrated to -// the latest version. +// TestVersionMigrated tests that an existing version zero database is migrated +// to the latest version. func TestVersionMigrated(t *testing.T) { tempDirName, err := ioutil.TempDir("", "clientstore") if err != nil { diff --git a/loopdb/swapstate.go b/loopdb/swapstate.go index fe029f2d..fb9f910d 100644 --- a/loopdb/swapstate.go +++ b/loopdb/swapstate.go @@ -172,7 +172,7 @@ func (s SwapState) String() string { // SwapCost is a breakdown of the final swap costs. type SwapCost struct { - // Swap is the amount paid to the server. + // Server is the amount paid to the server. Server btcutil.Amount // Onchain is the amount paid to miners for the onchain tx. @@ -189,7 +189,7 @@ func (s SwapCost) Total() btcutil.Amount { // SwapStateData is all persistent data to describe the current swap state. type SwapStateData struct { - // SwapState is the state the swap is in. + // State is the state the swap is in. State SwapState // Cost are the accrued (final) costs so far. diff --git a/loopout_test.go b/loopout_test.go index b367911e..1b3c6b32 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -40,7 +40,7 @@ func TestLoopOutPaymentParameters(t *testing.T) { }) } -// TestLoopOutPaymentParameters tests the first part of the loop out process up +// testLoopOutPaymentParameters tests the first part of the loop out process up // to the point where the off-chain payments are made. func testLoopOutPaymentParameters(t *testing.T) { defer test.Guard(t)() diff --git a/staticaddr/address/interface.go b/staticaddr/address/interface.go index 54d785de..14cae7fe 100644 --- a/staticaddr/address/interface.go +++ b/staticaddr/address/interface.go @@ -33,7 +33,7 @@ type Parameters struct { // timeout path. ClientPubkey *btcec.PublicKey - // ClientPubkey is the client's pubkey for the static address. It is + // ServerPubkey is the server's pubkey for the static address. It is // used for the 2-of-2 funding output. ServerPubkey *btcec.PublicKey diff --git a/staticaddr/loopin/loopin.go b/staticaddr/loopin/loopin.go index 78ed2d2f..e6194f5f 100644 --- a/staticaddr/loopin/loopin.go +++ b/staticaddr/loopin/loopin.go @@ -124,8 +124,8 @@ type StaticAddressLoopIn struct { // probing and payment. Private bool - // Optional route hints to reach the destination through private - // channels. + // RouteHints are optional route hints to reach the destination through + // private channels. RouteHints [][]zpay32.HopHint // Deposits are the deposits that are part of the loop-in swap. They diff --git a/staticaddr/loopin/manager.go b/staticaddr/loopin/manager.go index f2a07568..e5191441 100644 --- a/staticaddr/loopin/manager.go +++ b/staticaddr/loopin/manager.go @@ -60,10 +60,10 @@ type Config struct { // cancel invoices. InvoicesClient lndclient.InvoicesClient - // SwapClient is used to get loop in quotes. + // QuoteGetter is used to get loop-in quotes. QuoteGetter QuoteGetter - // NodePubKey is used to get a loo-in quote. + // NodePubkey is used to get a loop-in quote. NodePubkey route.Vertex // WalletKit is the wallet client that is used to derive new keys from @@ -74,7 +74,7 @@ type Config struct { // manager uses. ChainParams *chaincfg.Params - // Chain is the chain notifier that is used to listen for new + // ChainNotifier is the chain notifier that is used to listen for new // blocks. ChainNotifier lndclient.ChainNotifierClient diff --git a/staticaddr/openchannel/manager.go b/staticaddr/openchannel/manager.go index 34735128..a9d4255f 100644 --- a/staticaddr/openchannel/manager.go +++ b/staticaddr/openchannel/manager.go @@ -31,7 +31,8 @@ const ( // channel opening. defaultUtxoMinConf = 1 - // Is the default confirmation target for a channel open transaction. + // defaultConfTarget is the default confirmation target for a channel + // open transaction. defaultConfTarget int32 = 3 ) @@ -47,8 +48,8 @@ var ( // Config is the configuration struct for the open channel manager. type Config struct { - // StaticAddressServerClient is the client that calls the swap server - // rpcs to negotiate static address withdrawals. + // Server is the client that calls the swap server rpcs to negotiate + // static address withdrawals. Server serverrpc.StaticAddressServerClient // AddressManager gives the withdrawal manager access to static address @@ -91,7 +92,7 @@ type newOpenChannelResponse struct { // ChanOutpoint is the outpoint of the channel open transaction. ChanOutpoint *wire.OutPoint - // Err is the error that occurred during the channel open process. + // err is the error that occurred during the channel open process. err error } diff --git a/staticaddr/withdraw/manager.go b/staticaddr/withdraw/manager.go index 2dc27b28..c5b36430 100644 --- a/staticaddr/withdraw/manager.go +++ b/staticaddr/withdraw/manager.go @@ -135,8 +135,8 @@ type Manager struct { // initiationHeight stores the currently best known block height. initiationHeight atomic.Uint32 - // finalizedWithdrawalTx are the finalized withdrawal transactions that - // are published to the network and re-published on block arrivals. + // finalizedWithdrawalTxns are the finalized withdrawal transactions + // that are published to the network and re-published on block arrivals. finalizedWithdrawalTxns map[chainhash.Hash]*wire.MsgTx } diff --git a/swap.go b/swap.go index 94de7d10..204dd461 100644 --- a/swap.go +++ b/swap.go @@ -50,10 +50,12 @@ func newSwapKit(hash lntypes.Hash, swapType swap.Type, cfg *swapConfig, } } -// IsTaproot returns true if the swap referenced by the passed swap contract +// IsTaprootSwap returns true if the swap referenced by the passed swap contract // uses the v3 (taproot) htlc. func IsTaprootSwap(swapContract *loopdb.SwapContract) bool { - return utils.GetHtlcScriptVersion(swapContract.ProtocolVersion) == swap.HtlcV3 + version := utils.GetHtlcScriptVersion(swapContract.ProtocolVersion) + + return version == swap.HtlcV3 } // swapInfo constructs and returns a filled SwapInfo from diff --git a/swap/htlc.go b/swap/htlc.go index e3899141..2e87d8ae 100644 --- a/swap/htlc.go +++ b/swap/htlc.go @@ -477,7 +477,7 @@ func (h *HtlcScriptV2) SuccessSequence() uint32 { return 1 } -// Sighash is the signature hash to use for transactions spending from the htlc. +// SigHash is the signature hash to use for transactions spending from the htlc. func (h *HtlcScriptV2) SigHash() txscript.SigHashType { return txscript.SigHashAll } @@ -785,7 +785,7 @@ func (h *HtlcScriptV3) SuccessSequence() uint32 { return 1 } -// Sighash is the signature hash to use for transactions spending from the htlc. +// SigHash is the signature hash to use for transactions spending from the htlc. func (h *HtlcScriptV3) SigHash() txscript.SigHashType { return txscript.SigHashDefault } diff --git a/swap_server_client.go b/swap_server_client.go index 07ad57d3..310b17ee 100644 --- a/swap_server_client.go +++ b/swap_server_client.go @@ -658,7 +658,7 @@ type routeCancelMetadata struct { // outCancelDetails contains the information required to cancel a loop out swap. type outCancelDetails struct { - // Hash is the swap's hash. + // hash is the swap's hash. hash lntypes.Hash // paymentAddr is the payment address for the swap's invoice. diff --git a/sweepbatcher/sweep_batcher.go b/sweepbatcher/sweep_batcher.go index 51b707ba..85a0c272 100644 --- a/sweepbatcher/sweep_batcher.go +++ b/sweepbatcher/sweep_batcher.go @@ -277,7 +277,7 @@ type addSweepsRequest struct { // source. sweeps []*sweep - // Notifier is a notifier that is used to notify the requester of this + // notifier is a notifier that is used to notify the requester of this // sweep that the sweep was successful. notifier *SpendNotifier diff --git a/utils.go b/utils.go index 54edf4a5..32863431 100644 --- a/utils.go +++ b/utils.go @@ -368,9 +368,9 @@ func sufficientHints(numHints, maxHints, scalingFactor int, amount, return false } -// SelectHopHints will select up to numMaxHophints from the set of passed open -// channels. The set of hop hints will be returned as a slice of functional -// options that'll append the route hint to the set of all route hints. +// invoicesrpcSelectHopHints will select up to numMaxHophints from the set of +// passed open channels. The set of hop hints will be returned as a slice of +// functional options that'll append the route hint to the set of all hints. // // TODO(sputn1ck): remove when https://github.com/lightningnetwork/lnd/pull/7065 // is merged to a new lnd release.