Commit Graph

2093 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
b07e7fb7cc
routing: hop-payload for last hop should be the absolute timeout, not delta
This commit fixes an oversight in the path finding code when converting
a path into a route. Currently, for the last hop, we’d emplace the
expiry delta of the last hop within the per-hop payload. This was left
over from a prior version of the specification.

To fix this, we’ll now emplace the _absolute_ final HTLC expiry with
the payload, such that, the final hop that verify that the HTLC has not
been tampered with in flight.
2017-09-12 21:27:47 +02:00
Olaoluwa Osuntokun
f32a7a28ab
htlcswitch: if we fail to parse and onion error, return the proper lnwire.FailCode 2017-09-12 18:10:40 +02:00
Olaoluwa Osuntokun
3d95efdc0f
htlcswitch: use %x when printing the payment hash of an HTLC
We use %x as it’ll hex-encode the raw bytes, instead of printing the
individual integers within the byte array.
2017-09-12 18:08:50 +02:00
Olaoluwa Osuntokun
769abb87ea
funding: properly verify and apply channel constraints during funding flow
This commit implements some missing functionality as we’ll now properly
validate and generate the various channel flow control constraints
during initial channel funding.

With this commit, we take an additional step towards full spec
compliance as we’ll now properly send over the required channel
reservation, max HTLC’s, and other parameters during the funding flow.

When processing the desired parameters by the remote party, if we think
they’re unreasonable, then we’ll send an Error message and end the
funding flow.
2017-09-12 18:07:50 +02:00
Olaoluwa Osuntokun
6e6b5ac9af
lnrpc: remove the revocation_delay field from the HTLC proto
This commit removes the revocation_delay field from the HTLC proto as
we no longer need this field since the switch to 2-layer HTLC’s. The
2-layer HTLC construction no longer has the CSV delay directly in the
HTLC script itself.
2017-09-12 18:03:17 +02:00
Olaoluwa Osuntokun
d76f660eb1
rpc: in logging for CloseChannel RPC, also log the force parameter 2017-09-12 18:00:46 +02:00
Olaoluwa Osuntokun
9a93f83370
lnwire: fix ordering of the UpdateAddHTLC message on the wire
This commit fixes a diversion from the way the UpdateAddHTLC message is
defined within the specification. We had the HTLC expiry value in the
wrong place on the wire, which meant that we couldn’t parse the
messages as sent by the other LN implementations.
2017-09-12 17:58:48 +02:00
Olaoluwa Osuntokun
1e5949cfbb
lnwire: return more descriptive errors in DecodeFailure for onion errors 2017-09-12 17:55:25 +02:00
Olaoluwa Osuntokun
67aa519480
lnwallet: reverse order of signatures when spending the funding output
This commit is a follow up to the prior commit, as since we reversed
the order of the pubkeys in the multi-sig scripts, then we also need to
reverse the order of the signatures that we use when attempting to
spend the funding output directly.
2017-09-12 17:54:21 +02:00
Olaoluwa Osuntokun
eb2c8ba653
lnwallet: reverse the order of the pubkeys in the funding output
When creating the script for the funding output, we were reversing the
order of the public keys due to an incorrect assertion of the return
value of the bytes.Compare function. To fix this, we now flip the
order, allowing us to properly create channels as specified within the
specification.
2017-09-12 17:49:37 +02:00
Olaoluwa Osuntokun
5359476936
lnwallet: add new methods to ChannelReservation for dealing w/ chan constraints
This commit adds to methods to the ChannelReservation struct: one for
generating the channel constraints we require for the remote party, and
one for validating their desired constraints, and committing them to
our ChannelConfig.

With these two new methods, we can now begin to properly store and
adhere to the current set of channel flow control constraints.
2017-09-12 17:41:55 +02:00
Olaoluwa Osuntokun
5bb3efba4c
lnwallet: properly use the lsat 6-bytes of the sha hash for state hints
This commit fixes an existing w.r.t the way that we constructed all
commitment transactions. We were computing the hash that the obfsucator
was derived form correctly, but we were using the first 6-bytes, rather
than the last 6 bytes.
2017-09-12 17:38:31 +02:00
Olaoluwa Osuntokun
25766fc9ca
funding: use new failFundingFlow method when error encountered during funding 2017-09-12 17:31:29 +02:00
Olaoluwa Osuntokun
3701757cdc
funding: add new failFundingFlow method to fail flow and send funding error 2017-09-12 17:30:06 +02:00
Olaoluwa Osuntokun
c529597ff9
discovery: add more detail to error logging in processNetworkAnnouncement 2017-09-12 17:12:22 +02:00
Olaoluwa Osuntokun
5044cd6468
chainntnfs/btcdnotify: recognize JSON-RPC error in RegisterSpendNtfn
This commit fixes a prior bug in the logic for registering a new spend
notification. Previously, if the transaction wasn’t found in the
mempool or already confirmed within the chain, then
GetRawTransactionVerbose would return an error which would cause the
function itself to exit with an error.

This issue would then cause the server to be unable to start up as the
breach arbiter would be unable to register for spend notifications for
all the channels that it needed to be watching.

We fix this error simply by recognizing the particular JSON-RPC error
that will be returned in this scenario and treating it as a benign
error.
2017-09-12 17:11:47 +02:00
Olaoluwa Osuntokun
ed7eae819a
chainntnfs/btcdnotify: don't error if tx not found for historical conf dispatch
This commit fixes a prior mishandled error when attempting historical
confirmation dispatches. In the prior version of this code fragment, if
the transaction under the spotlight wasn’t found within the mempool, or
already in the chain, then an error would be returned by
b.chainConn.GetRawTransactionVerbose, which would case the function to
exit with an error. This behavior was incorrect, as during transaction
re-broadcasts, it was possible for transaction not yet to be a member
of either set.

We fix this issue by ensuring that we treat the JSON error code as a
benign error and continue with the notification registration.
2017-09-12 17:06:58 +02:00
Olaoluwa Osuntokun
fe0a7b6a09
multi: fix linter errors 2017-09-03 17:05:11 -07:00
Olaoluwa Osuntokun
53500127e3
test+config: add new --nobootstrap option to disable connection bootstrapping
This commit adds a new config option to allow callers to optionally
disable connection bootstrapping. This may be desirable for several
reasons, but primary, we add this so we can keep our integration tests
under the same context as before bootstrapping existed.
2017-09-03 17:05:05 -07:00
Olaoluwa Osuntokun
1196c2e254
server: introduce new peerBootstrapper goroutine to seed initial conns
This commit adds a new primary goroutine to the server struct:
peerBootstrapper. If peer boostrapping isn’t disabled in the config,
this new goroutine will be launched to attempt to establish a set of
initial connections for a new node. The logic is pretty straight
forward: first a set of initial connections is attempted, if after our
first epoch, we don’t have enough connections yet, then we’ll attempt
to query for an additional set. In each iteration, if we haven’t been
successful, then we increase our exponential backoff in order to not
spam any of our bootstrapping sources.
2017-09-03 16:58:21 -07:00
Olaoluwa Osuntokun
74ef963124
chains: add a set of BOLT-0010 DNS seeds for bitcoin 2017-09-03 16:53:33 -07:00
Olaoluwa Osuntokun
d5cc0441f4
chains: use distinct StaticFeeEstimator instances for Bitcoin and Litecoin 2017-09-03 16:53:09 -07:00
Olaoluwa Osuntokun
f823a860c8
discovery: add new interface NetworkPeerBootstrapper w/ 2 impls
This commit adds a new interface the to discovery package:
NetworkPeerBootstrapper. The NetworkPeerBootstrapper interface is meant
to be used to bootstrap a new peer joining the network to the set of
existing active peers within the network. Callers are encouraged to
utilize several boostrappers in series as redundant sources of
information. The MultiSourceBootstrap function will takes a set of
boostrappers, and compose their outputs into a single unified set of
addresses.

Two concrete implementations of the NetworkPeerBootstrapper interface
have been added as a part of this commit: the ChannelGraphBootstrapper
and the DNSSeedBootstrapper. The former will utilize the authenticated
node advertisements within the calling nodes view to boostrap new
connections. The latter will use a set of BOLT-0010 compliant DNS seeds
to query. This DNS seeding more will likely be used by nodes initial
joining the network, as they may not yet have the channel graph as they
haven’t connected to any peers.
2017-09-03 16:51:17 -07:00
Olaoluwa Osuntokun
0769cae565
autopilot: remove spammy trace log 2017-09-03 16:46:56 -07:00
Olaoluwa Osuntokun
2eb718e177
server: populate gossiper with chainhash of active chain 2017-09-03 16:41:43 -07:00
Olaoluwa Osuntokun
0b4ff2aabb
discovery: ignore any incoming channel ann's for an unknown chain
This commit fixes an existing bug in the announcement processing of the
authenticated gossiper. We will now only examine an incoming
announcement for validity if it targets the chain that we’re currently
active on.
2017-09-03 16:41:09 -07:00
Olaoluwa Osuntokun
1e513875e5
discovery: rename service.go to gossiper.go 2017-09-03 16:21:10 -07:00
Olaoluwa Osuntokun
f1501ebc95
discovery: rename validation.go to ann_validation.go 2017-09-03 16:18:28 -07:00
Olaoluwa Osuntokun
42743efa76
chainparams: ensure target chain checkpoints are properly set 2017-09-01 03:17:28 -07:00
Olaoluwa Osuntokun
5296df5d4d
build: update to latest version of roasbeef/btcutil and ltcsuite/ltcd
In this commit we’ve updated to the latest versions of roasbeef/btcutil
and ltcsuite/ltcd. With this change we fix two bugs:
  * The Bech32HRPSegwit parameter wasn’t being copied over in
applytLiteCoinParams
   * btcutil.DecodeAddress wasn’t properly using the passed net params
2017-09-01 02:16:24 -07:00
Olaoluwa Osuntokun
ff52ac374e
params: rename params.go to chainparams.go 2017-09-01 02:11:51 -07:00
Olaoluwa Osuntokun
2c556d11c7
build: update travis config to use go 1.9 and 1.8.3 2017-08-30 20:37:47 -07:00
Olaoluwa Osuntokun
73421caecc
lnwallet: don't attach the rpcclient to the lnwallet logging instance
We no longer attach the RPC client to the lnwallet logging instance as
it can generate a ton of spam in trace mode as it’ll dump the entire
hex encoded blocks, transactions, etc.
2017-08-30 20:32:37 -07:00
Olaoluwa Osuntokun
1ce6c4668e
funding: unconditionally forward all received errors to client
Previously, our old lnwire.Error message used a special code to
indicate different types of errors. With the recent push for spec
compatibility, we removed this field and instead stuffed the error into
the first byte of the error data. This works between lnd nodes, but
with other implementations they may send different errors which use a
different error scheme.

To fix this, we’ll now unconditionally return the error to the end
caller (if one exists).
2017-08-30 20:31:40 -07:00
Olaoluwa Osuntokun
7be039adec
multi: ensure that BlockEpoch clients are cancelled
This commit fixes a prior goroutine leak that could result in a node
having thousands of goroutines, particularly due to many concurrent
channel fundings. We now ensure that for each BlockEpoch client
created, we ensure that the client is cancelled once the creating
grouting exits.
2017-08-30 20:26:17 -07:00
Dave Collins
916ab454c1 channeldb: Fix payment serialization tests.
This modifies the tests that deal serializing the Invoice type to limit
the creation date to seconds since Go1.9 added the concept of a
monotonic component to times which does not round trip through
MarshalBinary and UnmarshalBinary and therefore causes the tests to fail.

In particular, it modifies the creation dates in the randInvoice,
makeFakePayment, makeRandomFakePayment, and TestInvoiceWorkflow
functions.

This results in allowing TestOutgoingPaymentSerialization,
TestOutgoingPaymentWorkflow, and TestInvoiceWorkflow to pass.
2017-08-30 18:57:39 -07:00
Dave Collins
42a263b29f wire: Correct fuzz test for MsgCommitSig.
This corrects the fuzz test in TestLightningWireProtocol for
MsgCommitSig to avoid creating an empty slice since the decoded message
only creates a slice when there are greater than zero signatures and an
empty slice is not considered equal to a nil slice under reflection.

This can be tested by running the TestLightningWireProtocol 1000 times
in a loop with and without this change.
2017-08-30 18:07:33 -07:00
Dave Collins
fc5d307c1a docs: Correct a couple of typos in README.md. (#290) 2017-08-30 17:34:28 -07:00
Olaoluwa Osuntokun
a43e9c6883
peer: check for ErrEdgeNotFound when loading chan edge for fwrding policy
This commit adds a precautionary check for the error returned if the
channel hasn’t yet been announced when attempting to read the our
current routing policy to initialize the channelLink for a channel.
Previously, if the channel wasn’t they announced, the function would
return early instead of using the default policy.

We also include another bug fix, that avoids a possible nil pointer
panic in the case that the ChannelEdgeInfo reread form the graph is
nil.
2017-08-30 15:34:27 -07:00
Olaoluwa Osuntokun
a52d405998
lnwallet: ensure HTLC values are properly converted to SAT in commit tx
This commit fixes a bug within the HTLC construction and commitment
transaction construction that would result in HTLC _values_ within the
commitment transaction being off by a factor of 1000. This was due to
the fact that we failed to convert the amount of an HTLC, in mSAT, to
SAT before placing it as an output within the commitment transaction.
When attempt to locate the output index of a particular half, we use
the unconverted amount, meaning it was unnoticed.

This commit adds a new assertion within the TestSimpleAddSettleWorkflow
test to ensure that the HTLC is found within the commitment transaction
with the proper value in satoshi.
2017-08-30 15:34:18 -07:00
Olaoluwa Osuntokun
af52aa838e
build: update glide commit hash to latest btcd+neutrino
This commit updates the glide hashes for btcd, neutrino, and btcwallet
to their latest versions. This change was prompted, as we've recently
fixed two bugs: one in btcd, and one in neutrino. The btcd in btcd was
due to not properly setting a pointer, which caused the new gcs related
RPC calls to now respond correctly. The neutrino bug was due to a nil
pointer panic that was triggered by not ensuring that we actually had a
`syncPeer` before referencing it.
2017-08-29 15:38:42 -07:00
Olaoluwa Osuntokun
19a843016e
build: update glide.lock to point to latest ltcd 2017-08-25 18:04:14 -07:00
Conner Fromknecht
4248836a2a lnd_test: use fresh Carol node for breach itest 2017-08-25 17:56:50 -07:00
Conner Fromknecht
85b76570ef lnd_test: increase startup timeout for breach itests 2017-08-25 17:56:50 -07:00
Conner Fromknecht
43b469be5a lnd_test: switch btcrpcclient to rpcclient 2017-08-25 17:56:50 -07:00
Conner Fromknecht
501e1dae23 breacharbiter_test: improves documentation for ba test cases 2017-08-25 17:56:50 -07:00
Conner Fromknecht
cfe1530205 breacharbiter: makes newline formatting consistent with lnd 2017-08-25 17:56:50 -07:00
Conner Fromknecht
c0f1d12521 utxonursery: refactors kidOutput SignDescriptor serialization 2017-08-25 17:56:50 -07:00
Conner Fromknecht
438c6b9621 lnwallet: move latest SignDescriptor + serialization 2017-08-25 17:56:50 -07:00
Conner Fromknecht
b7e426ecdc lnd_test: test breach persistence after breach conf 2017-08-25 17:56:50 -07:00