Commit Graph

8239 Commits

Author SHA1 Message Date
Johan T. Halseth
d75feeb953
contractcourt/chain_arbitrator_test: add TestChainArbitratorRepublishCommitment
TestChainArbitratorRepulishCommitment testst that the chain arbitrator
will republish closing transactions for channels marked
CommitementBroadcast in the database at startup.
2019-09-25 14:04:43 +02:00
Johan T. Halseth
07a42971bf
lnwallet/test_utils: make CreateTestChannel return random funding op
Previously it would always be the same, resulting in multiple calls to
the method not being usabel to create more than one set of channels.
2019-09-25 14:04:43 +02:00
Johan T. Halseth
425afd28ea
contractcourt/chain_arbitrator: republish closeTx for open channels 2019-09-25 14:04:43 +02:00
Johan T. Halseth
ac0e9b6016
channeldb/channel: add BroadcastedCommitment 2019-09-25 14:04:43 +02:00
Johan T. Halseth
02b2787e44
multi: make MarkCommitmentBroadcasted take closeTx 2019-09-25 14:04:43 +02:00
Johan T. Halseth
a810092e53
channeldb/channel: make putChanStatus take optional extra closures 2019-09-25 14:04:43 +02:00
Johan T. Halseth
1974bfa4cf
peer: send channel reestablish message for borked channels
When loading active channels for a connected peer, we gather channel
sync messages for all borked channels, and send them to the peer. This
should help a peer realize that the state is irreconcible, as we have
already realized.
2019-09-25 14:04:42 +02:00
Johan T. Halseth
eb1b84c0b4
channeldb+lnwallet: make ChanSyncMsg method on OpenChannel 2019-09-25 14:04:42 +02:00
Johan T. Halseth
0122dda88a
channeldb/channel: remove unused FullSync method
The exported FullSync method is only used by test code, so we remove it
and instead use SyncPending.
2019-09-25 14:04:42 +02:00
Johan T. Halseth
b7e1bb0bf0
Merge pull request #3510 from halseth/lnwallet-rbf
Handle RBF signaling publication failures in wallet
2019-09-25 14:04:03 +02:00
Johan T. Halseth
bc8308f42f
Merge pull request #3538 from fridokus/master
trivial: fix typo in config.go
2019-09-25 08:17:21 +02:00
Johan T. Halseth
2e9452916e
lnwallet/interface_test: add RBF test cases to testPublishTransaction
Checks that we get ErrDoubleSpend as expected when publishing a
conflicting mempool transaction with the same fee as the existing one,
and that we can publish a replacement with a higher fee successfully.
2019-09-25 08:04:04 +02:00
Johan T. Halseth
61e1b48f57
lnwallet/btcwallet: check publication error types, handle replacement
error

Since btcwallet will return typed errors now, we can simplify the
matching logic in order to return ErrDoubleSpend.

In case a transaction cannot be published since it did not satisfy the
requirements for a valid replacement, return ErrDoubleSpend to indicate
it was not propagated.
2019-09-25 08:04:04 +02:00
Johan T. Halseth
96ebce6842
go mod: update btcwallet dependency
We update to a new version of btcwallet where specific errors
(ErrDoubleSpend and ErrReplacement) will be returned from
PublishTransaction.
2019-09-25 08:03:21 +02:00
Johan T. Halseth
7897b96e6a
lnwallet/interface_test: extract local utility functions
In preparation for extending the testPublishTransaction test, shorten it
by moving utility methods out of the local scope.
2019-09-25 08:01:42 +02:00
Olaoluwa Osuntokun
18f88cbd8d
Merge pull request #3440 from joostjager/buildroute
routing: add build route functionality
2019-09-24 20:24:24 -07:00
Olaoluwa Osuntokun
fa063dd45c
Merge pull request #3536 from guggero/queue-tidy
lnd+queue: specify go 1.12 in all go.mod files
2019-09-24 17:50:42 -07:00
Wilmer Paulino
811c2df75a
Merge pull request #3505 from Crypt-iQ/invoice-param-checks-0913
zpay32: check route+hop hints while decoding
2019-09-24 15:22:30 -07:00
Johan T. Halseth
9f3fbda71f
fundingmanager: remove unnecessary Peer param to sendFundingLocked 2019-09-24 21:24:40 +02:00
Johan T. Halseth
5b8e97da29
funding: update comment aboute offline peers
Since fundingLocked now are being sent reliably, the only message left
to be sent reliably is the node announcement for private channels.
2019-09-24 21:24:40 +02:00
Johan T. Halseth
9ff6de5be1
funding: add TODO for consistency check 2019-09-24 21:24:39 +02:00
Johan T. Halseth
bda0e40dad
fundingmanager: save markedOpen before marking the channel open
This commit fixes a potential issue within the fundingmanager, where
failing to write the channel opening state could cause the channel being
marked open in the DB, but the opening state not being set. On startup
this would cause the channel state machine to not be able to resume.

We fix this by saving the channel opening state _first_. This works
because saving the opening state is idempotent, and in case a channel is
found pending at startup, it will re-register for confirmation
notifications and re-do the process.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
88f5e06427
fundingmanager: unify handling of pending and non-pending channels at startup
Since the advanceFundingState now can handle pending channels, we'll
call it for both pending and non-pending channels, just making sure that
we re-initialize the channel barriers and re-publish the funding tx fro
pending channels.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
8a61af6a55
fundingmanager: make advanceFundingState handle pending channels
This commit makes advanceFundingState check whether a channel is still
pending before checking the channel opening state. This lets us call it
directly, without checking whether a channel has confirmed first.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
30614d3840
funding tests: increase epoch channel buffer
Since the initiator no longer registers for block epochs, we increase
the buffer on the mocked channel to not block during tests.
2019-09-24 21:24:39 +02:00
Johan T. Halseth
893c6cbc59
fundingmanager: make waitForFundingTimeout sync
This commit makes the waitForFundingTimeout method synchronous, and
return ErrConfirmationTimeout in case the timeout is reached.

We also simplify the internals by using waitForTimout defined earlier.
2019-09-24 21:24:35 +02:00
Johan T. Halseth
47fae26dc4
fundingmanager: define method waitForTimeout
This commit defines a new method waitForTimeout, that will be used to
listen for channels timing out. It handles a subset of what is already
handled by waitForFundingWithTimeout, but we want to break that one up
in smaller parts, and waitForTimeout is the first of these.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
ea196f6e8f
fundingmanager make waitForFundingConfirmation decrement waitgroup
Since waitForFundingConfirmation is always called in a goroutine, we
make this explicit by requireing the caller to always increment the
waitgroup before calling it.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
76857dbcdc
fundingmanager: move handleFundingConfirmation out of waitForFundingWithTimeout
Similarly to what we did in the previous commit, we move the
responsibility of marking the channel open by calling
handleFundingConfirmation out from waitForFundingWithTimeout to the
caller.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
25f6094802
fungingmanager: move handleFundingConfirmation out of waitForfundingConfirmation
This commit moves the handling of a funding confirmation out of
waitForFundingConfirmation, and instead let the caller handle marking
the channel opened.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
b51b76b469
fundingmanager: extract opening logic into new method handleFundingConfirmation
This commit moves the opening logic found within
waitForFundingConfirmation into a new method handleFundingConfirmation.
This will make it easier to later break up waitForFundingConfirmation,
and avoid code duplication.
2019-09-24 21:24:34 +02:00
Johan T. Halseth
b2a7e42f44
fundingmanager: commit to new states in stateStep
This commit moves the saving of the new channelOpeningState to the
stateStep method.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
49bbf0eb61
fundingmanager: call advanceFundingState in place of handleFundingConfirmation
This commit removes the handleFundingConfirmation method, and instead
hands the newly confirmed channel of to advanceFundingState, which will
take the channel through the rest of the channel opening flow.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
e274c2fb7c
fundingmanager: call advanceFundingState from handleFundingSigned
Since the advanceFundingSigned now can resume a channel from any state,
we resue the logic in handleFundingSigned instead of manually executing
each step of the funding flow.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
cbf1fe6bb1
fundingmanager: define stateStep, make advanceFundingState sync
This commit make the advanceFundingStateMethod synchronous. It will now
query the database for a channel's opening state, and call the method
stateStep until the channel has finished the opening procedure.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
08cb313934
fundingmanager: move startup state check into advanceFundingState method
This commit extracts the funding state check we do at startup into a new
method advanceFundingState. In later commits we will modify this method
to work for all funding state machine flows, not only on restart.
2019-09-24 21:24:33 +02:00
Johan T. Halseth
e189f78567
fundingmanager: remove dead code
Pending channels will never have a channel opening state, and hence will
never be pending.
2019-09-24 21:24:32 +02:00
Johan T. Halseth
5d1a7b0e7d
funding test: correctly send remote peer on connected chan 2019-09-24 21:24:32 +02:00
Johan T. Halseth
0db9045e11
funding test: mark assert methods t.Helper 2019-09-24 21:24:32 +02:00
fridokus
b3669d71e3 Fix typo in config.go 2019-09-24 14:49:59 +02:00
nsa
0f6e11c35f
zpay32: check invoice length while decoding
This commit checks that the size of the bech32 encoded invoice is not
greater than 7092 bytes, which is the maximum number of bytes that can
fit into a QR code. This mitigates a potential DoS vector where an attacker
could craft a very large bech32 invoice string containing an absurd amount
of route and/or hop hints. If sent to an application that processes
payment requests, this would allocate a burdensome amount of memory
due to the public key parsing for each route/hop hint.

For a 1.7MB payment request, this yielded about 38MB in allocations
from just parsing public keys:

```
   45.51MB  7.31% 92.07%    45.51MB  7.31%  math/big.nat.make
   25.50MB  4.09% 96.16%    25.50MB  4.09%  github.com/lightningnetwork/lnd/zpay32.bech32VerifyChecksum
       1MB  0.16% 96.32%    39.50MB  6.34%  github.com/lightningnetwork/lnd/zpay32.parseRouteHint
       1MB  0.16% 96.48%    33.50MB  5.38%  github.com/btcsuite/btcd/btcec.decompressPoint
    0.50MB  0.08% 96.56%     7.50MB  1.20%  crypto/elliptic.(*CurveParams).doubleJacobian
    0.50MB  0.08% 96.64%       38MB  6.10%  github.com/btcsuite/btcd/btcec.ParsePubKey
         0     0% 96.64%       12MB  1.93%  crypto/ecdsa.Verify
         0     0% 96.64%        8MB  1.28%  crypto/elliptic.(*CurveParams).ScalarBaseMult
         0     0% 96.64%       12MB  1.93%  crypto/elliptic.(*CurveParams).ScalarMult
```

With this change, memory usage will be far lower as decoding will exit
early with an error if the invoice is too large.
2019-09-24 06:21:27 -04:00
Joost Jager
03d33cbd6b
lncli: update SendToRoute to also parse new route format 2019-09-24 10:00:48 +02:00
Joost Jager
6328b2e989
lncli: add BuildRoute function 2019-09-24 10:00:46 +02:00
Joost Jager
299821152a
routing+routerrpc: add BuildRoute function 2019-09-24 10:00:44 +02:00
Oliver Gugger
c01f9f043d
lnd: pin go version to 1.12 in go.mod 2019-09-24 09:18:21 +02:00
Olaoluwa Osuntokun
9b1ecbd3fa
Merge pull request #2485 from halseth/error-codes-dont-send
[lnwire+funding] Don't send ErrorCode on wire
2019-09-23 17:50:27 -07:00
Olaoluwa Osuntokun
9da8951cf0
Merge pull request #3523 from joostjager/enable-update-max-htlc
multi: enable max htlc update
2019-09-23 17:42:22 -07:00
Oliver Gugger
976c996fda
queue: run go mod tidy 2019-09-23 15:11:20 +02:00
Vadym Popov
850085782a
rpcserver: add BlockHeight param to SubscribeTransactions stream 2019-09-23 14:30:44 +03:00
Valentine Wallace
5aefe8bc70
lncli: allow users to update max HTLC channel policies
In this commit, we enable callers of UpdateChannelPolicy to
specify their desired max HTLC forwarding policy for one or
multiple channels over lncli.
2019-09-23 13:07:14 +02:00