diff --git a/fundingmanager.go b/fundingmanager.go index eb269c35..10e462e1 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -827,7 +827,7 @@ func (f *fundingManager) handleErrorGenericMsg(fmsg *fundingErrorMsg) { "exceeded -- unable to cancel reservation: %v", err) } else { - resCtx.err <- grpc.Errorf(OpenChannelFundingError, + resCtx.err <- grpc.Errorf(ErrorMaxPendingChannels, "unable to create channel, max number of "+ "pending channels exceeded.") } diff --git a/htlcswitch.go b/htlcswitch.go index 86066b39..b176e592 100644 --- a/htlcswitch.go +++ b/htlcswitch.go @@ -222,7 +222,7 @@ func (h *htlcSwitch) SendHTLC(htlcPkt *htlcPacket) error { // their links. The duties of the forwarder are similar to that of a network // switch, in that it facilitates multi-hop payments by acting as a central // messaging bus. The switch communicates will active links to create, manage, -// and tearn down active onion routed payments.Each active channel is modeled +// and tear down active onion routed payments.Each active channel is modeled // as networked device with meta-data such as the available payment bandwidth, // and total link capacity. func (h *htlcSwitch) htlcForwarder() { @@ -292,7 +292,7 @@ out: switch wireMsg := pkt.msg.(type) { // A link has just forwarded us a new HTLC, therefore // we initiate the payment circuit within our internal - // staate so we can properly forward the ultimate + // state so we can properly forward the ultimate // settle message. case *lnwire.HTLCAddRequest: // Create the two ends of the payment circuit @@ -328,7 +328,7 @@ out: // With the circuit initiated, send the htlcPkt // to the clearing link within the circuit to - // continue propagating the HTLC accross the + // continue propagating the HTLC across the // network. circuit.clear.linkChan <- &htlcPacket{ msg: wireMsg, diff --git a/lnd_test.go b/lnd_test.go index f66d757d..d90829e6 100644 --- a/lnd_test.go +++ b/lnd_test.go @@ -885,8 +885,8 @@ func testMaxPendingChannels(net *networkHarness, t *harnessTest) { _, err = net.OpenChannel(ctx, net.Alice, carol, amount, 1) if err == nil { t.Fatalf("error wasn't received") - } else if grpc.Code(err) != OpenChannelFundingError { - t.Fatalf("not expected error was received : %v", err) + } else if grpc.Code(err) != ErrorMaxPendingChannels { + t.Fatalf("not expected error was received: %v", err) } // For now our channels are in pending state, in order to not diff --git a/lnwallet/channel.go b/lnwallet/channel.go index 8de7f8ea..1928a8ba 100644 --- a/lnwallet/channel.go +++ b/lnwallet/channel.go @@ -1014,7 +1014,7 @@ func (lc *LightningChannel) evaluateHTLCView(view *htlcView, ourBalance, // processAddEntry evaluates the effect of an add entry within the HTLC log. // If the HTLC hasn't yet been committed in either chain, then the height it -// was commited is updated. Keeping track of this inclusion height allows us to +// was committed is updated. Keeping track of this inclusion height allows us to // later compact the log once the change is fully committed in both chains. func processAddEntry(htlc *PaymentDescriptor, ourBalance, theirBalance *btcutil.Amount, nextHeight uint64, remoteChain bool, isIncoming bool) { @@ -1165,7 +1165,7 @@ func (lc *LightningChannel) SignNextCommitment() ([]byte, uint32, error) { // the remote party. This method will should be called in response to the // remote party initiating a new change, or when the remote party sends a // signature fully accepting a new state we've initiated. If we are able to -// succesfully validate the signature, then the generated commitment is added +// successfully validate the signature, then the generated commitment is added // to our local commitment chain. Once we send a revocation for our prior // state, then this newly added commitment becomes our current accepted channel // state. @@ -1992,7 +1992,7 @@ func CreateCommitTx(fundingOutput *wire.TxIn, selfKey, theirKey *btcec.PublicKey } // Next, we create the script paying to them. This is just a regular - // P2WKH output, without any added CSV delay. + // P2WPKH output, without any added CSV delay. theirWitnessKeyHash, err := commitScriptUnencumbered(theirKey) if err != nil { return nil, err diff --git a/lnwallet/channel_test.go b/lnwallet/channel_test.go index fd137f9a..580e0622 100644 --- a/lnwallet/channel_test.go +++ b/lnwallet/channel_test.go @@ -135,7 +135,7 @@ func initRevocationWindows(chanA, chanB *LightningChannel, windowSize int) error return nil } -// forceStateTransition executes the neccessary interaction between the two +// forceStateTransition executes the necessary interaction between the two // commitment state machines to transition to a new state locking in any // pending updates. func forceStateTransition(chanA, chanB *LightningChannel) error { @@ -320,7 +320,7 @@ func createTestChannels(revocationWindow int) (*LightningChannel, *LightningChan // TestSimpleAddSettleWorkflow tests a simple channel scenario wherein the // local node (Alice in this case) creates a new outgoing HTLC to bob, commits // this change, then bob immediately commits a settlement of the HTLC after the -// initial add is fully commited in both commit chains. +// initial add is fully committed in both commit chains. // TODO(roasbeef): write higher level framework to exercise various states of // the state machine // * DSL language perhaps? @@ -389,7 +389,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) { } // Alice then processes this revocation, sending her own recovation for // her prior commitment transaction. Alice shouldn't have any HTLC's to - // forward since she's sending anoutgoing HTLC. + // forward since she's sending an outgoing HTLC. if htlcs, err := aliceChannel.ReceiveRevocation(bobRevocation); err != nil { t.Fatalf("alice unable to rocess bob's revocation: %v", err) } else if len(htlcs) != 0 { @@ -441,7 +441,7 @@ func TestSimpleAddSettleWorkflow(t *testing.T) { } // Alice's revocation window should now be one beyond the size of the - // intial window. Same goes for Bob. + // initial window. Same goes for Bob. if aliceChannel.revocationWindowEdge != 4 { t.Fatalf("alice revocation window not incremented, is %v should be %v", aliceChannel.revocationWindowEdge, 4) diff --git a/lnwallet/script_utils.go b/lnwallet/script_utils.go index 0e578270..be432393 100644 --- a/lnwallet/script_utils.go +++ b/lnwallet/script_utils.go @@ -340,7 +340,7 @@ func senderHtlcSpendTimeout(commitScript []byte, outputAmt btcutil.Amount, // // Possible Input Scripts: // RECVR: 1 -// REVOK: 1 0 +// REVOK: 0 1 // SENDR: 0 0 // // OP_IF @@ -358,7 +358,7 @@ func senderHtlcSpendTimeout(commitScript []byte, outputAmt btcutil.Amount, // OP_EQUALVERIFY // OP_ELSE // //Refund -// OP_CHECKLOCKTIMEVERIFY OP_DROP +// OP_CHECKLOCKTIMEVERIFY OP_DROP // OP_ENDIF // OP_CHECKSIG // OP_ENDIF diff --git a/lnwire/error_generic.go b/lnwire/error_generic.go index 0c49dc82..d0b6fe88 100644 --- a/lnwire/error_generic.go +++ b/lnwire/error_generic.go @@ -15,6 +15,10 @@ const ( // ErrorMaxPendingChannels is returned by remote peer when the number // of active pending channels exceeds their maximum policy limit. ErrorMaxPendingChannels ErrorCode = 1 + + // ErrorMaxTransactionWeight is returned by remote peer when transaction + // weight exceed maximum allowable value. + ErrorMaxTransactionWeight ErrorCode = 2 ) // ErrorGeneric represents a generic error bound to an exact channel. The diff --git a/peer.go b/peer.go index 3119308d..0d8fe8f8 100644 --- a/peer.go +++ b/peer.go @@ -977,7 +977,7 @@ type commitmentState struct { logCommitTimer <-chan time.Time // switchChan is a channel used to send packets to the htlc switch for - // fowarding. + // forwarding. switchChan chan<- *htlcPacket // sphinx is an instance of the Sphinx onion Router for this node. The diff --git a/rpcserver.go b/rpcserver.go index 1e716a87..35ee44e5 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -29,7 +29,9 @@ import ( ) const ( - OpenChannelFundingError = 100 + // ErrorMaxPendingChannels is an additional gRPC error, which is + // returned if max pending channel restriction was violated. + ErrorMaxPendingChannels = 100 ) var (