Commit Graph
100 Commits
Author SHA1 Message Date
eugene 8b463fbc2b lnd: optionally listen on localhost for better security
The --profile flag now accepts both a port and a host:port string.
If profile is set to a port, then pprof debugging information will
be served over localhost. Otherwise, we will attempt to serve pprof
information on the specified host:port (if we are allowed to listen
on it.)

We default to the safe option as if the port is connectable, anybody
can connect and see debugging information.

See: https://mmcloughlin.com/posts/your-pprof-is-showing
2021-04-01 12:14:24 -04:00
Eugene 6dca38c561 Merge pull request #5073 from Crypt-iQ/writemessage_03042021
lnwire: remove MaxPayloadLength from lnwire.Message interface
2021-03-09 04:50:40 -08:00
eugene 99a7271289 lntest/itest+lnwallet: add legacy chanrestore test
The test makes use of a nextRevocationProducer that is only used during
integration tests.
2021-03-05 12:49:18 -05:00
eugene bb84f0ebc8 multi: store KeyLocator in OpenChannel, use ECDH
This commit adds a RevocationKeyLocator field to the OpenChannel
struct so that the SCB derivation doesn't have to brute-force the
sha chain root key and match the public key. ECDH derivation is now
used to derive the key instead of regular private key derivation a
la DerivePrivKey. The legacy can still be used to recover old
channels.
2021-03-05 12:49:18 -05:00
eugene 986e69c81b channeldb: add KeyLocator Record 2021-03-05 12:49:16 -05:00
eugene 7ff04d8bad lnwire: remove MaxPayloadLength from Message interface
Removes the MaxPayloadLength function from the Message interface
and checks that each message payload is not greater than MaxMsgBody.
Since all messages are now allowed to be 65535 bytes in size, the
MaxPayloadLength is no longer needed.
2021-03-04 16:48:10 -05:00
eugene bc238ee84c lnd+lnwallet: make capacity check stricter by adding fee
Also patches breacharbiter tests by using the correct commitment
fee and balances.
2021-02-22 12:07:21 -05:00
eugene 80eb5dbece lncfg: add isIPv6Host helper to force v6 addrs through system resolver
With this commit, if --tor.active is specified, then IPv6 addresses
will no longer go through the connmgr.TorLookupIP function from btcd.
This function does not have proper IPv6 support and would fail with
the error "tor general error". Instead, use the system resolver.
2021-02-05 15:37:39 -05:00
eugene 1c407f4026 htlcswitch: reestablish unit tests 2021-02-03 16:47:47 -05:00
eugene 9b09895bde channeldb+lnwallet: lastWasRevokeKey to store last sent rev/sig 2021-02-03 16:43:04 -05:00
eugene f8b98a1d3b lntest/channels: introduce subpackage to deduplicate static structs 2021-01-25 14:04:39 -05:00
Eugene e0439965bb Merge pull request #4757 from Crypt-iQ/fmgr_1109
funding: move Manager to own package
2020-12-17 11:43:12 -05:00
eugene dcdf36f410 lnd+funding: move Manager to funding, change references 2020-12-17 10:45:05 -05:00
eugene e7e872f19a lnd: remove Manager's stop method, linter complaints 2020-12-17 09:50:55 -05:00
eugene 936227798a lnd: remove openChanReq, call InitFundingWorkflow with InitFundingMsg 2020-12-17 09:50:48 -05:00
eugene e85baea1b3 lnd: export InitFundingMsg 2020-12-17 09:36:34 -05:00
eugene 105e961b20 lnd: export Manager's InitFundingWorkflow method 2020-12-17 09:36:34 -05:00
eugene 1b84d07c4d lnd+funding: register funding logger 2020-12-17 09:36:34 -05:00
eugene 6a209bbdaf lnd: export Manager, NewFundingManager 2020-12-17 09:36:34 -05:00
eugene f43fd32daf lnd: remove PendingChannels call from fundingManager 2020-12-17 09:36:34 -05:00
eugene 9c72dd9eba funding+peer: rename Manager interface to Controller 2020-12-17 09:36:34 -05:00
eugene caa0f5da6a multi: move and export funding-related vars to funding package
Also moves the lnd global MaxFundingAmount to server.go
2020-12-17 09:36:34 -05:00
eugene f6524aabcb lnd+funding: use funding.WriteOutpoint instead of lnd version
This commit duplicates the utxonursery's writeOutpoint function
in the funding package so that when the rest of the fundingmanager
code is moved, it can use the WriteOutpoint function for its
channel opening state data.
2020-12-17 09:36:34 -05:00
eugene 61e0f67edf funding: rename from fmgr, change references 2020-12-17 09:36:34 -05:00
eugene f4593f95f4 channeldb/migration20: TestMigrateOutpointIndex 2020-12-10 17:37:59 -08:00
eugene 204b6c51cf channeldb: MigrateOutpointIndex, store indexStatus in outpoint index
Adds an outpoint index that stores a tlv stream. Currently the stream
only contains the outpoint's indexStatus. This should cut down on
big bbolt transactions in several places throughout the codebase.
2020-12-10 17:37:59 -08:00
eugene 81783d682b make: add zpay32 to fuzz_flags.mk 2020-11-30 07:59:41 -05:00
Eugene 225390ab5b Merge pull request #4487 from Crypt-iQ/cc_pkg_0723
chainreg: new chainreg package
2020-10-30 06:07:26 -04:00
Eugene 9571088756 lnd: log errors for ChainControl when shutting down 2020-10-29 15:24:17 -04:00
Eugene bebe258e2d chainregistry+lnd: moving chainregistry+chainparams to new package 2020-10-29 15:24:14 -04:00
Eugene 46ef212de4 lnd+lncfg: move normalizeNetwork to lncfg 2020-10-29 15:20:00 -04:00
Eugene 4d238cfa2f lnd: export ChainControl, ChainRegistry 2020-10-29 15:20:00 -04:00
Eugene cbdea57d52 chainregistry.go: export default values
This is needed so that git sees a subsequent commit as a code move.
2020-10-29 15:19:58 -04:00
Eugene f4fe76aaf1 chainreg: add Config, move chainparams.go
Creates a Config that initializes the chainregistry struct in the
lnd package. Also moves all of chainparams.go to the chainreg
package.
2020-10-29 15:19:58 -04:00
Eugene 933b959aa8 chainreg: export ChainCode to new pkg
Moves chainCode from the lnd package to the chainreg package,
where it is exported and can be used by other packages.
2020-10-29 15:19:57 -04:00
eugene afb6ad295e lnd: move initNeutrinoBackend to lnd.go 2020-10-29 15:19:56 -04:00
Eugene 426db548dd Merge pull request #4651 from Crypt-iQ/zpay32_fuzz
fuzz/zpay32: add Decode/Encode fuzz tests.
2020-10-22 10:23:24 -04:00
eugene bbe85f3c16 fuzz/zpay32: add Decode/Encode fuzz tests.
These can be expanded on in the future. Encoding is currently done
with a static key for test determinism.
2020-10-21 06:42:54 -04:00
Eugene 9e75c3eade Merge pull request #4682 from Crypt-iQ/fuzz_ret_1009
fuzz: change return values to 1 rather than 0 or -1
2020-10-14 16:07:54 -04:00
eugene f82653cb06 fuzz: change return values to 1 rather than 0 or -1
This allows gofuzz to store the mutating input as coverage if it reaches
any new coverage, even if it didn't make it to the end of the test.
2020-10-13 15:17:57 -04:00
Eugene 10a84f2c75 Merge pull request #4649 from Crypt-iQ/fmgr_abstract
multi: add fmgr.Manager interface, change usage in peer to use Manager
2020-10-02 08:21:15 -04:00
eugene e0859e121f multi: add fmgr.Manager interface, change usage in peer to use Manager
This gets rid of several config functions in the peer and should pave
the way for easier testing of the funding manager and peer.
2020-10-01 10:27:13 -04:00
Eugene 0a8f06651a Merge pull request #4645 from Crypt-iQ/peer_messageconn
peer: abstractions to aid in unit testing
2020-09-25 13:58:02 -04:00
eugene fada3dd871 server.go + peer: use MessageConn interface instead of brontide.Conn 2020-09-25 12:05:36 -04:00
Eugene cc29e1cce8 Merge pull request #4640 from Crypt-iQ/brontide_fuzz_fixups
fuzz/brontide: fix fuzz_utils.go NewBrontideMachine callsites
2020-09-24 00:53:43 -04:00
eugene 6ba35238ef fuzz/brontide: fix fuzz_utils.go NewBrontideMachine callsites 2020-09-22 15:53:49 -04:00
eugene ea467783e9 htlcswitch+peer: remove fwd pkgs once before tick, bump timer to 1hr
This commit changes the logic when garbage collecting forwarding
packages such that they are removed once when the function is called,
and then again upon subsequent ticks. This allows us to bump the
peer timer to 1 hour to limit the number of db transactions happening
in lnd. The forwarding packages need to be removed initially as
otherwise a flappy node will never have them garbage collected.
2020-08-31 20:52:51 -04:00
eugene 62e19185f1 htlcswitch+channeldb: single tx for removing fwdpkgs
This commit changes RemoveFwdPkg to RemoveFwdPkgs so that a single
tx is used instead of N where N is the number of fwd pkgs to remove.
2020-08-31 20:52:51 -04:00
eugene 9ce89c1b46 lnd: delete mock.go, move mockSpendNotifier to lntest/mock 2020-08-31 20:06:11 -04:00
eugene 4ff03afee0 lnd: move fundingBroadcastHeight to fundingmanager_test.go 2020-08-31 19:42:53 -04:00
eugene c7cbacc35b multi: move mockChainIO, mockNotifier to lntest/mock 2020-08-31 19:41:09 -04:00
eugene 3fa5d042c9 multi: move mockWalletController, mockSecretKeyRing to lntest/mock 2020-08-31 18:36:05 -04:00
eugene 49d8f04197 multi: migrate instances of mockSigner to the mock package
This commit moves all localized instances of mock implementations of
the Signer interface to the lntest/mock package. This allows us to
remove a lot of code and have it housed under a single interface in
many cases.
2020-08-28 15:43:51 -04:00
nsa 3791c9efcb lnd: removing activeNetParams global, passed around instead via configs
This commit removes the activeNetParams global in chainparams.go. This
is necessary to isolate code from the lnd package so we can import it
for use in tests, other projects, etc.
2020-08-11 11:41:24 -04:00
nsa c36840c2a5 lnwallet: add regression test TestChannelLocalUnsignedUpdatesFailure
This commit includes a regression test that checks that we remember
to restore updates that we sent to the peer but they haven't sent
us a signature for yet.
2020-07-29 19:03:44 -04:00
nsa e4188ba9c2 channeldb+lnwallet: store updates the peer should sign under new key
This fixes a long-standing force close bug. When we receive a
revocation, store the updates that the remote should sign next under
a new database key. Previously, these were not persisted which would
lead to force closure.
2020-07-29 19:03:44 -04:00
nsa b6eff5b0ec lnwallet: add regression test TestChannelUnsignedAckedFailure
This commit includes a regression test that checks that a force
close won't occur and that unsigned acked updates are properly
restored.
2020-07-27 16:18:11 -04:00
nsa 8c002a08a7 lnwallet: properly restore removeCommitHeightRemote
Previously, we could sign a pending commitment for the remote party,
disconnect, and not restore these signed remote updates as having been
removed at the pending commitment height. This commit fixes that to
look up whether the update under the unsigned acked updates key is
present on the pending commitment or not and appropriately set
the remove commit heights.
2020-07-27 15:41:48 -04:00
nsa 2149157d49 channeldb: filter out unsigned acked updates in AdvanceCommitChainTail
This commit moves the deletion of all updates under the unsigned
acked updates key from AppendRemoteCommitChain to
AdvanceCommitChainTail. This is done because if we went down after
signing for these updates but before receiving a revocation, we would
incorrectly reject their commitment signature:

Alice                Bob
      -----add----->
      -----sig----->
      <----rev------
      <----sig------
      -----rev----->
      <----fail-----
      <----sig------
      -----rev----->
      -----sig----->
      *reconnect*
      <----rev------
      <----add------
      x----sig------

It is also important to note that filtering is required when we
receive a revocation to ensure that we aren't erroneously deleting
remote updates. Take the following state transitions:

 Alice                Bob
       -----add----->
       -----sig----->
       <----rev------
       <----sig------
       -----rev----->
       -----add----->
       -----sig----->
       <----fail-----
       <----sig------
       -----rev-----> (alice stores updates here)
       <----rev------

In the above case, if Alice deleted all updates rather than filtering
when receiving the final revocation from Bob, then Alice would have
to force close the channel due to missing updates. Since Alice hasn't
signed for any of the unsigned acked updates, she should not filter any
of them out.
2020-07-27 15:41:48 -04:00
nsa 3ec081af84 lnwallet: correct fetchParent godoc 2020-07-21 10:45:57 -04:00
nsa 73757eb84d lnwallet: properly set addCommitHeightLocal in restoreStateLogs
The `restoreStateLogs` function now properly restores the
`addCommitHeightLocal` field of a settle or fail's parent add.
Previously, any updates' parent in unsignedAckedUpdates would have
the field set to the default value of 0. This would cause a force
closure when receiving a commitment due to our belt-and-suspenders
checks for update logs during commitment validation.

The bug in question occurs because the `addCommitHeightLocal` field
is only populated for a restored add if the add is on the local
commitment. `TestChannelRestoreCommitHeight` is expanded in
`lnwallet/channel_test.go` to demonstrate restoration now works.

The faulty state transition:
```
<----fail----
<----sig-----
-----rev----> (add no longer on Alice's commitment)
*Alice restores* (addCommitHeightLocal of failed htlc is 0)
```

NOTE: Alice dies after sending a revocation but before signing a
commitment. This is possible because there is a select block in the link
that can potentially exit after sending over the revocation but before
signing the next commitment state for the counterparty.
2020-07-21 10:45:57 -04:00
nsa cbd54101f8 multi: remove peer.go, change all references to point to peer pkg 2020-07-06 19:16:07 -04:00
nsa 9be9d69349 multi: initialize peer with peer.Config 2020-07-06 19:16:07 -04:00
nsa bf161c9835 peer+server: add HandleLocalCloseChanReqs to peer, call from server 2020-07-06 19:16:07 -04:00
nsa e1632dd172 peer.go: handleCloseMsg function for channelManager goroutine 2020-07-06 19:16:07 -04:00
nsa 1a91013c14 peer_test+test_utils: remove duplicate *LightningChannel return param
It was already present in the peer object that was returned.
2020-07-06 19:16:07 -04:00
nsa 02fd905f61 peer.go: moving the apply function outside of the constructor
This is mainly for readability so that the function isn't indented.
2020-07-06 19:16:07 -04:00
nsa 4ee4a1a24e peer.go: remove height argument to addLink function
Best height is not needed to create a link.
2020-07-06 19:16:07 -04:00
nsa 328094d8fb peer.go: replace switch statements with if statements 2020-07-06 19:16:06 -04:00
nsa 0dda9e06ce multi: exporting PendingUpdate, ChannelCloseUpdate, ErrorBufferSize 2020-07-06 19:16:06 -04:00
nsa ac3d416b04 peer_test.go: fixes to coop close tests, modifying variable names
to either be alice or bob-prefixed. This helps an observer understand
what the test is actually doing.
2020-07-06 19:16:06 -04:00
nsa ac72479b10 server.go: log DisconnectPeer errors, use public functions to access
peer internals.
2020-07-06 19:16:06 -04:00
nsa bfaef46579 peer_test.go: comment clarifications 2020-07-06 19:16:06 -04:00
nsa d23b30d889 peer.go: comment clarifications, improved formatting 2020-07-06 19:16:06 -04:00
nsa 01415f4a5f peer: define Config and LinkUpdater interface
This commit defines a Config for initializing a peer and the
LinkUpdater interface.
2020-07-06 19:16:06 -04:00
nsa 50186ba834 lnpeer/peer.go: modifying interface comment 2020-07-06 19:16:06 -04:00
nsa 2d68a64a5b chancloser: new package for cooperative channel closure
Introduces a new chancloser package which exposes a ChanCloser
struct that handles the cooperative channel closure negotiation
and is meant to replace chancloser.go in the lnd package. Updates
all references to chancloser.go to instead use chancloser package.
2020-06-16 20:34:44 -04:00
nsa 8528ec4568 lnd: modifying comments in chancloser.go 2020-06-16 20:34:44 -04:00
nsa ec2d999371 chancloser+peer: export negotiationHeight, channel, and error 2020-06-11 15:49:23 -04:00
nsa 85852733af Makefile: add -w to -ldflags to strip DWARF symbols
Compiling with this flag cuts down on the binary size by several
megabytes.
2020-06-09 14:40:48 -04:00
nsa 2848eb1d53 docs: detail watchtower tor hidden service configuration 2020-03-30 11:54:48 -04:00
nsa ada0b78dfc lnd+server+watchtower: allow Standalone access to the tor controller
This commit lets the watchtower automatically create hidden services
by giving it a pointer to a TorController. The server was also slightly
refactored so that it was not the sole owner of the TorController.
2020-03-29 12:36:54 -04:00
nsaandTurtle f1fd5e86c0 config: add WatchtowerKeyPath Tor option
Co-authored-by: Turtle <orbitalturtle@protonmail.com>
2020-03-29 11:54:59 -04:00
nsa f00159f64c peer: no pending channels in switch, buffer msgs until link active 2020-03-27 08:49:46 -04:00
nsa 966cd2112c multi: link notifies subscribers of ActiveLinkEvent, rpc ignores 2020-03-27 08:49:46 -04:00
nsa f5237589ea channelnotifier: new ActiveLinkEvent for link startup notification 2020-03-27 08:49:46 -04:00
nsa 8c0c53eac3 htlcswitch: only error in closeCircuit if the htlc was failed
This commit changes the switch to only log an error if update_fail_htlc
comes in and closeCircuit returns ErrUnknownCircuit. Rationale
being that only settles should hit this code path, anything else
is a result of a link flap and should be treated as an error.
2020-03-25 11:53:46 -04:00
nsa 4fe174ba4e htlcswitch: switch ackDownStreamPackets order with contract update call
This commit modifies updateCommitTx to error with ErrLinkShuttingDown
when we try to send a ContractUpdate on the htlcUpdates chan and the
link has closed the quit chan. It also changes the order of the call
to ackDownStreamPackets and contract update call for consistency since
the packets should be acknowledged before the link goes down.
2020-03-25 11:53:21 -04:00
nsa f757bf48bd channeldb: use RemoteCommitment in NextLocalHtlcIndex
This commit changes the fallback in NextLocalHtlcIndex to
RemoteCommitment since the LocalHtlcIndex field lags behind
on the LocalCommitment. Without this bug fix, open circuits
would get prematurely trimmed, resulting in more erroneous
logs. A test case is included to check that the fix works.
2020-03-25 11:49:16 -04:00
nsa 363bdc42b0 fuzz/lnwire: adding fuzz harnesses for all lnwire messages + zlib 2020-03-03 13:58:25 -05:00
nsa 5a03fe572f lnwire: move zero-length queryBody check to zlib case 2020-03-03 13:58:25 -05:00
nsa 7b9e0c889e docs: add fuzz.md 2020-03-03 13:58:07 -05:00
nsa 5a5e095684 lnwallet: adding TestMaxAsynchronousHtlcs unit test
Adds a new test which asserts that the new ReceiveHTLC logic can
handle proper commitment overflow calculation in the face of
asynchronous updates.
2020-02-15 09:59:50 -05:00
nsa 4af00c6b25 lnwallet: fixing unit tests to properly handle new receive validation
This commit fixes the TestMaxAcceptedHTLCs, TestMaxPendingAmount,
TestMinHTLC, & TestChanReserve unit tests to pass with the new
ReceiveHTLC logic. Instead of asserting specific failures upon
receiving a new commitment signature, the various assertions were
moved to assert on the error returned from ReceiveHTLC.
2020-02-15 09:59:50 -05:00
nsa 56c07a52d8 lnwallet: call valdiateCommitmentSanity in ReceiveHTLC
This commit checks the commitment sanity when receiving an HTLC so
that if a commitment transaction will overflow from an ADD, it is
caught earlier rather than in ReceiveNewCommitment.
2020-02-15 09:59:49 -05:00
nsa 0d42da0cb3 fuzz/brontide: random+static round-trip encrypt+decrypt harnesses 2020-01-30 16:46:02 -05:00
nsa 0be5660a2a fuzz/brontide: random+static encrypt harnesses 2020-01-30 16:46:02 -05:00
nsa 468e5c03e9 fuzz/brontide: random+static decrypt harnesses 2020-01-30 16:46:01 -05:00
nsa 116c5469bc fuzz/brontide: random+static harnesses for acts 1-3 2020-01-30 16:46:01 -05:00
nsa 511fdb2520 fuzz/brontide: add fuzzing helper utilities 2020-01-30 16:46:01 -05:00