mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
multi: make linter happy
Fix all the linter problems for the `v0.16.0-beta.rc3`.
This commit is contained in:
parent
840c939464
commit
4a0a15586b
@ -652,7 +652,9 @@ type walletReBroadcaster struct {
|
||||
}
|
||||
|
||||
// newWalletReBroadcaster creates a new instance of the walletReBroadcaster.
|
||||
func newWalletReBroadcaster(broadcaster *pushtx.Broadcaster) *walletReBroadcaster {
|
||||
func newWalletReBroadcaster(
|
||||
broadcaster *pushtx.Broadcaster) *walletReBroadcaster {
|
||||
|
||||
return &walletReBroadcaster{
|
||||
Broadcaster: broadcaster,
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// RecvOrTimeout attempts to recv over chan c, returning the value. If the
|
||||
// timeout passes before the recv succeeds, an error is returned
|
||||
// timeout passes before the recv succeeds, an error is returned.
|
||||
func RecvOrTimeout[T any](c <-chan T, timeout time.Duration) (*T, error) {
|
||||
select {
|
||||
case m := <-c:
|
||||
|
@ -21,7 +21,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
CoinPkScript, _ = hex.DecodeString("001431df1bde03c074d0cf21ea2529427e1499b8f1de")
|
||||
CoinPkScript, _ = hex.DecodeString(
|
||||
"001431df1bde03c074d0cf21ea2529427e1499b8f1de",
|
||||
)
|
||||
)
|
||||
|
||||
// mockWalletController is a mock implementation of the WalletController
|
||||
@ -50,6 +52,7 @@ func (w *mockWalletController) FetchInputInfo(
|
||||
Confirmations: 1,
|
||||
OutPoint: *prevOut,
|
||||
}
|
||||
|
||||
return utxo, nil
|
||||
}
|
||||
|
||||
@ -74,8 +77,10 @@ func (w *mockWalletController) NewAddress(AddressType, bool,
|
||||
string) (btcutil.Address, error) {
|
||||
|
||||
addr, _ := btcutil.NewAddressPubKey(
|
||||
w.RootKey.PubKey().SerializeCompressed(), &chaincfg.MainNetParams,
|
||||
w.RootKey.PubKey().SerializeCompressed(),
|
||||
&chaincfg.MainNetParams,
|
||||
)
|
||||
|
||||
return addr, nil
|
||||
}
|
||||
|
||||
@ -176,6 +181,7 @@ func (w *mockWalletController) ListUnspentWitness(int32, int32,
|
||||
atomic.AddUint32(&w.index, 1)
|
||||
var ret []*Utxo
|
||||
ret = append(ret, utxo)
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
@ -200,19 +206,21 @@ func (w *mockWalletController) LeaseOutput(wtxmgr.LockID, wire.OutPoint,
|
||||
}
|
||||
|
||||
// ReleaseOutput currently does nothing.
|
||||
func (w *mockWalletController) ReleaseOutput(wtxmgr.LockID, wire.OutPoint) error {
|
||||
func (w *mockWalletController) ReleaseOutput(wtxmgr.LockID,
|
||||
wire.OutPoint) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *mockWalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult,
|
||||
func (w *mockWalletController) ListLeasedOutputs() ([]*base.ListLeasedOutputResult, //nolint:lll
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// FundPsbt currently does nothing.
|
||||
func (w *mockWalletController) FundPsbt(*psbt.Packet, int32, chainfee.SatPerKWeight,
|
||||
string, *waddrmgr.KeyScope) (int32, error) {
|
||||
func (w *mockWalletController) FundPsbt(*psbt.Packet, int32,
|
||||
chainfee.SatPerKWeight, string, *waddrmgr.KeyScope) (int32, error) {
|
||||
|
||||
return 0, nil
|
||||
}
|
||||
@ -228,7 +236,9 @@ func (w *mockWalletController) FinalizePsbt(_ *psbt.Packet, _ string) error {
|
||||
}
|
||||
|
||||
// PublishTransaction sends a transaction to the PublishedTransactions chan.
|
||||
func (w *mockWalletController) PublishTransaction(tx *wire.MsgTx, _ string) error {
|
||||
func (w *mockWalletController) PublishTransaction(tx *wire.MsgTx,
|
||||
_ string) error {
|
||||
|
||||
w.PublishedTransactions <- tx
|
||||
return nil
|
||||
}
|
||||
@ -286,7 +296,8 @@ type mockChainNotifier struct {
|
||||
// that the tx confirmation will go over.
|
||||
func (c *mockChainNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
|
||||
pkScript []byte, numConfs, heightHint uint32,
|
||||
opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent, error) {
|
||||
opts ...chainntnfs.NotifierOption) (*chainntnfs.ConfirmationEvent,
|
||||
error) {
|
||||
|
||||
return &chainntnfs.ConfirmationEvent{
|
||||
Confirmed: c.ConfChan,
|
||||
@ -307,8 +318,9 @@ func (c *mockChainNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint,
|
||||
|
||||
// RegisterBlockEpochNtfn returns a BlockEpochEvent that contains a channel that
|
||||
// block epochs will go over.
|
||||
func (c *mockChainNotifier) RegisterBlockEpochNtfn(blockEpoch *chainntnfs.BlockEpoch) (
|
||||
*chainntnfs.BlockEpochEvent, error) {
|
||||
func (c *mockChainNotifier) RegisterBlockEpochNtfn(
|
||||
blockEpoch *chainntnfs.BlockEpoch) (*chainntnfs.BlockEpochEvent,
|
||||
error) {
|
||||
|
||||
return &chainntnfs.BlockEpochEvent{
|
||||
Epochs: c.EpochChan,
|
||||
@ -339,6 +351,7 @@ func (*mockChainIO) GetBestBlock() (*chainhash.Hash, int32, error) {
|
||||
|
||||
func (*mockChainIO) GetUtxo(op *wire.OutPoint, _ []byte,
|
||||
heightHint uint32, _ <-chan struct{}) (*wire.TxOut, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -346,6 +359,8 @@ func (*mockChainIO) GetBlockHash(blockHeight int64) (*chainhash.Hash, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock, error) {
|
||||
func (*mockChainIO) GetBlock(blockHash *chainhash.Hash) (*wire.MsgBlock,
|
||||
error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/lnutils"
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -132,7 +131,7 @@ func TestWalletRebroadcaster(t *testing.T) {
|
||||
ChainIO: chainIO,
|
||||
}
|
||||
|
||||
t.Run("rebroadcast bypass", func(t *testing.T) {
|
||||
t.Run("rebroadcast bypass", func(t *testing.T) { //nolint:paralleltest
|
||||
// We'll make a copy of the config, but without the
|
||||
// broadcaster.
|
||||
testCfg := *cfg
|
||||
@ -148,7 +147,8 @@ func TestWalletRebroadcaster(t *testing.T) {
|
||||
t, wallet, rebroadcaster, walletController,
|
||||
)
|
||||
|
||||
wallet.Shutdown()
|
||||
err = wallet.Shutdown()
|
||||
require.NoError(t, err)
|
||||
|
||||
// If we make a new wallet, that has the broadcaster, but
|
||||
// hasn't started yet, we should see the same behavior.
|
||||
@ -162,15 +162,19 @@ func TestWalletRebroadcaster(t *testing.T) {
|
||||
t, wallet, rebroadcaster, walletController,
|
||||
)
|
||||
|
||||
wallet.Shutdown()
|
||||
err = wallet.Shutdown()
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("rebroadcast normal", func(t *testing.T) {
|
||||
t.Run("rebroadcast normal", func(t *testing.T) { //nolint:paralleltest
|
||||
wallet, err := NewLightningWallet(*cfg)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, wallet.Startup())
|
||||
|
||||
defer wallet.Shutdown()
|
||||
defer func() {
|
||||
err = wallet.Shutdown()
|
||||
require.NoError(t, err)
|
||||
}()
|
||||
|
||||
// Wait for the broadcaster to start.
|
||||
_, err = lnutils.RecvOrTimeout(
|
||||
@ -192,6 +196,5 @@ func TestWalletRebroadcaster(t *testing.T) {
|
||||
rebroadcaster.confSignal, time.Second,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
})
|
||||
}
|
||||
|
@ -482,7 +482,8 @@ func (l *LightningWallet) PublishTransaction(tx *wire.MsgTx,
|
||||
const numConfs = 6
|
||||
|
||||
txConf, err := l.Cfg.Notifier.RegisterConfirmationsNtfn(
|
||||
&txHash, tx.TxOut[0].PkScript, numConfs, uint32(bestHeight),
|
||||
&txHash, tx.TxOut[0].PkScript, numConfs,
|
||||
uint32(bestHeight),
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user