Commit Graph

6169 Commits

Author SHA1 Message Date
Wilmer Paulino
7239e04696
chainntnfs: initialize TxNotifier with new ReorgSafetyLimit 2019-01-11 16:58:15 -08:00
Wilmer Paulino
9d51114546
chainntnfs/txnotifier: define ReorgSafetyLimit as 144 blocks 2019-01-11 16:58:15 -08:00
Wilmer Paulino
55b580f2b8
Merge pull request #2462 from Roasbeef/fix-length-update
lnwire: ensure we precisely encode the length for onion errors w/ cha…
2019-01-11 16:12:04 -08:00
Olaoluwa Osuntokun
2d717fdc44
Merge pull request #2446 from cfromknecht/lncfg-lnaddress-parsing
lncfg: NetAddress parsing
2019-01-11 15:42:48 -08:00
Olaoluwa Osuntokun
400a1d3282
Merge pull request #2431 from cfromknecht/keyring-remote-delay-retribution
lnwallet: Add keyring and remote CSV delay to BreachRetribution
2019-01-11 15:33:16 -08:00
Olaoluwa Osuntokun
5fde362420
Merge pull request #2452 from cfromknecht/stricter-has-active-link
htlcswitch: stricter HasActiveLink
2019-01-11 15:28:21 -08:00
Olaoluwa Osuntokun
f83fde8483
lnwire: ensure we precisely encode the length for onion errors w/ chan updates
In this commit we fix a compatibility issue with other implementations.
Before this commit, when writing out an onion error that includes a
`ChannelUpdate` we would use the `MaxPayloadLength` to get the length to
encode. However, a recent update has modified that to be the max
`brontide` payload length as it's possible to pad out the message with
optional fields we're unaware of. As a result, we would always write out
a length of 65KB or so. This didn't effect our parser as we ignore the
length and decode the channel update directly as we don't need the
length to do that. However, other implementations depended on the length
rather than just reading the channel update, meaning that they weren't
able to decode our onion errors that had channel updates.

In this commit we fix that by introducing a new
`writeOnionErrorChanUpdate` which will write out the precise length
instead of using the max payload size.

Fixes #2450.
2019-01-11 14:21:48 -08:00
Conner Fromknecht
043631e59f
Merge pull request #2430 from cfromknecht/remove-breach-txn-from-retribution
lnwallet: Remove breach txn from NewBreachRetribution
2019-01-11 13:47:30 -08:00
Johan T. Halseth
a324691013
Merge pull request #2289 from ccdle12/unsettled-balance
rpcserver+lnd_test: fixing unassigned UnsettledBalance field
2019-01-11 10:50:56 +01:00
Johan T. Halseth
3c2b46eb8c
Merge pull request #2445 from cfromknecht/netann-logging
netann: Add NANN subsystem logger
2019-01-11 10:45:29 +01:00
Johan T. Halseth
058b0e5767
Merge pull request #2454 from cfromknecht/handle-write-errors
peer: handle message encoding errors on write
2019-01-11 09:36:21 +01:00
Conner Fromknecht
2cf220a137
peer: handle message encoding errors on write
In this commit, we modify the peer's writeMessage
method to properly handle errors returned from
encoding an lnwire message and from setting the
write deadline on the connection. Since an error
would likely result in an empty byte slice, the
worse case seems to be that we may have tried to
send an empty message on the wire.

Lastly, we correct the way we compute bytes sent
on the wire to properly count the number of bytes
*written*, and not just the length of the encoded
message.
2019-01-10 19:49:44 -08:00
ccdle12
264293ff89 rpcserver+lnd_test: adding PendingHtlcs to UnsetteldBalance
rpcserver: summing PendingHtlcs and assigning to UnsettledBalance

lnd_test: adding tests for UnsettledBalance
2019-01-10 22:11:38 -05:00
Olaoluwa Osuntokun
cd15de4144
Merge pull request #2259 from yancyribbens/update-dockerfile-image
update lnd dockerfile image
2019-01-10 17:40:52 -08:00
Conner Fromknecht
6ae77bc3cb
htlcswitch/switch_test: adds HasActiveLink unit test 2019-01-10 16:34:03 -08:00
Conner Fromknecht
164250d1cd
htlcswitch/switch: check EligibleToForward in HasActiveLink
This commit modifies the behavior of the
HasActiveLink method within the switch to
only return true if the link is in the
link index and is eligible to forward
HTLCs.

The prior version returns true whenever
the link is found in the link index,
which may return true for pending
channels that are not actually active.
2019-01-10 16:34:02 -08:00
Yancy Ribbens
8fef5608b5 update lnd dockerfile image to golang:1.11-alpine for lnd 2019-01-10 18:21:12 -06:00
Conner Fromknecht
f66e713b35
watchtower/blob/justice_kit_test: test witness script/stack construction 2019-01-10 15:59:54 -08:00
Conner Fromknecht
ca3e06b785
watchtower/wtserver: reject unknown blob types 2019-01-10 15:59:54 -08:00
Conner Fromknecht
4f3655ba93
watchtower/wtwire/create_session_reply: add reject blob type code 2019-01-10 15:59:54 -08:00
Conner Fromknecht
b746bf86c2
watchtower/multi: switch over to wtpolicy
migrate to using wtpolicy.Policy in wtwire messages and wtserver
2019-01-10 15:59:54 -08:00
Conner Fromknecht
c315d74347
watchtower/wtpolicy/policy: adds watchtower policy 2019-01-10 15:59:54 -08:00
Conner Fromknecht
cf1b8ba78f
watchtower/blob/type_test: adds Flag and Type unit tests 2019-01-10 15:59:54 -08:00
Conner Fromknecht
bc09c6dbae
watchtower/blob/type: introduces blob type flags
Adds flags for reward outputs and commitment outputs.
The fixed-size encoding for commitment outputs is
treated as a flag, so that the blob format can be
modified, extended, or replaced in future iterations.
2019-01-10 15:35:07 -08:00
Conner Fromknecht
eb1167cc52
Merge pull request #2418 from cfromknecht/connectpeer-logging
rpcserver: add connectpeer log, fix existing formatting
2019-01-10 13:51:48 -08:00
Conner Fromknecht
eb2f5cecf6
multi: remove breach tx arg from NewBreachRetribution args
This commit removes the breach transaction from the
arguments passed to NewBreachRetribution. We already
keep all prior remote commitments on disk in the
commitment log, and load that transaction from disk
inside the method. In practice, the one loaded from
disk will be the same one that is passed in by the
caller, so there should be no change in behavior
as we've already derived the appropriate state number.

This changes makes integration with the watchtower
client simpler, since we no longer need to acquire
the breaching commitment transaction to be able to
construct the BreachRetribution. This simplifies
not only the logic surrounding transient backsups,
but also on startup (and later, retroactively
backing up historic updates).
2019-01-10 13:13:38 -08:00
Olaoluwa Osuntokun
9f7d2f6cbc
Merge pull request #2449 from cfromknecht/router-avoid-naked-spew
routing/router: avoid naked spew of channel policies
2019-01-10 12:44:38 -08:00
Johan T. Halseth
e6ee835bbe
lnwallet/channel_test: assert FeeUpdate is removed from logs after lock-in 2019-01-10 12:31:12 +01:00
Johan T. Halseth
dadfcefc07
lnwallet/channel: don't return feePerKw from computeView
Since the feerate is part of the computed view now, we don't have to
pass the found feerate as a distinct parameter.
2019-01-10 12:31:12 +01:00
Johan T. Halseth
7e015258cd
lnwallet/channel test: add TestUpdateFeeConcurrentSig
This tests make sure we don't reset our expected fee upate after signing
our next commitment. This test would fail without the previous set of
commits.
2019-01-10 12:31:12 +01:00
Johan T. Halseth
6ffd354d63
lnwallet/channel: add fee updates to update logs
Instead of special casing the UpdateFee messages, we instead add them to
the update logs like any other HTLC update message. This lets us avoid
having to keep an extra set of variables to keep track of the fee
updates, and instead reuse the commit/ack logic used for other updates.

This fixes a bug where we would reset the pendingFeeUpdate variable
after signing our next commitment, which would make us calculate the new
fee incorrectly if the remote sent a commitment concurrently.

When restoring state logs, we also make sure to re-add any fee updates.
2019-01-10 12:31:12 +01:00
Johan T. Halseth
810c56cdb9
lnwallet/channel: process FeeUpdate found in update log
This commit makes the evaluateHTLCView method process any found
FeeUpdates in the logs, by returning the last set feerate.
2019-01-10 12:31:11 +01:00
Johan T. Halseth
277949cb0e
lnwallet/channel: remove FeeUpdates when compacting logs
When compacting the update logs we remove any fee updates when they
remove height is passed. We do this since we'll assume fee updates are
added and removed at the same commit height, as they will apply for all
commitments following the fee update.
2019-01-10 12:26:41 +01:00
Johan T. Halseth
480f43f1dc
lnwallet/channel: add lnwire<->PaymentDescriptor FeeUpdate conversion
This commit adds conversion between the lnwire.UpdateFee message and the
new FeeUpdate PaymentDescriptor. We re-purpose the existing Amount field
in the PaymentDescriptor stuct to hold the feerate.
2019-01-10 12:26:33 +01:00
Johan T. Halseth
36857a1042
lnwallet/channel: add new PaymentDescriptor type FeeUpdate
This commit adds a new updateType that can be used for
PaymentDescriptors: FeeUpdate. We repurpose the fields of the existing
PaymentDescriptor struct such that we can easily re-use the commit/ack
logic used for other update types also for fee updates.
2019-01-10 12:23:56 +01:00
Conner Fromknecht
a5b22788bf
routing/router: avoid naked spew of channel policies 2019-01-09 23:54:41 -08:00
Conner Fromknecht
a8b2c093aa
Merge pull request #2416 from cfromknecht/netann-node-signer
netann: move NodeSigner out of main package
2019-01-09 17:01:00 -08:00
Conner Fromknecht
381b5275c4
lncfg/address_test: test LNAddress parsing, refactor addr tests 2019-01-09 16:37:56 -08:00
Conner Fromknecht
198f9323cc
lncfg/address: add LN address parsing 2019-01-09 16:37:48 -08:00
Olaoluwa Osuntokun
e140cbb945
test: add integration test for sweeping all coins from wallet 2019-01-09 15:55:31 -08:00
Olaoluwa Osuntokun
eda6ed224f
sweep: add unit tests for TestDetermineFeePerKw and CraftSweepAllTx
Along the way we also extend the mockFeeEstimator to be able to return a
fee rate for a specified confirmation target.
2019-01-09 15:55:28 -08:00
Olaoluwa Osuntokun
b2c712fb67
cmd/lncli: add new --sweepall flag to sendcoins
In this commit, we add a new flag to the sendcoins command that allows
callers to sweep all funds out of the daemon's wallet. This CANNOT be
set at the same time that an amount is specified.
2019-01-09 15:55:27 -08:00
Olaoluwa Osuntokun
3a7b9c8367
rpc: implement new feature of sendcoins to sweep all wallet UTXOs
In this commit, we implement the new feature which allows sendcoins to
sweep all the coins in the wallet. We use the new sweep.CraftSweepAllTx
method, and also use WithCoinSelectLock to ensure that we don't trigger
any double-spend errors triggered by coin selection race conditions.
2019-01-09 15:55:26 -08:00
Olaoluwa Osuntokun
36ff16cce4
lnrpc: add new SendAll field to SendCoinsRequest 2019-01-09 15:55:25 -08:00
Olaoluwa Osuntokun
4b316d97c8
lnwallet: add new WithCoinSelectLock method to fix coin select race conditions
In this commit, we add a new method WithCoinSelectLock. This method will
allow us to fix bugs in the project atm that can arise if a channel
funding is attempted (either manually or by autopilot) while a users is
attempting to send an on-chain transaction. If this happens
concurrently, then both contexts will grab the set of UTXOs and attempt
to lock them one by one. However, since they didn't obtain an exclusive
snapshot of the UTXO set of the wallet, they may both attempt to lock
the same input.

We also ensure that calls to SendMany cannot run into this issue by
using the WithCoinSelectLock synchronization when attempting to instruct
the internal wallet to send payments.
2019-01-09 15:55:24 -08:00
Olaoluwa Osuntokun
9c29e61826
sweep: add new CraftSweepAllTx method to fully withdrawal from a wallet
In this commit, we add a new function, CraftSweepAllTx. This function
allows callers to craft a transaction which sweeps ALL outputs from the
wallet to a single target address. It can either be used for UTXO
consolidation (at the cost of privacy by co-mingling inputs), or simply
to sweep all funds out of a wallet for various reasons.

In an attempt to ensure this method is loosely coupled and testable, for
all behavior structs, we create brand new interface to accept. This
ensures that we only rely on the minimal number of methods needed to
perform our duty.
2019-01-09 15:55:23 -08:00
Olaoluwa Osuntokun
4ad175c16d
sweep: update getInputWitnessSizeUpperBound to be aware of nested p2sh
In this commit, we update the `getInputWitnessSizeUpperBound` and all
its callers to be aware of nested p2sh witness inputs. We do so by
adding another bool which is true if the output is a nested p2sh output.
If so, then in order to properly estimate the total weight, the caller
needs to factor in the non-witness data of the additional sigScript data
push.
2019-01-09 15:55:22 -08:00
Olaoluwa Osuntokun
40f0dbb5e6
lnwallet: add witness generation functions for p2wkh and np2wkh types 2019-01-09 15:55:21 -08:00
Olaoluwa Osuntokun
c18e166e03
lnwallet+sweep: extend the WitnessGenerator type to return an InputScript
In this commit, we extend the WitnessGenerator type to now return an
InputScript. This allows it to be more encompassing, as now callers can
expect a sigScript to be populated if the input being swept requires a
sigScript field.

Along the way, we've also renamed input.BuildWitness to
input.CraftInputScript.  We also take a step towards allowing the
sweeper to sweep transactions for n2pwkh outputs. We do so by modifying
the BuiltWitness method to instead return an InputScript. Additionally,
when populating inputs if a sigScript is present, it will now be
populated.
2019-01-09 15:55:19 -08:00
Olaoluwa Osuntokun
bd9ebbd5af
lnwallet: add more godoc to InputScript rename ScriptSig field to SigScript 2019-01-09 15:55:18 -08:00