Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add goclean #2

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4c4ce93
peer: fix panic during peer connection
andrewshvv Feb 22, 2017
d759e05
lnwallet: fix failure to exit early in openChannelAfterConfirmations
Roasbeef Feb 22, 2017
bd775b9
lnwallet: ensure reservation state is cleaned up in case of Cancel
Roasbeef Feb 22, 2017
2636e65
funding: ensure reservation contexts are remove in the case of workfl…
Roasbeef Feb 22, 2017
6c81dfa
chainntfns/btcdnotifier: fix race condition in notifyBlockEpochs
Roasbeef Feb 22, 2017
e910b12
lnd: fix issues reported by golint+govet
Roasbeef Feb 22, 2017
873211c
Use 48-bit commitment transaction numbers
cjamthagen Jan 4, 2017
3983e06
lnwire: use [6]byte obsfucator
cjamthagen Jan 5, 2017
97aa478
channeldb: change [4]byte obsfucator to [6]byte in test
cjamthagen Jan 9, 2017
46d2391
lnwire: add serializing and deserializing for type [6]byte
cjamthagen Jan 9, 2017
42b3b54
lnwallet: allow maximum state size to be used + tests
cjamthagen Jan 9, 2017
0410ea7
test: Add table driven tests for script_utils
cjamthagen Jan 9, 2017
bdb38ca
lnwallet: fix bug that makes commitment transaction unspendable
cjamthagen Jan 13, 2017
cf30609
lnwallet: extend test to check for valid locktime and sequence
cjamthagen Jan 14, 2017
ace1adb
funding: fix logging display of node pub key upon recv funding req
Roasbeef Feb 22, 2017
f9b4456
lnwire: remove String() method from FeatureVector
Roasbeef Feb 22, 2017
3e14c6e
features+lnd: add a feature bit for 48-bit state hints
Roasbeef Feb 22, 2017
3a64786
lnwire: fix features_test.go to not reference removed .String() method
Roasbeef Feb 23, 2017
b40afea
shachain: complete shachain implementation
andrewshvv Dec 13, 2016
f86557c
channeldb+lnwallet: replace elkrem with shachain
andrewshvv Dec 14, 2016
9034f85
features: add shachain required feature flag
andrewshvv Feb 22, 2017
9d78b49
lnd: add gofmt, govet, gosimple, unconvert, race detector, test cover…
andrewshvv Feb 23, 2017
aa8d7fd
fix gosimple warnings
andrewshvv Feb 23, 2017
4a23697
fix gofmt warnings
andrewshvv Feb 23, 2017
9ade906
fix unconvert warnings
andrewshvv Feb 23, 2017
dd6bdc7
fix govet warnings
andrewshvv Feb 23, 2017
e64c03a
partially fix golint warnings
andrewshvv Feb 23, 2017
6140d6f
readme: add coverage badge
andrewshvv Feb 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ install:
- go get -v github.com/roasbeef/btcd # Required for the rpc test package.
- go get -v github.com/Masterminds/glide
- glide install
- go install -v . # Required for the integration tests.
- go install . ./cmd/...
- go get -v golang.org/x/tools/cmd/cover
- go get -v github.com/alecthomas/gometalinter
- gometalinter --install
script:
- export PATH=$PATH:$HOME/gopath/bin
- go test -p 1 -v $(go list ./... | grep -v '/vendor/')
- ./goclean.sh
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
    
[![Godoc](https://godoc.org/github.com/lightningnetwork/lnd?status.svg)]
(https://godoc.org/github.com/lightningnetwork/lnd)
    
[![Coverage Status](https://coveralls.io/repos/github/AndrewSamokhvalov/lnd/badge.svg?branch=master)](https://coveralls.io/github/AndrewSamokhvalov/lnd?branch=master)

The Lightning Network Daemon (`lnd`) - is a complete implementation of a
[Lightning Network](https://lightning.network) node and currently
Expand Down
4 changes: 2 additions & 2 deletions brontide/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
// exchange and message encryption protocol dubbed "Brontide" after initial TCP
// connection establishment. In the case of a successful handshake, all
// messages sent via the .Write() method are encrypted with an AEAD cipher
// along with an encrypted length-prefix. See the BrontideMachine struct for
// along with an encrypted length-prefix. See the Machine struct for
// additional details w.r.t to the handshake and encryption scheme.
type Conn struct {
conn net.Conn

noise *BrontideMachine
noise *Machine

readBuf bytes.Buffer
}
Expand Down
4 changes: 2 additions & 2 deletions brontide/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

// Listener is an implementation of a net.Conn which executes an authenticated
// key exchange and message encryption protocol dubeed "BrontideMachine" after
// initial connection acceptance. See the BrontideMachine struct for additional
// key exchange and message encryption protocol dubeed "Machine" after
// initial connection acceptance. See the Machine struct for additional
// details w.r.t the handshake and encryption scheme used within the
// connection.
type Listener struct {
Expand Down
47 changes: 19 additions & 28 deletions brontide/noise.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func newHandshakeState(initiator bool, prologue []byte,
return h
}

// BrontideMachine is a state-machine which implements Brontide: an
// Machine is a state-machine which implements Brontide: an
// Authenticated-key Exchange in Three Acts. Brontide is derived from the Noise
// framework, specifically implementing the Noise_XK handshake. Once the
// initial 3-act handshake has completed all messages are encrypted with a
Expand All @@ -324,7 +324,7 @@ func newHandshakeState(initiator bool, prologue []byte,
// -> e, es
// <- e, ee
// -> s, se
type BrontideMachine struct {
type Machine struct {
sendCipher cipherState
recvCipher cipherState

Expand All @@ -336,12 +336,12 @@ type BrontideMachine struct {
// be nil. The handshake state within brontide is initialized using the ascii
// string "bitcoin" as the prologue.
func NewBrontideMachine(initiator bool, localPub *btcec.PrivateKey,
remotePub *btcec.PublicKey) *BrontideMachine {
remotePub *btcec.PublicKey) *Machine {

handshake := newHandshakeState(initiator, []byte("lightning"), localPub,
remotePub)

return &BrontideMachine{handshakeState: handshake}
return &Machine{handshakeState: handshake}
}

const (
Expand Down Expand Up @@ -381,7 +381,7 @@ const (
// derived from this result.
//
// -> e, es
func (b *BrontideMachine) GenActOne() ([ActOneSize]byte, error) {
func (b *Machine) GenActOne() ([ActOneSize]byte, error) {
var (
err error
actOne [ActOneSize]byte
Expand Down Expand Up @@ -413,7 +413,7 @@ func (b *BrontideMachine) GenActOne() ([ActOneSize]byte, error) {
// executes the mirrored actions to that of the initiator extending the
// handshake digest and deriving a new shared secret based on a ECDH with the
// initiator's ephemeral key and responder's static key.
func (b *BrontideMachine) RecvActOne(actOne [ActOneSize]byte) error {
func (b *Machine) RecvActOne(actOne [ActOneSize]byte) error {
var (
err error
e [33]byte
Expand Down Expand Up @@ -443,11 +443,8 @@ func (b *BrontideMachine) RecvActOne(actOne [ActOneSize]byte) error {

// If the initiator doesn't know our static key, then this operation
// will fail.
if _, err := b.DecryptAndHash(p[:]); err != nil {
return err
}

return nil
_, err = b.DecryptAndHash(p[:])
return err
}

// GenActTwo generates the second packet (act two) to be sent from the
Expand All @@ -456,7 +453,7 @@ func (b *BrontideMachine) RecvActOne(actOne [ActOneSize]byte) error {
// initiator's and responder's ephemeral keys.
//
// <- e, ee
func (b *BrontideMachine) GenActTwo() ([ActTwoSize]byte, error) {
func (b *Machine) GenActTwo() ([ActTwoSize]byte, error) {
var (
err error
actTwo [ActTwoSize]byte
Expand Down Expand Up @@ -487,7 +484,7 @@ func (b *BrontideMachine) GenActTwo() ([ActTwoSize]byte, error) {
// RecvActTwo processes the second packet (act two) sent from the responder to
// the initiator. A successful processing of this packet authenticates the
// initiator to the responder.
func (b *BrontideMachine) RecvActTwo(actTwo [ActTwoSize]byte) error {
func (b *Machine) RecvActTwo(actTwo [ActTwoSize]byte) error {
var (
err error
e [33]byte
Expand Down Expand Up @@ -515,11 +512,8 @@ func (b *BrontideMachine) RecvActTwo(actTwo [ActTwoSize]byte) error {
s := ecdh(b.remoteEphemeral, b.localEphemeral)
b.mixKey(s)

if _, err := b.DecryptAndHash(p[:]); err != nil {
return err
}

return nil
_, err = b.DecryptAndHash(p[:])
return err
}

// GenActThree creates the final (act three) packet of the handshake. Act three
Expand All @@ -529,7 +523,7 @@ func (b *BrontideMachine) RecvActTwo(actTwo [ActTwoSize]byte) error {
// the final session.
//
// -> s, se
func (b *BrontideMachine) GenActThree() ([ActThreeSize]byte, error) {
func (b *Machine) GenActThree() ([ActThreeSize]byte, error) {
var actThree [ActThreeSize]byte

ourPubkey := b.localStatic.PubKey().SerializeCompressed()
Expand All @@ -555,7 +549,7 @@ func (b *BrontideMachine) GenActThree() ([ActThreeSize]byte, error) {
// the responder. After processing this act, the responder learns of the
// initiator's static public key. Decryption of the static key serves to
// authenticate the initiator to the responder.
func (b *BrontideMachine) RecvActThree(actThree [ActThreeSize]byte) error {
func (b *Machine) RecvActThree(actThree [ActThreeSize]byte) error {
var (
err error
s [33 + 16]byte
Expand Down Expand Up @@ -602,7 +596,7 @@ func (b *BrontideMachine) RecvActThree(actThree [ActThreeSize]byte) error {
// instances: one which is used to encrypt messages from the initiator to the
// responder, and another which is used to encrypt message for the opposite
// direction.
func (b *BrontideMachine) split() {
func (b *Machine) split() {
var (
empty []byte
sendKey [32]byte
Expand Down Expand Up @@ -637,7 +631,7 @@ func (b *BrontideMachine) split() {
// ciphertext of the message is pre-pended with an encrypt+auth'd length which
// must be used as the AD to the AEAD construction when being decrypted by the
// other side.
func (b *BrontideMachine) WriteMessage(w io.Writer, p []byte) error {
func (b *Machine) WriteMessage(w io.Writer, p []byte) error {
// The total length of each message payload including the MAC size
// payload exceed the largest number encodable within a 16-bit unsigned
// integer.
Expand All @@ -662,16 +656,13 @@ func (b *BrontideMachine) WriteMessage(w io.Writer, p []byte) error {
// single packet, as any fragmentation should have taken place at a
// higher level.
cipherText := b.sendCipher.Encrypt(nil, nil, p)
if _, err := w.Write(cipherText); err != nil {
return err
}

return nil
_, err := w.Write(cipherText)
return err
}

// ReadMessage attempts to read the next message from the passed io.Reader. In
// the case of an authentication error, a non-nil error is returned.
func (b *BrontideMachine) ReadMessage(r io.Reader) ([]byte, error) {
func (b *Machine) ReadMessage(r io.Reader) ([]byte, error) {
var cipherLen [lengthHeaderSize + macSize]byte
if _, err := io.ReadFull(r, cipherLen[:]); err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion brontide/noise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestConnectionCorrectness(t *testing.T) {
}

func TestMaxPayloadLength(t *testing.T) {
b := BrontideMachine{}
b := Machine{}
b.split()

// Create a payload that's juust over the maximum alloted payload
Expand Down
11 changes: 4 additions & 7 deletions chainntnfs/btcdnotify/btcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ out:
chainntnfs.Log.Infof("New block: height=%v, sha=%v",
update.blockHeight, update.blockHash)

b.wg.Add(1)
go b.notifyBlockEpochs(update.blockHeight,
b.notifyBlockEpochs(update.blockHeight,
update.blockHash)

newHeight := update.blockHeight
Expand Down Expand Up @@ -469,8 +468,6 @@ func (b *BtcdNotifier) attemptHistoricalDispatch(msg *confirmationsNotification,
// notifyBlockEpochs notifies all registered block epoch clients of the newly
// connected block to the main chain.
func (b *BtcdNotifier) notifyBlockEpochs(newHeight int32, newSha *chainhash.Hash) {
defer b.wg.Done()

epoch := &chainntnfs.BlockEpoch{
Height: newHeight,
Hash: newSha,
Expand Down Expand Up @@ -563,7 +560,7 @@ func (b *BtcdNotifier) checkConfirmationTrigger(txSha *chainhash.Hash,
// which notification(s) we should fire off with
// each incoming block.
confClient.initialConfirmHeight = uint32(newTip.blockHeight)
finalConfHeight := uint32(confClient.initialConfirmHeight + confClient.numConfirmations - 1)
finalConfHeight := confClient.initialConfirmHeight + confClient.numConfirmations - 1
heapEntry := &confEntry{
confClient,
confDetails,
Expand Down Expand Up @@ -594,7 +591,7 @@ type spendCancel struct {
spendID uint64
}

// RegisterSpendNotification registers an intent to be notified once the target
// RegisterSpendNtfn registers an intent to be notified once the target
// outpoint has been spent by a transaction on-chain. Once a spend of the target
// outpoint has been detected, the details of the spending event will be sent
// across the 'Spend' channel.
Expand Down Expand Up @@ -670,7 +667,7 @@ type confirmationsNotification struct {
negativeConf chan int32 // TODO(roasbeef): re-org funny business
}

// RegisterConfirmationsNotification registers a notification with BtcdNotifier
// RegisterConfirmationsNtfn registers a notification with BtcdNotifier
// which will be triggered once the txid reaches numConfs number of
// confirmations.
func (b *BtcdNotifier) RegisterConfirmationsNtfn(txid *chainhash.Hash,
Expand Down
2 changes: 1 addition & 1 deletion chainntnfs/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func getTestTxId(miner *rpctest.Harness) (*chainhash.Hash, error) {
}

outputs := []*wire.TxOut{
&wire.TxOut{
{
Value: 2e8,
PkScript: script,
},
Expand Down
2 changes: 1 addition & 1 deletion chainntnfs/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/btcsuite/btclog"
)

// log is a logger that is initialized with no output filters. This
// Log is a logger that is initialized with no output filters. This
// means the package will not perform any logging by default until the caller
// requests it.
var Log btclog.Logger
Expand Down
Loading