Commit Graph

3180 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
d35709b38e
lnwallet: extend TestForceClose to close with both incoming+outgoing HTLCs
In this commit we add some additional scenarios to the TestForceClose
test. With this expanded test case, we now ensure the the party that
force closes is able to properly sweep both incoming and outgoing
HTLC’s fully with the information contained the HtlcResolution struct.
2018-01-22 19:19:33 -08:00
Olaoluwa Osuntokun
1d7a1ac0ee
lnwallet: update channel state machine tests to use distinct keys
In this commit, we update the channel state machine tests to use a new
key for each purpose. Before this commit, the same key would be used
the entire time. As a result, a few bugs slipped by that would’ve been
detected if we used fresh keys for each purpose. Additionally, this
reflect the real world case as we always use distinct keys for each
purpose to avoid key re-use.
2018-01-22 19:19:32 -08:00
Olaoluwa Osuntokun
b5496c52a2
lnwallet: newHtlcResolution now returns both incoming and outgoing HTLC resolutions
In this commit, we’ve added a new HtlcResolutions struct to house both
the incoming and outgoing HTLC resolutions. This struct will now be
coupled with the object that returns when we detect that a commitment
transaction was closed on chain. For incoming HTLC’s, we’ll check the
preimage cache to see if we can claim the HTLC on-chain. If we can,
then we’ll copy of the preimage, and make a proper incoming HTLC
resolution.
2018-01-22 19:19:32 -08:00
Olaoluwa Osuntokun
d98026f579
lnwallet: modify OutgoingHtlcResolution to also account for remote force closes
In this commit, we modify the OutgoingHtlcResolution struct to detect
if this is the remote party’s commitment transaction or not. With this
change, we’ll now be able to properly time out an HTLC that was
detected on the commitment transaction of the remote peer.
Additionally, we now populate the CsvDelay (if local commitment) and
the ClaimOutpoint (as we may be sweeping directly from the commitment
transaction now.
2018-01-22 19:19:32 -08:00
Olaoluwa Osuntokun
bcfe7192d7
lnwallet: add new IncomingHtlcResolution for resolving incoming HTLC's on-chain
In this commit, we add a new IncomingHtlcResolution struct. This is the
opposite of the existing OutgoingHtlcResolution struct. The items in
this new struct allow callers to sweep an incoming HTLC that we know
the preimage to. These will always be created when a commitment goes
on-chain. However, if we know the preimage, then that will be populated
in place of all zeroes in the Preimage field.
2018-01-22 19:19:31 -08:00
Olaoluwa Osuntokun
ecf6d758a2
lnwallet: add distinct CommitOutputResolution for resolving commit outputs on-chain
In this commit, we modify both the ForceCloseSummary, and the
UnilateralClosureSummary to return the items needed to sweep the
commitment output distinctly. By doing this, it’s now possible to pass
a dedicated struct to a sub-system in order to allow it to sweep a
commitment output. As the maturity delay is a part of this new struct,
this tells the caller if this was on the local commitment (CSV
required) or on the remote commitment (no CSV required).
2018-01-22 19:19:31 -08:00
Olaoluwa Osuntokun
42cd2fa5be
lnwallet: add new ActiveHtlcs to channel state machine
In this commit, we’ve added a new method to the channel state machine:
ActiveHtlcs. This method will allow callers to poll the state of the
channel to retrieve the set of HTLC’s active on *both* commitment
transactions.
2018-01-22 19:19:31 -08:00
Olaoluwa Osuntokun
5f6c15cfa4
lnwallet: RevokeCurrentCommitment now returns the set of active HTLC's
In this commit, we modify the RevokeCurrentCommitment method to now
return the set of active HTLC’s. This will be used by callers in the
future to update other sub-systems when the set of HTLC’s on the
commitment changes, and can also be used on the RPC level to
synchronize systems level integration tests.
2018-01-22 19:19:30 -08:00
Olaoluwa Osuntokun
75d2f09d4c
lnwallet: add a PreimageCache instead of a FeeEstimator as LightningChannel dep 2018-01-22 19:19:29 -08:00
Olaoluwa Osuntokun
b1503adfad
lnwallet: add new PreimageCache interface 2018-01-22 19:19:29 -08:00
Olaoluwa Osuntokun
a9d451e46d
lnwallet: add AcceptedHtlcTimeoutWitnessSize to size.go 2018-01-22 19:19:29 -08:00
Olaoluwa Osuntokun
774ec5b528
lnwallet: rename OfferedHtlcWitnessSize to OfferedHtlcSuccessWitnessSize 2018-01-22 19:19:28 -08:00
Olaoluwa Osuntokun
65619b11aa
lnwallet: modify TxWeightEstimator methods to allow chaining
By returning a *TxWeightEstimator from each method, we now all callers
to chain the methods. This adds a bit of nice sugar when interacting
with the struct.
2018-01-22 19:19:28 -08:00
Olaoluwa Osuntokun
ff872b798c
lnwallet: update WitnessType names to be more descriptive
In this commit, we rename several of the existing WitnessType
definitions to be more descriptive than they were previously. We also
add a number of additional types which we need to handle scripts for,
but weren’t yet added before. Finally, we modify the
receiverHtlcSpendTimeout to optionally take an additional parameter to
set the locktime of the spending transaction accordingly. This final
modification allows the caller to specify that the lock time has
already been set on the main transaction.
2018-01-22 19:19:27 -08:00
Olaoluwa Osuntokun
3fa0cde631
lnwallet: export senderHtlcSpendRedeem and make rename HtlcSpendSuccess to HtlcSecondLevelSpend 2018-01-22 19:19:21 -08:00
Jim Posen
0becaddcd5 lnwallet: Move mocks to separate file and augment mockSigner.
To implement the BOLT 03 test vectors, a more powerful mockSigner is
required. The new version of mockSigner stores multiple keys and signs
the transaction outputs with the appropriate one.
2018-01-22 19:00:28 -08:00
Matt Drollette
86133e559b config: add peer, rpc, and rest listener options
This commit removes the `peerport` and `rpcport` config options and
adds `listen`, `rpclisten`, and `restlisten` options to allow setting
one or multiple interfaces to listen on for incoming connections.

It also adds a `nolisten` option to allow disabling the listener for
incoming peer connections.
2018-01-21 17:35:03 -08:00
Johan T. Halseth
8cce2ad630
Merge pull request #573 from wilmerpaulino/parse-data-fields
invoice: refactor parsing data tagged fields and add unit tests
2018-01-19 18:40:48 +01:00
Wilmer Paulino
8807fb804b
invoice: add unit tests for each parsed tagged field
This commit introduces unit tests for each parsed tagged field to cover
all possible input scenarios.
2018-01-19 12:00:51 -05:00
Wilmer Paulino
07ac278771
invoice: properly parse the field data length
When accessing a value from a byte slice, the value is returned as a
byte, which is just a uint8. When the first byte takes more than 3 bits
of space, shifting 5 bits left results in data loss.
2018-01-19 10:52:24 -05:00
Wilmer Paulino
fa2cc57ca6
invoice: sanity check routing info field
This commit allows parseRoutingInfo to return an error when parsing a
routing info field whose length is not a multiple of 51 bytes, rather
than crash.
2018-01-19 10:52:23 -05:00
Wilmer Paulino
db7154a401
invoice: sanity check empty fallback addr field
This commit allows parseFallbackAddr to return an error when parsing an
empty fallback address field, rather than crash.
2018-01-19 10:52:22 -05:00
Wilmer Paulino
00d530bd91
invoice: remove duplicate code when parsing the timestamp 2018-01-19 10:52:21 -05:00
Wilmer Paulino
6f5d673679
invoice: refactor parsing tagged fields
This commit refactors parsing each of the tagged fields of an invoice
into their own method. This makes the code easier to read and will allow
us to introduce unit tests for each parsing method.
2018-01-19 10:52:21 -05:00
Johan T. Halseth
cb7699068b
Merge pull request #591 from AdamISZ/master
Fix trivial comment errors in noise.go
2018-01-19 14:47:22 +01:00
Johan T. Halseth
88f5c9ca9c
Merge branch 'master' into master 2018-01-19 14:04:52 +01:00
Deelight-fr
e4e6766746 Doc fix: typo in lnd/bitcoind arguments 2018-01-19 11:23:05 +01:00
Conner Fromknecht
5126e43135
rpcserver: flip inbound bool for display, fix internally later 2018-01-18 14:10:35 -08:00
Benjamin Congdon
92ac81b3b0
lnd+server: Allow configurable Node Alias and Color
This commit sets the Node's Alias and Color to the values set in config.
2018-01-18 09:31:48 -06:00
Benjamin Congdon
a40ee8fe8a
config: Add settings for Alias and Color
This commit adds configuration variables for setting the Color and Alias
of the Node.
2018-01-18 07:39:37 -06:00
Benjamin Congdon
ecff8f2a07
lnwire: Trim zero-bytes from NodeAlias String representation
This commit alters the NodeAlias String method to trim null-bytes from
the end of the alias. This is helpful for presentation in contexts such
as the GetInfo response.
2018-01-18 07:39:37 -06:00
Benjamin Congdon
f1f1c8a257
rpc: Remove SetAlias and add Alias to GetInfo Response
This commit removes the SetAlias RPC function because it was deemed
unnecessary. This commit also populates the Alias field in the GetInfo
response
2018-01-18 07:39:37 -06:00
Maarten Tutak
a8728ccb5b docs: add example of Java gRPC client 2018-01-18 12:47:54 +01:00
romanornr
d512642c02 Travis: fix sudo required and apt-get update command 2018-01-17 10:06:40 -07:00
Olaoluwa Osuntokun
7b6f4d34b1
docker: fix stray quote in start-lnd.sh
Fixes #613.
2018-01-16 17:19:40 -08:00
Olaoluwa Osuntokun
ebd97b83f3
discovery: ensure we only send node announcements that have active channels 2018-01-16 17:18:21 -08:00
Alex
3da0e2011b docker, docs, sample-lnd.conf: update examples for new command-line options 2018-01-15 14:56:21 -08:00
Alex
1305a4fedf build: update travis to install bitcoind for running tests 2018-01-15 13:59:34 -08:00
Alex
db55569bac chainntfns: stop neutrino service before closing DB in interface_test.go 2018-01-15 13:59:34 -08:00
Alex
9a02884d0b main/lntest: factor out node config options, add options for bitcoind
This commit factors out the btcd and ltcd options into their own sections
similar to neutrino, and adds a bitcoind section as well. Now, you specify
node options similarly to:

--ltcd.rpchost=...
or
--btcd.rpcuser=...
or
--bitcoind.zmqpath=...

For Bitcoin, you specify an alternate back-end to btcd as follows:

--bitcoin.node=bitcoind
or
--bitcoin.node=neutrino

You can also specify the default option:
--bitcoin.node=btcd

For Litecoin, only `btcd` mode is valid, and corresponds to the `ltcd`
section. For example:

--litecoin.node=btcd
--ltcd.rpchost=...

The new code also attempts to read the correct options and auth info
from bitcoin.conf just as it does from btcd.conf/ltcd.conf.
2018-01-15 13:59:34 -08:00
Alex
187f59556a multi: add bitcoind drivers and tests 2018-01-15 13:59:34 -08:00
Johan T. Halseth
244ae4b571
Merge pull request #605 from timo-schmid/master
rpc: remove SetAlias from the rpc docs
2018-01-15 11:33:11 +01:00
Timo Schmid
9ab2ab0424
rpc: remove SetAlias from the rpc docs 2018-01-13 21:29:15 +01:00
Olaoluwa Osuntokun
db06a8a7ee
Merge pull request #506 from halseth/dynamic-channel-params
Dynamic and user definable channel params
2018-01-12 15:38:12 -08:00
Johan T. Halseth
d030773c8d
lnd test: add testUpdateChannelPolicy
This commit adds a new integration test, that checks that
policy/fee updates get propagated properly in the network,
such that the other nodes learn about the changes.
2018-01-12 22:57:05 +01:00
Johan T. Halseth
f4f024aff2
lnd_test: extract graph topology subscription into own method
This commit extracts the launching of a goroutine subscribing
to and forwarding graph topology notifications into its own
utility method, such that it can be used in other tests as
well.
2018-01-12 22:57:04 +01:00
Johan T. Halseth
483abbee5b
discovery: make sure ChannelUpdates always have incremented timestamp
This commit ensures that we always increment the timestamp of
ChannelUpdates we send telling the network about changes to
our channel policy. We do this because it could happen
(especially during tests) that we issued an update, but the
ChannelUpdate would have the same timestamp as our last
ChannelUpdate, and would be ignored by the network.
2018-01-12 22:57:03 +01:00
Johan T. Halseth
43d7dd3d99
lnd: make NumRequiredConfs and RequiredRemoteDelay scale with chanAmt
This commit makes the value returned fomr NumRequiredConfs
and RequiredRemoteDelay used during the funding process scale
linearly with the channel size. This is done to ensure that
in cases there are more at stake in a channel, we have more
time to react to reorgs, or unilateral closes.

If the user explicitly specified values for these two at
startup, we return those instead, without doing the scaling.
2018-01-12 22:57:02 +01:00
Johan T. Halseth
3edc1a7456
fundingmanager: define min and maxRemoteDelay
This commit defines minRemoteDelay and maxRemoteDelay,
which is the extremes of the CSV delay we will require
the remote to use for its commitment transaction. The
actual delay we will require will be somewhere between
these values, depending on channel size.
2018-01-12 22:57:01 +01:00
Johan T. Halseth
53b0ee3765
lntest/node: use --bitcoin.defaultchanconfs=1 and --bitcoin.defaultremotedelay=4 2018-01-12 22:57:00 +01:00