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

Fix numerous typos #101

Merged
merged 1 commit into from
Jan 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(https://godoc.org/github.com/lightningnetwork/lnd)

The Lightning Network Daemon (`lnd`) - is a complete implementation of a
[Lightning Network](http://lightning.network) node and currently
[Lightning Network](https://lightning.network) node and currently
deployed on `testnet4` - the Bitcoin Test Network. It utilizes an
upcoming upgrade to Bitcoin: Segregated Witness (`segwit`). The
project's codebase uses the [btcsuite](https://github.com/btcsuite/) set
Expand Down Expand Up @@ -56,7 +56,7 @@ said, `lnd` the current status of `lnd`'s BOLT compliance is:
- [X] BOLT 8: Encrypted and Authenticated Transport

## Installation
In order to build form source, the following build dependencies are
In order to build from source, the following build dependencies are
required:

* **Go:** Installation instructions can be found [here](http://golang.org/doc/install).
Expand Down
56 changes: 28 additions & 28 deletions breacharbiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"github.com/roasbeef/btcutil"
)

// breachArbiter is a special sub-system which is responsible for watching and
// breachArbiter is a special subsystem which is responsible for watching and
// acting on the detection of any attempted uncooperative channel breaches by
// channel counter-parties. This file essentially acts as deterrence code for
// channel counterparties. This file essentially acts as deterrence code for
// those attempting to launch attacks against the daemon. In practice it's
// expected that the logic in this file never gets executed, but it is
// important to have it in place just in case we encounter cheating channel
// counter-parties.
// TODO(roasbeef): closures in config for sub-system pointers to decouple?
// counterparties.
// TODO(roasbeef): closures in config for subsystem pointers to decouple?
type breachArbiter struct {
wallet *lnwallet.LightningWallet
db *channeldb.DB
Expand All @@ -32,22 +32,22 @@ type breachArbiter struct {
// observers we're currently managing. The key of the map is the
// funding outpoint of the channel, and the value is a channel which
// will be closed once we detect that the channel has been
// cooperatively closed, there by killing the goroutine and freeing up
// resource.
// cooperatively closed, thereby killing the goroutine and freeing up
// resources.
breachObservers map[wire.OutPoint]chan struct{}

// breachedContracts is a channel which is used internally within the
// struct to send the necessary information required to punish a
// counter-party once a channel breach is detected. Breach observers
// counterparty once a channel breach is detected. Breach observers
// use this to communicate with the main contractObserver goroutine.
breachedContracts chan *retributionInfo

// newContracts is a channel which is used by outside sub-systems to
// newContracts is a channel which is used by outside subsystems to
// notify the breachArbiter of a new contract (a channel) that should
// be watched.
newContracts chan *lnwallet.LightningChannel

// settledContracts is a channel by outside sub-subsystems to notify
// settledContracts is a channel by outside subsystems to notify
// the breachArbiter that a channel has peacefully been closed. Once a
// channel has been closed the arbiter no longer needs to watch for
// breach closes.
Expand All @@ -59,8 +59,8 @@ type breachArbiter struct {
wg sync.WaitGroup
}

// newBreachArbiter creates a new instance of a breachArbiter initialize with
// its dependant objects.
// newBreachArbiter creates a new instance of a breachArbiter initialized with
// its dependent objects.
func newBreachArbiter(wallet *lnwallet.LightningWallet, db *channeldb.DB,
notifier chainntnfs.ChainNotifier, h *htlcSwitch) *breachArbiter {

Expand Down Expand Up @@ -250,7 +250,7 @@ out:

// exactRetribution is a goroutine which is executed once a contract breach has
// been detected by a breachObserver. This function is responsible for
// punishing a counter-party for violating the channel contract by sweeping ALL
// punishing a counterparty for violating the channel contract by sweeping ALL
// the lingering funds within the channel into the daemon's wallet.
//
// NOTE: This MUST be run as a goroutine.
Expand All @@ -259,7 +259,7 @@ func (b *breachArbiter) exactRetribution(confChan *chainntnfs.ConfirmationEvent,

defer b.wg.Done()

// TODO(roasbeef): state needs to be check-pointed here
// TODO(roasbeef): state needs to be checkpointed here

select {
case _, ok := <-confChan.Confirmed:
Expand All @@ -270,7 +270,7 @@ func (b *breachArbiter) exactRetribution(confChan *chainntnfs.ConfirmationEvent,
}

// Otherwise, if this is a real confirmation notification, then
// we fall through to complete out duty.
// we fall through to complete our duty.
case <-b.quit:
return
}
Expand All @@ -291,7 +291,7 @@ func (b *breachArbiter) exactRetribution(confChan *chainntnfs.ConfirmationEvent,
}))

// Finally, broadcast the transaction, finalizing the channels'
// retribution against the cheating counter-party.
// retribution against the cheating counterparty.
if err := b.wallet.PublishTransaction(justiceTx); err != nil {
brarLog.Errorf("unable to broadcast "+
"justice tx: %v", err)
Expand All @@ -300,7 +300,7 @@ func (b *breachArbiter) exactRetribution(confChan *chainntnfs.ConfirmationEvent,

// As a conclusionary step, we register for a notification to be
// dispatched once the justice tx is confirmed. After confirmation we
// notify the caller that initiated the retribution work low that the
// notify the caller that initiated the retribution workflow that the
// deed has been done.
justiceTXID := justiceTx.TxHash()
confChan, err = b.notifier.RegisterConfirmationsNtfn(&justiceTXID, 1)
Expand All @@ -316,7 +316,7 @@ func (b *breachArbiter) exactRetribution(confChan *chainntnfs.ConfirmationEvent,
return
}

// TODO(roasbeef): factor in HTLC's
// TODO(roasbeef): factor in HTLCs
revokedFunds := breachInfo.revokedOutput.amt
totalFunds := revokedFunds + breachInfo.selfOutput.amt

Expand All @@ -338,7 +338,7 @@ func (b *breachArbiter) exactRetribution(confChan *chainntnfs.ConfirmationEvent,
}

// breachObserver notifies the breachArbiter contract observer goroutine that a
// channel's contract has been breached by the prior counter party. Once
// channel's contract has been breached by the prior counterparty. Once
// notified the breachArbiter will attempt to sweep ALL funds within the
// channel using the information provided within the BreachRetribution
// generated due to the breach of channel contract. The funds will be swept
Expand All @@ -361,7 +361,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,

// A read from this channel indicates that a channel breach has been
// detected! So we notify the main coordination goroutine with the
// information needed to bring the counter-party to justice.
// information needed to bring the counterparty to justice.
case breachInfo := <-contract.ContractBreach:
brarLog.Warnf("REVOKED STATE #%v FOR ChannelPoint(%v) "+
"broadcast, REMOTE PEER IS DOING SOMETHING "+
Expand All @@ -370,7 +370,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,

// Immediately notify the HTLC switch that this link has been
// breached in order to ensure any incoming or outgoing
// multi-hop HTLC's aren't sent over this link, nor any other
// multi-hop HTLCs aren't sent over this link, nor any other
// links associated with this peer.
b.htlcSwitch.CloseLink(chanPoint, CloseBreach)
if err := contract.DeleteState(); err != nil {
Expand All @@ -396,7 +396,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
}

// Next we create the witness generation function that will be
// used to sweep the cheating counter party's output by taking
// used to sweep the cheating counterparty's output by taking
// advantage of the revocation clause within the output's
// witness script.
remoteSignDesc := breachInfo.RemoteOutputSignDesc
Expand Down Expand Up @@ -438,7 +438,7 @@ func (b *breachArbiter) breachObserver(contract *lnwallet.LightningChannel,
}

// breachedOutput contains all the information needed to sweep a breached
// output. A breach output is an output that were now entitled to due to a
// output. A breached output is an output that we are now entitled to due to a
// revoked commitment transaction being broadcast.
type breachedOutput struct {
amt btcutil.Amount
Expand All @@ -450,7 +450,7 @@ type breachedOutput struct {

// retributionInfo encapsulates all the data needed to sweep all the contested
// funds within a channel whose contract has been breached by the prior
// counter-party. This struct is used by the utxoNursery to create the justice
// counterparty. This struct is used by the utxoNursery to create the justice
// transaction which spends all outputs of the commitment transaction into an
// output controlled by the wallet.
type retributionInfo struct {
Expand All @@ -468,7 +468,7 @@ type retributionInfo struct {

// createJusticeTx creates a transaction which exacts "justice" by sweeping ALL
// the funds within the channel which we are now entitled to due to a breach of
// the channel's contract by the counter-party. This function returns a *fully*
// the channel's contract by the counterparty. This function returns a *fully*
// signed transaction with the witness for each input fully in place.
func (b *breachArbiter) createJusticeTx(r *retributionInfo) (*wire.MsgTx, error) {
// First, we obtain a new public key script from the wallet which we'll
Expand All @@ -480,13 +480,13 @@ func (b *breachArbiter) createJusticeTx(r *retributionInfo) (*wire.MsgTx, error)
return nil, err
}

// Before creating the actual TxOut, we'll need to calculate proper fee
// Before creating the actual TxOut, we'll need to calculate the proper fee
// to attach to the transaction to ensure a timely confirmation.
// TODO(roasbeef): remove hard-coded fee
totalAmt := r.selfOutput.amt + r.revokedOutput.amt
sweepedAmt := int64(totalAmt - 5000)

// With the fee calculate, we can now create the justice transaction
// With the fee calculated, we can now create the justice transaction
// using the information gathered above.
justiceTx := wire.NewMsgTx(2)
justiceTx.AddTxOut(&wire.TxOut{
Expand All @@ -504,9 +504,9 @@ func (b *breachArbiter) createJusticeTx(r *retributionInfo) (*wire.MsgTx, error)

// Finally, using the witness generation functions attached to the
// retribution information, we'll populate the inputs with fully valid
// witnesses for both commitment outputs, and all the pending HTLC's at
// witnesses for both commitment outputs, and all the pending HTLCs at
// this state in the channel's history.
// TODO(roasbeef): handle the 2-layer HTLC's
// TODO(roasbeef): handle the 2-layer HTLCs
localWitness, err := r.selfOutput.witnessFunc(justiceTx, hashCache, 0)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion chainntnfs/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type SpendEvent struct {
Spend chan *SpendDetail // MUST be buffered.
}

// BlockEpoch represents meta-data concerning each new block connected to the
// BlockEpoch represents metadata concerning each new block connected to the
// main chain.
type BlockEpoch struct {
Height int32
Expand Down
30 changes: 15 additions & 15 deletions channeldb/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
// openChanBucket stores all the currently open channels. This bucket
// has a second, nested bucket which is keyed by a node's ID. Additionally,
// at the base level of this bucket several prefixed keys are stored which
// house channel meta-data such as total satoshis sent, number of updates
// house channel metadata such as total satoshis sent, number of updates
// etc. These fields are stored at this top level rather than within a
// node's channel bucket in order to facilitate sequential prefix scans
// to gather stats such as total satoshis received.
Expand All @@ -41,7 +41,7 @@ var (

// channelLogBucket is dedicated for storing the necessary delta state
// between channel updates required to re-construct a past state in
// order to punish a counter party attempting a non-cooperative channel
// order to punish a counterparty attempting a non-cooperative channel
// closure. A channel log bucket is created for each node and is nested
// within a node's ID bucket.
channelLogBucket = []byte("clb")
Expand Down Expand Up @@ -81,7 +81,7 @@ var (
// commitment transactions in addition to the csvDelay for both.
commitTxnsKey = []byte("ctk")

// currentHtlcKey stores the set of fully locked-in HTLC's on our
// currentHtlcKey stores the set of fully locked-in HTLCs on our
// latest commitment state.
currentHtlcKey = []byte("chk")

Expand All @@ -90,7 +90,7 @@ var (
fundingTxnKey = []byte("fsk")

// elkremStateKey stores their current revocation hash, and our elkrem
// sender, and their elkrem reciever.
// sender, and their elkrem receiver.
elkremStateKey = []byte("esk")

// deliveryScriptsKey stores the scripts for the final delivery in the
Expand All @@ -101,7 +101,7 @@ var (
// ChannelType is an enum-like type that describes one of several possible
// channel types. Each open channel is associated with a particular type as the
// channel type may determine how higher level operations are conducted such as
// fee negotiation, channel closing, the format of HTLC's, etc.
// fee negotiation, channel closing, the format of HTLCs, etc.
// TODO(roasbeef): split up per-chain?
type ChannelType uint8

Expand Down Expand Up @@ -221,7 +221,7 @@ type OpenChannel struct {
RemoteCsvDelay uint32

// Current revocation for their commitment transaction. However, since
// this the derived public key, we don't yet have the pre-image so we
// this the derived public key, we don't yet have the preimage so we
// aren't yet able to verify that it's actually in the hash chain.
TheirCurrentRevocation *btcec.PublicKey
TheirCurrentRevocationHash [32]byte
Expand Down Expand Up @@ -251,7 +251,7 @@ type OpenChannel struct {
// CreationTime is the time this channel was initially created.
CreationTime time.Time

// Htlcs is the list of active, uncleared HTLC's currently pending
// Htlcs is the list of active, uncleared HTLCs currently pending
// within the channel.
Htlcs []*HTLC

Expand Down Expand Up @@ -342,7 +342,7 @@ func (c *OpenChannel) FullSyncWithAddr(addr *net.TCPAddr) error {
}

// Next, we need to establish a (possibly) new LinkNode
// relationship for this channel. The LinkNode meta-data contains
// relationship for this channel. The LinkNode metadata contains
// reachability, up-time, and service bits related information.
// TODO(roasbeef): net info shuld be in lnwire.NetAddress
linkNode := c.Db.NewLinkNode(wire.MainNet, c.IdentityPub, addr)
Expand Down Expand Up @@ -407,7 +407,7 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *wire.MsgTx,
})
}

// HTLC is the on-disk representation of a hash time-locked contract. HTLC's
// HTLC is the on-disk representation of a hash time-locked contract. HTLCs
// are contained within ChannelDeltas which encode the current state of the
// commitment between state updates.
type HTLC struct {
Expand Down Expand Up @@ -451,7 +451,7 @@ func (h *HTLC) Copy() HTLC {

// ChannelDelta is a snapshot of the commitment state at a particular point in
// the commitment chain. With each state transition, a snapshot of the current
// state along with all non-settled HTLC's are recorded.
// state along with all non-settled HTLCs are recorded.
type ChannelDelta struct {
LocalBalance btcutil.Amount
RemoteBalance btcutil.Amount
Expand Down Expand Up @@ -514,7 +514,7 @@ func (c *OpenChannel) CommitmentHeight() (uint64, error) {
}

err := c.Db.View(func(tx *bolt.Tx) error {
// Get the bucket dedicated to storing the meta-data for open
// Get the bucket dedicated to storing the metadata for open
// channels.
openChanBucket := tx.Bucket(openChannelBucket)
if openChanBucket == nil {
Expand Down Expand Up @@ -569,7 +569,7 @@ func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelDelta, error)
// entails deleting all saved state within the database concerning this
// channel, as well as created a small channel summary for record keeping
// purposes.
// TODO(roasbeef): delete on-disk set of HTLC's
// TODO(roasbeef): delete on-disk set of HTLCs
func (c *OpenChannel) CloseChannel() error {
var b bytes.Buffer
if err := writeOutpoint(&b, c.ChanID); err != nil {
Expand Down Expand Up @@ -614,7 +614,7 @@ func (c *OpenChannel) CloseChannel() error {
}

// Now that the index to this channel has been deleted, purge
// the remaining channel meta-data from the database.
// the remaining channel metadata from the database.
if err := deleteOpenChannel(chanBucket, nodeChanBucket,
outPointBytes); err != nil {
return err
Expand Down Expand Up @@ -648,7 +648,7 @@ type ChannelSnapshot struct {

// Snapshot returns a read-only snapshot of the current channel state. This
// snapshot includes information concerning the current settled balance within
// the channel, meta-data detailing total flows, and any outstanding HTLCs.
// the channel, metadata detailing total flows, and any outstanding HTLCs.
func (c *OpenChannel) Snapshot() *ChannelSnapshot {
c.RLock()
defer c.RUnlock()
Expand All @@ -664,7 +664,7 @@ func (c *OpenChannel) Snapshot() *ChannelSnapshot {
TotalSatoshisReceived: c.TotalSatoshisReceived,
}

// Copy over the current set of HTLC's to ensure the caller can't
// Copy over the current set of HTLCs to ensure the caller can't
// mutate our internal state.
snapshot.Htlcs = make([]HTLC, len(c.Htlcs))
for i, h := range c.Htlcs {
Expand Down
8 changes: 4 additions & 4 deletions channeldb/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ func TestChannelStateTransition(t *testing.T) {
t.Fatalf("unable to save and serialize channel state: %v", err)
}

// Add some HTLC's which were added during this new state transition.
// Half of the HTLC's are incoming, while the other half are outgoing.
// Add some HTLCs which were added during this new state transition.
// Half of the HTLCs are incoming, while the other half are outgoing.
var htlcs []*HTLC
for i := uint32(0); i < 10; i++ {
var incoming bool
Expand All @@ -397,7 +397,7 @@ func TestChannelStateTransition(t *testing.T) {
htlcs = append(htlcs, htlc)
}

// Create a new channel delta which includes the above HTLC's, some
// Create a new channel delta which includes the above HTLCs, some
// balance updates, and an increment of the current commitment height.
// Additionally, modify the signature and commitment transaction.
newSequence := uint32(129498)
Expand All @@ -416,7 +416,7 @@ func TestChannelStateTransition(t *testing.T) {
t.Fatalf("unable to update commitment: %v", err)
}

// The balances, new update, the HTLC's and the changes to the fake
// The balances, new update, the HTLCs and the changes to the fake
// commitment transaction along with the modified signature should all
// have been updated.
updatedChannel, err := cdb.FetchOpenChannels(channel.IdentityPub)
Expand Down
Loading