Commit Graph

4706 Commits

Author SHA1 Message Date
Johan T. Halseth
f73a2f362e
lnd_test: correct that Bob can sweep immediately
This commit fixes a flake within the integration tests, where we would
mine a set of blocks before checking if Bob's sweep tx was in the
mempool. Usually this would pass since the blocks were generated before
the tx hit the miner's mempool, but sometimes it was mined and then we
would check the mempool.

This commit fixes this by correctly waiting immediately for Bob to sweep
his funds, as they are not time locked.
2018-07-26 09:18:42 +02:00
Olaoluwa Osuntokun
098cd940e3
Merge pull request #1622 from cfromknecht/hide-hodl-config-production
Hide hodl config production
2018-07-25 20:33:16 -07:00
Olaoluwa Osuntokun
b8c3987fd7
Merge pull request #1618 from cfromknecht/resolver-subscribe-order
contractcourt/contract_resolvers: fix subscribe preimage race
2018-07-25 20:29:14 -07:00
Stefan Menzel
e776a06cfb rpc: disallow a negative invoice amount in AddInvoice 2018-07-25 20:11:46 -07:00
Olaoluwa Osuntokun
8cd6eebadc
Merge pull request #1617 from cfromknecht/to-local-script-size
lnwallet/size: correct commit to-local and 2nd stage script/witness sizes
2018-07-25 17:16:15 -07:00
Conner Fromknecht
a5e841c6b7
htlcswitch/hodl/config_production: hide cli hodl flags in prod
This commit replaces the debug Config struct with an empty
one, so that the command line flags are hidden in production
builds.

Production help before commit:

Tor:
      --tor.active
      --tor.socks=
      --tor.dns=
      --tor.streamisolation
      --tor.control=
      --tor.v2
      --tor.v2privatekeypath=
      --tor.v3

hodl:
      --hodl.exit-settle
      --hodl.add-incoming
      --hodl.settle-incoming
      --hodl.fail-incoming
      --hodl.add-outgoing
      --hodl.settle-outgoing
      --hodl.fail-outgoing
      --hodl.commit
      --hodl.bogus-settle

Help Options:
  -h, --help

Production help after commit:

Tor:
      --tor.active
      --tor.socks=
      --tor.dns=
      --tor.streamisolation
      --tor.control=
      --tor.v2
      --tor.v2privatekeypath=
      --tor.v3

Help Options:
  -h, --help
2018-07-25 03:33:36 -07:00
Conner Fromknecht
0df2bcd18c
htlcswitch/hodl/config_debug: only expose hodl flags in debug
This commit places hodl command line flags behind the debug flag,
so that they're only accessible during testing builds.
2018-07-25 03:30:12 -07:00
Conner Fromknecht
aa6e5bdd2a
contractcourt/contract_resolvers: fix subscribe preimage race
This commit fixes a potential race condition within the
IncomingContestResolver, that could cause us to miss a
preimage that was delivered in time.

Currently we query the db for the preimage, and then
subscribe for notifications. This permits the following
ordering of events:
 - query for preimage, returns nothing
 - preimage is added and delivered to subscribers
 - subscribe to preimages
 - preimage never comes through!!

We fix this by reordering to subscribe for preimages and
then query just in case it already exists. The effect is
that the query will always return a valid read of the
preimages that are currently queued for delivery.
2018-07-25 03:15:51 -07:00
Conner Fromknecht
d41d63a409
breacharbiter: use ToLocalPenaltyWitnessSize for stage 2 htlcs 2018-07-24 22:53:17 -07:00
Conner Fromknecht
381579477c
utxonursery: use symmetric second level htlc witness size
This commit switches over the estimates for htlc success/timeout
witness sizes to use a symmetric variable, highlighting their
equivalence in size.
2018-07-24 22:53:17 -07:00
Conner Fromknecht
ee2f2573c1
lnwallet/size: correct commit to-local and 2nd stage script sizes
In this commit, we correct our size estimates for to-local scripts,
which are used on the commitment transaction and the htlc
success/timeout transactions. There have been observed cases of
transactions getting stuck because our estimates were too low, and cause
the transactions to not be relayed.

Our previous estimate for the commitment to-local script was derived
from an older version of the script. Though the estimate is greater than
the actual size, this has been updated with the current estimate of 79
bytes.

This estimates makes the assumption that CSV delays will be at most
4 bytes when serialized. Since this value is expressed in relative block
heights, this should be more than sufficient for our needs, even though
the maximum possible size for the little-endian int64 is 9 bytes (plus
an OP_DATA).

The other correction is to use the ToLocalScriptSize as our estimate for
htlc timeout/success scripts, as they are the same script. Previously,
our estimate was derived from the proper script, though we were 6 bytes
shy of the new to-local estimate, since we counted the csv_delay as 1
byte, and missed some other OP_DATAs.

All derived estimates have been updating depending on the new and
improved ToLocalScriptSize estimate, and fix some estimates that did not
include the witness length in the estimate.

Finally, we correct some weight miscalculations in:
 - AcceptedHtlcTimeoutWitnessSize: missing data push lengths
 - OfferedHtlcSuccessWitnessSize: extra 73 byte sig, missing data push lengths
 - OfferedHtlcPenaltyWitnessSize: missing 33 byte pubkey
2018-07-24 22:53:13 -07:00
Conner Fromknecht
085e1f9ca8
watchtower/blob/justice_kit_test: add encrypt/decrypt test vectors 2018-07-24 19:55:07 -07:00
Conner Fromknecht
9749096403
watchtower/blob/justice_kit: adds v0 encoding and encryption 2018-07-24 19:55:07 -07:00
Conner Fromknecht
b0379dfa59
lnwallet/channel: use exposed CommitScriptUnencumbered 2018-07-24 16:54:30 -07:00
Conner Fromknecht
1eba460a2c
lnwallet/script_utils_test: use exposed CommitScriptUnencumbered 2018-07-24 16:54:30 -07:00
Conner Fromknecht
afd8dfb9b4
lnwallet/script_utils: expose CommitScriptUnencumbered 2018-07-24 16:54:30 -07:00
Olaoluwa Osuntokun
e0baa49690
Merge pull request #1387 from wpaulino/send-disable-chan-update
multi: send a channel update with disabled flag set on channel close
2018-07-23 17:46:37 -07:00
Olaoluwa Osuntokun
2eeced5f5e
Merge pull request #1531 from halseth/only-vonfirmed-spends
Only act on confirmed spends
2018-07-23 17:36:09 -07:00
Olaoluwa Osuntokun
ef56f76200
routing: demote channel update logging to trace 2018-07-23 17:01:39 -07:00
Olaoluwa Osuntokun
1a13e44cde
Merge pull request #1600 from Roasbeef/prune-unconnected-graph-verticies
channeldb+routing: prune unconnected graph vertexes on start up
2018-07-23 16:49:00 -07:00
Olaoluwa Osuntokun
ef4c7d2a78
channeldb: add new TestAddChannelEdgeShellNodes test 2018-07-22 21:05:52 -07:00
Olaoluwa Osuntokun
2e75499787
channeldb+routing: move adding shell nodes into db txn of AddChannelEdge
In this commit, we fix a slight race condition that can occur when we go
to add a shell node for a node announcement, but then right afterwards,
a new block arrives that causes us to prune an unconnected node. To
ensure this doesn't happen, we now add shell nodes within the same db
transaction as AddChannelEdge. This ensures that the state is fully
consistent and shell nodes will be added atomically along with the new
channel edge.

As a result of this change, we no longer need to add shell nodes within
the ChannelRouter, as the database will take care of this operation as
it should.
2018-07-22 21:02:53 -07:00
Olaoluwa Osuntokun
8519ea869d
channeldb: add logging for nodes pruned from the channel graph 2018-07-22 21:00:51 -07:00
Olaoluwa Osuntokun
6bf15e8f2b
channeldb: fix bug in pruneGraphNodes by switching to using ref counting
In this commit, we fix an existing bug in the pruneGraphNodes method.
Before this commit, if a node was involved in a channel, but only one of
the edges was advertised, then either it, or the other node would be
erroneously pruned from the graph. They shouldn't be pruned as there's
still an edge connecting the, although only 1/2 of the edge is actually
advertised.

In order to fix this, we'll now do two passes: the first pass will
populate a ref count map of all known nodes in the graph, the second
pass will increment the ref count each time a node is found in the
graph. With this two pass method, we ensure that nodes are only deleted
if there are absolutely no edges pointing to them within the graph.
2018-07-22 18:59:36 -07:00
Olaoluwa Osuntokun
131eea4960
channeldb: modify TestPruneGraphNodes to test nodes w/ single edge
In this commit, we extend the TestPruneGraphNodes test to also test the
case of when a node is involved in a channel, but only a single edge for
that channel has been advertised. In order to test this, we add an
additional node to the graph, and also a new channel. However, this
channel will only have a single edge advertised. As result, when we
prune the set of edges, the only node remaining should be the node that
didn't have any edges at all.
2018-07-22 18:57:18 -07:00
Johan T. Halseth
181014c363
chainntnfs/bitcoindnotify: remove all mempool spend clients 2018-07-22 23:09:09 +02:00
Johan T. Halseth
3808105dcd
chainntnfs/btcdnotify: remove all mempool spend clients 2018-07-22 23:09:08 +02:00
Johan T. Halseth
d7b2977e8c
multi test: remove mempool bool from RegisterSpendNtfn 2018-07-22 23:09:08 +02:00
Johan T. Halseth
57e829f47e
multi: remove mempool bool from RegisterSpendNtfn 2018-07-22 23:09:08 +02:00
Johan T. Halseth
02f7f29b97
chainntnfs/interface_test: remove mempool spend tests 2018-07-22 23:09:08 +02:00
Johan T. Halseth
44d7b84df0
chainntnfs: remove mempool option from RegisterSpendNtfn 2018-07-22 23:09:08 +02:00
Johan T. Halseth
77f0020697
lnd_test: account for justice tx broadcast failure 2018-07-22 23:09:08 +02:00
Johan T. Halseth
8cff5eae6c
breacharbiter: make the second level check use confirmed spends 2018-07-22 23:09:08 +02:00
Johan T. Halseth
a16bb662a4
contractcourt/chain_arbitrator: make watchForChannelClose use confirmed spend 2018-07-22 23:09:07 +02:00
Johan T. Halseth
5bfa2f5912
contractcourt/contract_resolvers: make commitSweepResolver use confirmed spend 2018-07-22 23:09:07 +02:00
Johan T. Halseth
9fffe23696
contractcourt/contract_resolvers: make htlcOutgoingContestResolver act on conf 2018-07-22 23:07:53 +02:00
Johan T. Halseth
b3e17aa67b
contractcourt/contract_resolvers: make second level htlcSuccessResolver wait for conf 2018-07-22 11:20:23 +02:00
Johan T. Halseth
bf06dc24c1
contractcourt/contract_resolvers: make waitForOutputResolution use confirmed spend 2018-07-22 11:20:23 +02:00
Johan T. Halseth
fdf3b407c9
lnd_test: correct node names in comments, format file 2018-07-22 11:20:23 +02:00
Johan T. Halseth
ea2b706174
lntest/node: make sure finalizing file is over before stop 2018-07-22 11:20:23 +02:00
Olaoluwa Osuntokun
f8cbe34e93
routing: prune nodes from the channel graph on start up 2018-07-21 19:52:26 -07:00
Olaoluwa Osuntokun
0645261e5e
channeldb: add nwe PruneGraphNodes method to prune unconnected nodes 2018-07-21 19:49:59 -07:00
Olaoluwa Osuntokun
3a465c64b5
channeldb: modify pruneGraphNodes to prune nodes if no edges exist 2018-07-21 19:49:16 -07:00
Olaoluwa Osuntokun
bca926d6af
Merge pull request #1371 from wpaulino/prune-link-nodes
server: prune link nodes without any open channels
2018-07-21 18:55:38 -07:00
Olaoluwa Osuntokun
925879f0fc
Merge pull request #1581 from Roasbeef/async-rescan-btcd
chainntnfs/btcdnotify: switch to async rescan call for historical spe…
2018-07-21 18:35:12 -07:00
Olaoluwa Osuntokun
b9947c1c7c
Merge pull request #1578 from Roasbeef/invoice-ntfn-buffer
invoiceregistry: make the invoice ntfn chan buffered
2018-07-20 18:12:00 -07:00
Olaoluwa Osuntokun
271db7d06d
Merge pull request #1505 from wpaulino/fundingmanager-send-peer-directly
fundingmanager: send messages directly to peers
2018-07-20 17:48:14 -07:00
Wilmer Paulino
d54d41eed7
fundingmanager: update tests to latest changes 2018-07-19 12:34:13 -07:00
Wilmer Paulino
38e01b259f
fundingmanager+lnd: remove no longer needed FindPeer and SendToPeer
callbacks

The FindPeer and SendToPeer callbacks are no longer needed within the
fundingManager due to the previous commit allowing us to send messages
to peers directly.
2018-07-19 12:34:12 -07:00
Wilmer Paulino
9cedef9245
fundingmanager: send messages to peers directly
In this commit, we modify the existing message sending functionality
within the fundingmanager. Due to each mesage send requiring to hold the
server's lock to retrieve the peer, we might run into a case where the
lock is held for a larger than usual amount of time and would therefore
block on sending the message within the fundingmanager. We remedy this
by taking a similar approach to some recent changes within the gossiper.
We now keep track of each peer within the internal fundingmanager
messages and send messages directly to them.
2018-07-19 12:34:11 -07:00