multi: Fix various typos.

This commit is contained in:
Jim Posen 2017-09-25 11:25:58 -07:00 committed by Olaoluwa Osuntokun
parent 4b883b9899
commit a13ad0a339
11 changed files with 46 additions and 58 deletions

@ -262,7 +262,7 @@ func (b *breachArbiter) Start() error {
}
// Additionally, we'll also want to watch any pending close or force
// close transactions to we can properly mark them as resolved in the
// close transactions so we can properly mark them as resolved in the
// database.
if err := b.watchForPendingCloseConfs(currentHeight); err != nil {
return err

@ -125,9 +125,6 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
}
}
var obsfucator [6]byte
copy(obsfucator[:], key[:])
localCfg := ChannelConfig{
ChannelConstraints: ChannelConstraints{
DustLimit: btcutil.Amount(rand.Int63()),

@ -107,7 +107,7 @@ func TestInvoiceWorkflow(t *testing.T) {
"instead %v", err)
}
// Attempt to look up a non-existant invoice, this should also fail but
// Attempt to look up a non-existent invoice, this should also fail but
// with a "not found" error.
var fakeHash [32]byte
if _, err := db.LookupInvoice(fakeHash); err != ErrInvoiceNotFound {

@ -164,9 +164,6 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
return nil, nil, nil, err
}
var obsfucator [lnwallet.StateHintSize]byte
copy(obsfucator[:], aliceFirstRevoke[:])
estimator := &lnwallet.StaticFeeEstimator{
FeeRate: 24,
Confirmation: 6,

@ -178,7 +178,7 @@ type PaymentDescriptor struct {
// chain, then this value will be -1.
localOutputIndex int32
// remoteOutputIndex is the output index of this HTLc output in the
// remoteOutputIndex is the output index of this HTLC output in the
// commitment transaction of the remote node.
//
// NOTE: If the output is dust from the PoV of the remote commitment
@ -306,7 +306,7 @@ type commitment struct {
// the local commitment state. We use this map in order to locate the
// details needed to validate an HTLC signature while iterating of the
// outputs int he local commitment view.
outgoignHTLCIndex map[int32]*PaymentDescriptor
outgoingHTLCIndex map[int32]*PaymentDescriptor
incomingHTLCIndex map[int32]*PaymentDescriptor
}
@ -406,7 +406,7 @@ func (c *commitment) populateHtlcIndexes(ourCommitTx bool,
// must keep this index so we can validate the HTLC signatures sent to
// us.
dups := make(map[PaymentHash][]int32)
c.outgoignHTLCIndex = make(map[int32]*PaymentDescriptor)
c.outgoingHTLCIndex = make(map[int32]*PaymentDescriptor)
c.incomingHTLCIndex = make(map[int32]*PaymentDescriptor)
// populateIndex is a helper function that populates the necessary
@ -446,7 +446,7 @@ func (c *commitment) populateHtlcIndexes(ourCommitTx bool,
if incoming {
c.incomingHTLCIndex[htlc.localOutputIndex] = htlc
} else {
c.outgoignHTLCIndex[htlc.localOutputIndex] = htlc
c.outgoingHTLCIndex[htlc.localOutputIndex] = htlc
}
// Otherwise, this is there remote party's commitment
@ -797,9 +797,9 @@ type LightningChannel struct {
// Capcity is the total capacity of this channel.
Capacity btcutil.Amount
// stateHintObsfucator is a 48-bit state hint that's used to obfsucate
// stateHintObfuscator is a 48-bit state hint that's used to obfsucate
// the current state number on the commitment transactions.
stateHintObsfucator [StateHintSize]byte
stateHintObfuscator [StateHintSize]byte
// currentHeight is the current height of our local commitment chain.
// This is also the same as the number of updates to the channel we've
@ -929,7 +929,7 @@ func NewLightningChannel(signer Signer, events chainntnfs.ChainNotifier,
signer: signer,
channelEvents: events,
feeEstimator: fe,
stateHintObsfucator: stateHint,
stateHintObfuscator: stateHint,
currentHeight: state.NumUpdates,
remoteCommitChain: newCommitmentChain(state.NumUpdates),
localCommitChain: newCommitmentChain(state.NumUpdates),
@ -1142,7 +1142,7 @@ type BreachRetribution struct {
// according to the remote party's dust limit.
RemoteOutputSignDesc *SignDescriptor
// RemoteOutpoint is the output of the output paying to the remote
// RemoteOutpoint is the outpoint of the output paying to the remote
// party within the breach transaction.
RemoteOutpoint wire.OutPoint
@ -1394,8 +1394,8 @@ func (lc *LightningChannel) closeObserver(channelCloseNtfn *chainntnfs.SpendEven
// Decode the state hint encoded within the commitment transaction to
// determine if this is a revoked state or not.
obsfucator := lc.stateHintObsfucator
broadcastStateNum := GetStateNumHint(commitTxBroadcast, obsfucator)
obfuscator := lc.stateHintObfuscator
broadcastStateNum := GetStateNumHint(commitTxBroadcast, obfuscator)
currentStateNum := lc.currentHeight
@ -1975,7 +1975,7 @@ func (lc *LightningChannel) createCommitmentTx(c *commitment,
// Set the state hint of the commitment transaction to facilitate
// quickly recovering the necessary penalty state in the case of an
// uncooperative broadcast.
err = SetStateNumHint(commitTx, c.height, lc.stateHintObsfucator)
err = SetStateNumHint(commitTx, c.height, lc.stateHintObfuscator)
if err != nil {
return err
}
@ -2017,8 +2017,8 @@ func (lc *LightningChannel) evaluateHTLCView(view *htlcView, ourBalance,
continue
}
// If we're settling in inbound HTLC, and it hasn't been
// processed, yet, the increment our state tracking the total
// If we're settling an inbound HTLC, and it hasn't been
// processed yet, then increment our state tracking the total
// number of satoshis we've received within the channel.
if entry.EntryType == Settle && !remoteChain &&
entry.removeCommitHeightLocal == 0 {
@ -2573,8 +2573,8 @@ func genHtlcSigValidationJobs(localCommitmentView *commitment,
// Otherwise, if this is an outgoing HTLC, then we'll need to
// generate a timeout transaction so we can verify the
// signature presented.
case localCommitmentView.outgoignHTLCIndex[outputIndex] != nil:
htlc := localCommitmentView.outgoignHTLCIndex[outputIndex]
case localCommitmentView.outgoingHTLCIndex[outputIndex] != nil:
htlc := localCommitmentView.outgoingHTLCIndex[outputIndex]
sigHash = func() ([]byte, error) {
op := wire.OutPoint{
@ -2972,7 +2972,7 @@ func (lc *LightningChannel) NextRevocationKey() (*btcec.PublicKey, error) {
}
// InitNextRevocation inserts the passed commitment point as the _next_
// revocation to be used when created a new commitment state for the remote
// revocation to be used when creating a new commitment state for the remote
// party. This function MUST be called before the channel can accept or propose
// any new states.
func (lc *LightningChannel) InitNextRevocation(revKey *btcec.PublicKey) error {
@ -3089,7 +3089,7 @@ func (lc *LightningChannel) ReceiveHTLCSettle(preimage [32]byte, htlcIndex uint6
paymentHash := sha256.Sum256(preimage[:])
htlc := lc.localUpdateLog.lookupHtlc(htlcIndex)
if htlc == nil {
return fmt.Errorf("non existant log entry")
return fmt.Errorf("non-existent log entry")
}
if !bytes.Equal(htlc.RHash[:], paymentHash[:]) {

@ -287,9 +287,6 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan
return nil, nil, nil, err
}
var obsfucator [StateHintSize]byte
copy(obsfucator[:], aliceFirstRevoke[:])
estimator := &StaticFeeEstimator{24, 6}
feePerKw := btcutil.Amount(estimator.EstimateFeePerWeight(1) * 1000)
commitFee := calcStaticFee(0)

@ -438,7 +438,7 @@ func (r *ChannelReservation) FinalFundingTx() *wire.MsgTx {
// FundingOutpoint returns the outpoint of the funding transaction.
//
// NOTE: The pointer returned will only be set once the .ProcesContribution()
// NOTE: The pointer returned will only be set once the .ProcessContribution()
// method is called in the case of the initiator of a single funder workflow,
// and after the .CompleteReservationSingle() method is called in the case of
// a responder to a single funder workflow.

@ -347,7 +347,7 @@ func senderHtlcSpendRedeem(signer Signer, signDesc *SignDescriptor,
// HTLC to activate the time locked covenant clause of a soon to be expired
// HTLC. This script simply spends the multi-sig output using the
// pre-generated HTLC timeout transaction.
func senderHtlcSpendTimeout(reciverSig []byte, signer Signer,
func senderHtlcSpendTimeout(receiverSig []byte, signer Signer,
signDesc *SignDescriptor, htlcTimeoutTx *wire.MsgTx) (wire.TxWitness, error) {
sweepSig, err := signer.SignOutputRaw(htlcTimeoutTx, signDesc)
@ -361,7 +361,7 @@ func senderHtlcSpendTimeout(reciverSig []byte, signer Signer,
// original OP_CHECKMULTISIG.
witnessStack := wire.TxWitness(make([][]byte, 5))
witnessStack[0] = nil
witnessStack[1] = append(reciverSig, byte(txscript.SigHashAll))
witnessStack[1] = append(receiverSig, byte(txscript.SigHashAll))
witnessStack[2] = append(sweepSig, byte(txscript.SigHashAll))
witnessStack[3] = nil
witnessStack[4] = signDesc.WitnessScript
@ -1026,7 +1026,7 @@ func SingleTweakBytes(commitPoint, basePoint *btcec.PublicKey) []byte {
//
// tweakPub := basePoint + sha256(commitPoint || basePoint) * G
// := G*k + sha256(commitPoint || basePoint)*G
// := G*(k + sha256(commitPoint || basePoint)
// := G*(k + sha256(commitPoint || basePoint))
//
// Therefore, if a party possess the value k, the private key of the base
// point, then they are able to derive the private key by computing: compute
@ -1036,8 +1036,8 @@ func SingleTweakBytes(commitPoint, basePoint *btcec.PublicKey) []byte {
//
// Where N is the order of the sub-group.
//
// The rational for tweaking all public keys used within the commitment
// contracts are to ensure that all keys are properly delinearized to avoid any
// The rationale for tweaking all public keys used within the commitment
// contracts is to ensure that all keys are properly delinearized to avoid any
// funny business when jointly collaborating to compute public and private
// keys. Additionally, the use of the per commitment point ensures that each
// commitment state houses a unique set of keys which is useful when creating
@ -1214,7 +1214,7 @@ func DeriveRevocationRoot(derivationRoot *btcec.PrivateKey,
// obfuscater is XOR'd against the state number in order to hide the exact
// state number from the PoV of outside parties.
func SetStateNumHint(commitTx *wire.MsgTx, stateNum uint64,
obsfucator [StateHintSize]byte) error {
obfuscator [StateHintSize]byte) error {
// With the current schema we are only able able to encode state num
// hints up to 2^48. Therefore if the passed height is greater than our
@ -1234,7 +1234,7 @@ func SetStateNumHint(commitTx *wire.MsgTx, stateNum uint64,
// commitment transaction in the case that either commitment
// transaction is broadcast directly on chain.
var obfs [8]byte
copy(obfs[2:], obsfucator[:])
copy(obfs[2:], obfuscator[:])
xorInt := binary.BigEndian.Uint64(obfs[:])
stateNum = stateNum ^ xorInt
@ -1249,15 +1249,15 @@ func SetStateNumHint(commitTx *wire.MsgTx, stateNum uint64,
// GetStateNumHint recovers the current state number given a commitment
// transaction which has previously had the state number encoded within it via
// setStateNumHint and a shared obsfucator.
// setStateNumHint and a shared obfuscator.
//
// See setStateNumHint for further details w.r.t exactly how the state-hints
// are encoded.
func GetStateNumHint(commitTx *wire.MsgTx, obsfucator [StateHintSize]byte) uint64 {
func GetStateNumHint(commitTx *wire.MsgTx, obfuscator [StateHintSize]byte) uint64 {
// Convert the obfuscater into a uint64, this will be used to
// de-obfuscate the final recovered state number.
var obfs [8]byte
copy(obfs[2:], obsfucator[:])
copy(obfs[2:], obfuscator[:])
xorInt := binary.BigEndian.Uint64(obfs[:])
// Retrieve the state hint from the sequence number and locktime

@ -1047,8 +1047,8 @@ func TestCommitTxStateHint(t *testing.T) {
},
}
var obsfucator [StateHintSize]byte
copy(obsfucator[:], testHdSeed[:StateHintSize])
var obfuscator [StateHintSize]byte
copy(obfuscator[:], testHdSeed[:StateHintSize])
timeYesterday := uint32(time.Now().Unix() - 24*60*60)
for _, test := range stateHintTests {
@ -1062,7 +1062,7 @@ func TestCommitTxStateHint(t *testing.T) {
for i := test.from; i <= test.to; i++ {
stateNum := uint64(i)
err := SetStateNumHint(commitTx, stateNum, obsfucator)
err := SetStateNumHint(commitTx, stateNum, obfuscator)
if err != nil && !test.shouldFail {
t.Fatalf("unable to set state num %v: %v", i, err)
} else if err == nil && test.shouldFail {
@ -1088,7 +1088,7 @@ func TestCommitTxStateHint(t *testing.T) {
}
}
extractedStateNum := GetStateNumHint(commitTx, obsfucator)
extractedStateNum := GetStateNumHint(commitTx, obfuscator)
if extractedStateNum != stateNum && !test.shouldFail {
t.Fatalf("state number mismatched, expected %v, got %v",
stateNum, extractedStateNum)

@ -614,7 +614,7 @@ func (l *LightningWallet) handleFundingCancelRequest(req *fundingReserveCancelMs
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
if !ok {
// TODO(roasbeef): make new error, "unkown funding state" or something
req.err <- fmt.Errorf("attempted to cancel non-existant funding state")
req.err <- fmt.Errorf("attempted to cancel non-existent funding state")
return
}
@ -692,7 +692,7 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
l.limboMtx.Unlock()
if !ok {
req.err <- fmt.Errorf("attempted to update non-existant funding state")
req.err <- fmt.Errorf("attempted to update non-existent funding state")
return
}
@ -822,11 +822,11 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
}
// With both commitment transactions constructed, generate the state
// obsfucator then use it to encode the current state number within
// obfuscator then use it to encode the current state number within
// both commitment transactions.
var stateObsfucator [StateHintSize]byte
var stateObfuscator [StateHintSize]byte
if chanState.ChanType == channeldb.SingleFunder {
stateObsfucator = deriveStateHintObfuscator(
stateObfuscator = deriveStateHintObfuscator(
ourContribution.PaymentBasePoint,
theirContribution.PaymentBasePoint,
)
@ -835,18 +835,18 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
theirSer := theirContribution.PaymentBasePoint.SerializeCompressed()
switch bytes.Compare(ourSer, theirSer) {
case -1:
stateObsfucator = deriveStateHintObfuscator(
stateObfuscator = deriveStateHintObfuscator(
ourContribution.PaymentBasePoint,
theirContribution.PaymentBasePoint,
)
default:
stateObsfucator = deriveStateHintObfuscator(
stateObfuscator = deriveStateHintObfuscator(
theirContribution.PaymentBasePoint,
ourContribution.PaymentBasePoint,
)
}
}
err = initStateHints(ourCommitTx, theirCommitTx, stateObsfucator)
err = initStateHints(ourCommitTx, theirCommitTx, stateObfuscator)
if err != nil {
req.err <- err
return
@ -1106,7 +1106,7 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
pendingReservation, ok := l.fundingLimbo[req.pendingFundingID]
l.limboMtx.RUnlock()
if !ok {
req.err <- fmt.Errorf("attempted to update non-existant funding state")
req.err <- fmt.Errorf("attempted to update non-existent funding state")
req.completeChan <- nil
return
}
@ -1136,10 +1136,10 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
// With both commitment transactions constructed, we can now use the
// generator state obfuscator to encode the current state number within
// both commitment transactions.
stateObsfucator := deriveStateHintObfuscator(
stateObfuscator := deriveStateHintObfuscator(
pendingReservation.theirContribution.PaymentBasePoint,
pendingReservation.ourContribution.PaymentBasePoint)
err = initStateHints(ourCommitTx, theirCommitTx, stateObsfucator)
err = initStateHints(ourCommitTx, theirCommitTx, stateObfuscator)
if err != nil {
req.err <- err
req.completeChan <- nil
@ -1345,7 +1345,7 @@ func deriveStateHintObfuscator(key1, key2 *btcec.PublicKey) [StateHintSize]byte
}
// initStateHints properly sets the obsfucated state hints on both commitment
// transactions using the passed obsfucator.
// transactions using the passed obfuscator.
func initStateHints(commit1, commit2 *wire.MsgTx,
obfuscator [StateHintSize]byte) error {

@ -134,9 +134,6 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
return nil, nil, nil, nil, err
}
var obsfucator [lnwallet.StateHintSize]byte
copy(obsfucator[:], aliceFirstRevoke[:])
estimator := &lnwallet.StaticFeeEstimator{FeeRate: 50}
feePerKw := btcutil.Amount(estimator.EstimateFeePerWeight(1) * 1000)
aliceChannelState := &channeldb.OpenChannel{