multi: fix go vet
warnings throughout code base
This commit is contained in:
parent
55e693aa09
commit
384fe61e73
@ -174,7 +174,7 @@ out:
|
|||||||
breachTXID := &breachInfo.commitHash
|
breachTXID := &breachInfo.commitHash
|
||||||
confChan, err := b.notifier.RegisterConfirmationsNtfn(breachTXID, 1)
|
confChan, err := b.notifier.RegisterConfirmationsNtfn(breachTXID, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
brarLog.Errorf("unable to register for conf for txid: ",
|
brarLog.Errorf("unable to register for conf for txid: %v",
|
||||||
breachTXID)
|
breachTXID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -592,7 +592,9 @@ func (b *BtcdNotifier) RegisterSpendNtfn(outpoint *wire.OutPoint) (*chainntnfs.S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &chainntnfs.SpendEvent{ntfn.spendChan}, nil
|
return &chainntnfs.SpendEvent{
|
||||||
|
Spend: ntfn.spendChan,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirmationNotification represents a client's intent to receive a
|
// confirmationNotification represents a client's intent to receive a
|
||||||
|
@ -40,7 +40,12 @@ func getTestTxId(miner *rpctest.Harness) (*chainhash.Hash, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
outputs := []*wire.TxOut{&wire.TxOut{2e8, script}}
|
outputs := []*wire.TxOut{
|
||||||
|
&wire.TxOut{
|
||||||
|
Value: 2e8,
|
||||||
|
PkScript: script,
|
||||||
|
},
|
||||||
|
}
|
||||||
return miner.SendOutputs(outputs, 10)
|
return miner.SendOutputs(outputs, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,6 @@ func assertChannelOpen(t *testing.T, miner *rpctest.Harness, numConfs uint32,
|
|||||||
t.Fatalf("channel never opened")
|
t.Fatalf("channel never opened")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// bobNode represents the other party involved as a node within LN. Bob is our
|
// bobNode represents the other party involved as a node within LN. Bob is our
|
||||||
@ -210,7 +208,10 @@ func newBobNode(miner *rpctest.Harness, amt btcutil.Amount) (*bobNode, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Give bobNode one 7 BTC output for use in creating channels.
|
// Give bobNode one 7 BTC output for use in creating channels.
|
||||||
output := &wire.TxOut{7e8, bobAddrScript}
|
output := &wire.TxOut{
|
||||||
|
Value: 7e8,
|
||||||
|
PkScript: bobAddrScript,
|
||||||
|
}
|
||||||
mainTxid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
|
mainTxid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -284,7 +285,10 @@ func loadTestCredits(miner *rpctest.Harness, w *lnwallet.LightningWallet, numOut
|
|||||||
|
|
||||||
addrs = append(addrs, walletAddr)
|
addrs = append(addrs, walletAddr)
|
||||||
|
|
||||||
output := &wire.TxOut{satoshiPerOutput, script}
|
output := &wire.TxOut{
|
||||||
|
Value: satoshiPerOutput,
|
||||||
|
PkScript: script,
|
||||||
|
}
|
||||||
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
|
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -949,7 +953,10 @@ func testListTransactionDetails(miner *rpctest.Harness, wallet *lnwallet.Lightni
|
|||||||
t.Fatalf("unable to create output script: %v", err)
|
t.Fatalf("unable to create output script: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
output := &wire.TxOut{outputAmt, script}
|
output := &wire.TxOut{
|
||||||
|
Value: outputAmt,
|
||||||
|
PkScript: script,
|
||||||
|
}
|
||||||
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
|
txid, err := miner.SendOutputs([]*wire.TxOut{output}, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to send coinbase: %v", err)
|
t.Fatalf("unable to send coinbase: %v", err)
|
||||||
@ -1044,7 +1051,7 @@ func testListTransactionDetails(miner *rpctest.Harness, wallet *lnwallet.Lightni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !burnTxFound {
|
if !burnTxFound {
|
||||||
t.Fatalf("tx burning btc not found")
|
t.Fatal("tx burning btc not found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1056,7 +1063,7 @@ func testTransactionSubscriptions(miner *rpctest.Harness, w *lnwallet.LightningW
|
|||||||
// implementation of the WalletController.
|
// implementation of the WalletController.
|
||||||
txClient, err := w.SubscribeTransactions()
|
txClient, err := w.SubscribeTransactions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to generate tx subscription: %v")
|
t.Fatalf("unable to generate tx subscription: %v", err)
|
||||||
}
|
}
|
||||||
defer txClient.Cancel()
|
defer txClient.Cancel()
|
||||||
|
|
||||||
@ -1097,7 +1104,10 @@ func testTransactionSubscriptions(miner *rpctest.Harness, w *lnwallet.LightningW
|
|||||||
t.Fatalf("unable to create output script: %v", err)
|
t.Fatalf("unable to create output script: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
output := &wire.TxOut{outputAmt, script}
|
output := &wire.TxOut{
|
||||||
|
Value: outputAmt,
|
||||||
|
PkScript: script,
|
||||||
|
}
|
||||||
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
|
if _, err := miner.SendOutputs([]*wire.TxOut{output}, 10); err != nil {
|
||||||
t.Fatalf("unable to send coinbase: %v", err)
|
t.Fatalf("unable to send coinbase: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,16 @@ func TestCommitmentSpendValidation(t *testing.T) {
|
|||||||
// transaction which sweeps the funds to a random address.
|
// transaction which sweeps the funds to a random address.
|
||||||
targetOutput, err := commitScriptUnencumbered(aliceKeyPub)
|
targetOutput, err := commitScriptUnencumbered(aliceKeyPub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to create target output: %v")
|
t.Fatalf("unable to create target output: %v", err)
|
||||||
}
|
}
|
||||||
sweepTx := wire.NewMsgTx(2)
|
sweepTx := wire.NewMsgTx(2)
|
||||||
sweepTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{commitmentTx.TxHash(), 0}, nil, nil))
|
sweepTx.AddTxIn(wire.NewTxIn(&wire.OutPoint{
|
||||||
|
Hash: commitmentTx.TxHash(),
|
||||||
|
Index: 0,
|
||||||
|
},
|
||||||
|
nil,
|
||||||
|
nil),
|
||||||
|
)
|
||||||
sweepTx.AddTxOut(&wire.TxOut{
|
sweepTx.AddTxOut(&wire.TxOut{
|
||||||
PkScript: targetOutput,
|
PkScript: targetOutput,
|
||||||
Value: 0.5 * 10e8,
|
Value: 0.5 * 10e8,
|
||||||
@ -77,7 +83,7 @@ func TestCommitmentSpendValidation(t *testing.T) {
|
|||||||
// First, we'll test spending with Alice's key after the timeout.
|
// First, we'll test spending with Alice's key after the timeout.
|
||||||
delayScript, err := commitScriptToSelf(csvTimeout, aliceKeyPub, revokePubKey)
|
delayScript, err := commitScriptToSelf(csvTimeout, aliceKeyPub, revokePubKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to generate alice delay script: %v")
|
t.Fatalf("unable to generate alice delay script: %v", err)
|
||||||
}
|
}
|
||||||
sweepTx.TxIn[0].Sequence = lockTimeToSequence(false, csvTimeout)
|
sweepTx.TxIn[0].Sequence = lockTimeToSequence(false, csvTimeout)
|
||||||
signDesc := &SignDescriptor{
|
signDesc := &SignDescriptor{
|
||||||
@ -92,7 +98,7 @@ func TestCommitmentSpendValidation(t *testing.T) {
|
|||||||
aliceWitnessSpend, err := CommitSpendTimeout(aliceSelfOutputSigner,
|
aliceWitnessSpend, err := CommitSpendTimeout(aliceSelfOutputSigner,
|
||||||
signDesc, sweepTx)
|
signDesc, sweepTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to generate delay commit spend witness :%v")
|
t.Fatalf("unable to generate delay commit spend witness: %v", err)
|
||||||
}
|
}
|
||||||
sweepTx.TxIn[0].Witness = aliceWitnessSpend
|
sweepTx.TxIn[0].Witness = aliceWitnessSpend
|
||||||
vm, err := txscript.NewEngine(delayOutput.PkScript,
|
vm, err := txscript.NewEngine(delayOutput.PkScript,
|
||||||
@ -378,8 +384,8 @@ func TestHTLCSenderSpendValidation(t *testing.T) {
|
|||||||
t.Fatalf("spend test case #%v succeed, spend should be invalid: %v", i, err)
|
t.Fatalf("spend test case #%v succeed, spend should be invalid: %v", i, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
debugBuf.WriteString(fmt.Sprintf("Stack: ", vm.GetStack()))
|
debugBuf.WriteString(fmt.Sprintf("Stack: %v", vm.GetStack()))
|
||||||
debugBuf.WriteString(fmt.Sprintf("AltStack: ", vm.GetAltStack()))
|
debugBuf.WriteString(fmt.Sprintf("AltStack: %v", vm.GetAltStack()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,8 +557,8 @@ func TestHTLCReceiverSpendValidation(t *testing.T) {
|
|||||||
t.Fatalf("spend test case #%v succeed, spend should be invalid: %v", i, err)
|
t.Fatalf("spend test case #%v succeed, spend should be invalid: %v", i, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
debugBuf.WriteString(fmt.Sprintf("Stack: ", vm.GetStack()))
|
debugBuf.WriteString(fmt.Sprintf("Stack: %v", vm.GetStack()))
|
||||||
debugBuf.WriteString(fmt.Sprintf("AltStack: ", vm.GetAltStack()))
|
debugBuf.WriteString(fmt.Sprintf("AltStack: %v", vm.GetAltStack()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
|
||||||
"github.com/roasbeef/btcd/btcec"
|
"github.com/roasbeef/btcd/btcec"
|
||||||
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChannelAnnouncement message is used to announce the existence of a channel
|
// ChannelAnnouncement message is used to announce the existence of a channel
|
||||||
@ -50,35 +48,6 @@ var _ Message = (*ChannelAnnouncement)(nil)
|
|||||||
//
|
//
|
||||||
// This is part of the lnwire.Message interface.
|
// This is part of the lnwire.Message interface.
|
||||||
func (a *ChannelAnnouncement) Validate() error {
|
func (a *ChannelAnnouncement) Validate() error {
|
||||||
// TODO(roasbeef): move validation to discovery service
|
|
||||||
return nil
|
|
||||||
|
|
||||||
var sigHash []byte
|
|
||||||
|
|
||||||
sigHash = chainhash.DoubleHashB(a.FirstNodeID.SerializeCompressed())
|
|
||||||
if !a.FirstBitcoinSig.Verify(sigHash, a.FirstBitcoinKey) {
|
|
||||||
return errors.New("can't verify first bitcoin signature")
|
|
||||||
}
|
|
||||||
|
|
||||||
sigHash = chainhash.DoubleHashB(a.SecondNodeID.SerializeCompressed())
|
|
||||||
if !a.SecondBitcoinSig.Verify(sigHash, a.SecondBitcoinKey) {
|
|
||||||
return errors.New("can't verify second bitcoin signature")
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := a.DataToSign()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
dataHash := chainhash.DoubleHashB(data)
|
|
||||||
|
|
||||||
if !a.FirstNodeSig.Verify(dataHash, a.FirstNodeID) {
|
|
||||||
return errors.New("can't verify data in first node signature")
|
|
||||||
}
|
|
||||||
|
|
||||||
if !a.SecondNodeSig.Verify(dataHash, a.SecondNodeID) {
|
|
||||||
return errors.New("can't verify data in second node signature")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/roasbeef/btcd/btcec"
|
"github.com/roasbeef/btcd/btcec"
|
||||||
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -108,22 +107,6 @@ var _ Message = (*NodeAnnouncement)(nil)
|
|||||||
func (a *NodeAnnouncement) Validate() error {
|
func (a *NodeAnnouncement) Validate() error {
|
||||||
// TODO(roasbeef): move validation to discovery service
|
// TODO(roasbeef): move validation to discovery service
|
||||||
return nil
|
return nil
|
||||||
|
|
||||||
if err := a.Alias.Validate(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
data, err := a.DataToSign()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dataHash := chainhash.DoubleHashB(data)
|
|
||||||
if !a.Signature.Verify(dataHash, a.NodeID) {
|
|
||||||
return errors.New("can't check the node annoucement signature")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode deserializes a serialized NodeAnnouncement stored in the
|
// Decode deserializes a serialized NodeAnnouncement stored in the
|
||||||
|
@ -422,7 +422,9 @@ func (n *networkHarness) SetUp() error {
|
|||||||
// Load up the wallets of the seeder nodes with 10 outputs of 1 BTC
|
// Load up the wallets of the seeder nodes with 10 outputs of 1 BTC
|
||||||
// each.
|
// each.
|
||||||
ctxb := context.Background()
|
ctxb := context.Background()
|
||||||
addrReq := &lnrpc.NewAddressRequest{lnrpc.NewAddressRequest_WITNESS_PUBKEY_HASH}
|
addrReq := &lnrpc.NewAddressRequest{
|
||||||
|
Type: lnrpc.NewAddressRequest_WITNESS_PUBKEY_HASH,
|
||||||
|
}
|
||||||
clients := []lnrpc.LightningClient{n.Alice, n.Bob}
|
clients := []lnrpc.LightningClient{n.Alice, n.Bob}
|
||||||
for _, client := range clients {
|
for _, client := range clients {
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
|
@ -1029,9 +1029,9 @@ func generateSphinxPacket(route *Route, paymentHash []byte) ([]byte, error) {
|
|||||||
// mutating the curve parameters, which are unset in a higher
|
// mutating the curve parameters, which are unset in a higher
|
||||||
// level in order to avoid spamming the logs.
|
// level in order to avoid spamming the logs.
|
||||||
pub := btcec.PublicKey{
|
pub := btcec.PublicKey{
|
||||||
btcec.S256(),
|
Curve: btcec.S256(),
|
||||||
hop.Channel.Node.PubKey.X,
|
X: hop.Channel.Node.PubKey.X,
|
||||||
hop.Channel.Node.PubKey.Y,
|
Y: hop.Channel.Node.PubKey.Y,
|
||||||
}
|
}
|
||||||
nodes[i] = &pub
|
nodes[i] = &pub
|
||||||
}
|
}
|
||||||
|
10
rpcserver.go
10
rpcserver.go
@ -705,7 +705,9 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
|||||||
|
|
||||||
rpcsLog.Debugf("[walletbalance] balance=%v", balance)
|
rpcsLog.Debugf("[walletbalance] balance=%v", balance)
|
||||||
|
|
||||||
return &lnrpc.WalletBalanceResponse{balance.ToBTC()}, nil
|
return &lnrpc.WalletBalanceResponse{
|
||||||
|
Balance: balance.ToBTC(),
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelBalance returns the total available channel flow across all open
|
// ChannelBalance returns the total available channel flow across all open
|
||||||
@ -969,8 +971,6 @@ func (r *rpcServer) SendPayment(paymentStream lnrpc.Lightning_SendPaymentServer)
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendPaymentSync is the synchronous non-streaming version of SendPayment.
|
// SendPaymentSync is the synchronous non-streaming version of SendPayment.
|
||||||
@ -1242,8 +1242,6 @@ func (r *rpcServer) SubscribeInvoices(req *lnrpc.InvoiceSubscription,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SubscribeTransactions creates a uni-directional stream (server -> client) in
|
// SubscribeTransactions creates a uni-directional stream (server -> client) in
|
||||||
@ -1286,8 +1284,6 @@ func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetTransactions returns a list of describing all the known transactions
|
// GetTransactions returns a list of describing all the known transactions
|
||||||
|
@ -385,8 +385,6 @@ func (s *server) sendToPeer(target *btcec.PublicKey, msgs ...lnwire.Message) err
|
|||||||
case <-s.quit:
|
case <-s.quit:
|
||||||
return errors.New("server shutting down")
|
return errors.New("server shutting down")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// peerConnected is a function that handles initialization a newly connected
|
// peerConnected is a function that handles initialization a newly connected
|
||||||
|
@ -208,7 +208,7 @@ func TestAddSerializedKidsToList(t *testing.T) {
|
|||||||
|
|
||||||
kidList, err := deserializeKidList(&b)
|
kidList, err := deserializeKidList(&b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unable to deserialize kid output list: ", err)
|
t.Fatalf("unable to deserialize kid output list: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
|
Loading…
Reference in New Issue
Block a user