Commit Graph

8371 Commits

Author SHA1 Message Date
Joost Jager
3a2ca434fe htlcswitch/hop: fix logging
Logging for the hop package is controlled via the parent htlcswitch
package. Unfortunately the parent package only controlled the
initialization, but didn't enable the logger when the log level came
in from the main lnd package.
2019-09-09 13:52:35 +02:00
Olaoluwa Osuntokun
62dcc4b7d5
channeldb: ensure test for migration 9 is fully enclosed
In this commit, we ensure that the test for migration 9 uses the same
encoding/decoding functions as was present in the repo when the
migration was first added. Otherwise, the test will fail as it'll try to
use the decoding functions of master (migration 10 and onwards) rather
than the decoding function of migration 9.
2019-09-09 03:57:52 -07:00
Olaoluwa Osuntokun
1f92b7587c
Merge pull request #3468 from joostjager/move-onion-processor
htlcswitch: move hop iterator into htlcswitch/hop package
2019-09-09 03:29:41 -07:00
chokoboko
ac617a0d01 channeldb: return errors in various missed places 2019-09-09 02:41:43 -07:00
Spencer Dupre
e2d5825df0 docs: update INSTALL.md to include first wallet creation (#3403)
Add 'Creating a wallet' section, explaining that 'lncli create' must be run
with a new instance. Also describe the password prompt and mnemonic this
command presents to the user.
2019-09-09 02:37:23 -07:00
Olaoluwa Osuntokun
918fd9e8ff
Merge pull request #3282 from halseth/mobile-rpcs
[mobile] Mobile RPCs
2019-09-09 02:23:26 -07:00
Olaoluwa Osuntokun
acb38a8b8b
Merge pull request #3479 from Roasbeef/migration-9-10-fix-min-version
channeldb: fix migration bug due to interplay between migration #9 an…
2019-09-09 02:20:49 -07:00
Olaoluwa Osuntokun
754809406d
channeldb: fix migration bug due to interplay between migration #9 and #10
In this commit, we fix an issue that was recently introduced as a result
of migration #10. The new TLV format ended up modifying the
serialization functions called in `serializePaymentAttemptInfo`.
Migration #9, also used this `serializePaymentAttemptInfo` method to
serialize the _new_ (pre TLV, but new payment attempt structure) routes
into the database during its migration. However, migration #10 failed to
copy over the existing unmodified `serializePaymentAttemptInfo` method
into the legacy serialization for migration #9. As a result, once
migration #9 was run, the routes/payments were serialized using the
_new_ format, rather than the format used for v0.7.1. This then lead to
de-serialization either failing, or causing partial payment corruption
as migration #10 was expecting the "legacy" format (no TLV info).

We fix this issue by adding a new fully enclosed
`serializePaymentAttemptInfoMigration9`method that will be used for
migration #9. Note that our tests didn't catch this, as they test the
migration in isolation, rather than in series which is how users will
encounter the migrations.

Fixes #3463.
2019-09-09 02:16:13 -07:00
Johan T. Halseth
78e87d148f
Merge pull request #3475 from chokoboko/fix-pilot-log-message
trivial: fix log message in initAutoPilot
2019-09-09 10:25:46 +02:00
chokoboko
c38f241b51 pilot: fix log message in initAutoPilot 2019-09-06 17:04:47 +03:00
Conner Fromknecht
6015567927
htlcswitch/iterator: validate presence/omission of payload types
From BOLT 04:

The writer:
 - MUST include amt_to_forward and outgoing_cltv_value for every node.
 - MUST include short_channel_id for every non-final node.
 - MUST NOT include short_channel_id for the final node.
2019-09-05 09:32:03 -07:00
Conner Fromknecht
aefec9b10f
tlv: return parsed types from DecodeWithParsedTypes
This commit adds an additional return value to
Stream.DecodeWithParsedTypes, which returns the set of types that were
encountered during decoding. The set will contain all known types that
were decoded, as well as unknown odd types that were ignored.

The rationale for the return value (rather than an internal member) is
so that the stream remains stateless.

This return value can be used by callers during decoding to make
assertions as to whether specific types were included in the stream.
This is need, for example, when parsing onion payloads where certain
fields must be included/omitted depending on the hop type.

The original Decode method would incur the additional performance hit of
needing to track the parsed types, so we can selectively enable this
functionality when a decoder requires it by using a helper which
conditionally tracks the parsed types.
2019-09-05 09:30:37 -07:00
Joost Jager
e54b24289f
htlcswitch: move hop iterator into htlcswitch/hop package
Prepares for onion blob decoding outside of htlcswitch.
2019-09-05 15:30:31 +02:00
Joost Jager
fb565bcd5d
Merge pull request #3449 from joostjager/route-success-prob
routerrpc: report route success probability
2019-09-05 12:34:18 +02:00
Joost Jager
6638e1ddde
Merge pull request #3466 from cfromknecht/htlcswitch-hop
htlcswitch/hop: new package for hop payload parsing/encapsulation
2019-09-05 12:31:23 +02:00
Conner Fromknecht
138b0798f5
htlcswitch/iterator: use hop.Payload constructors 2019-09-05 01:35:24 -07:00
Conner Fromknecht
378e0558c5
htlcswitch/hop: move hop.Exit and hop.Source to hop pkg 2019-09-05 01:35:23 -07:00
Conner Fromknecht
fc0e4be4d8
htlcswitch+hop: move ForwardingInfo to hop.ForwaringInfo 2019-09-05 01:35:23 -07:00
Conner Fromknecht
83d2112e8b
htlcswitch/hop: move NetworkHop to hop.Network 2019-09-05 01:35:20 -07:00
Johan T. Halseth
a8cb1c80eb
mobile: add README 2019-09-05 09:22:54 +02:00
Johan T. Halseth
fef2074c1d
mobile: add sample_lnd.conf 2019-09-05 09:22:54 +02:00
Johan T. Halseth
3aa9f18395
make: define make android, make mobile (ios+android) 2019-09-05 09:22:54 +02:00
Johan T. Halseth
4dcaea1f5d
make: define make ios, make vendor 2019-09-05 09:22:54 +02:00
Johan T. Halseth
8a92ccbbf4
mobile/bindings: add mobile bindings 2019-09-05 09:22:54 +02:00
Johan T. Halseth
a5c63786c6
make+mobile: define gen_bindings.sh
gen_bindings uses falafel to generate Go bindings from the lnrpc
protos.
2019-09-05 09:22:54 +02:00
Johan T. Halseth
fa21601d07
lnd+cmd/lnd/main: add ListenerCfg to Main
ListenerCfg allows passing custom listeners to the main method, to be
used for the wallet unlocker and rpc server. If these are set these will
be used instead of the regular RPC listeners.
2019-09-05 09:22:54 +02:00
Johan T. Halseth
2562fdbdda
lnd+rpcserver: extract listener setup into closure 2019-09-05 09:22:54 +02:00
Johan T. Halseth
187bd29d2d
gitignore: add mobile/build 2019-09-05 09:22:53 +02:00
Joost Jager
99a920f2a3
routerrpc: report route success probability
The intention of adding this field is to make probability based path
finding more transparent and help understand why a route is returned.
2019-09-05 08:35:04 +02:00
Olaoluwa Osuntokun
866867a4b0
Merge pull request #3401 from wpaulino/channel-initiator-max-fee
htlcswitch: avoid proposing fee updates exceeding max fee allowed
2019-09-04 20:38:52 -07:00
Olaoluwa Osuntokun
b43a9f2e20
Merge pull request #1583 from halseth/multibackend-integration-test
[itests] Bitcoind integration test
2019-09-04 20:12:26 -07:00
Olaoluwa Osuntokun
00682584aa
Merge pull request #3441 from cfromknecht/truncated-sid
htlcswitch+routing: omit next_hop_id in final hop payload
2019-09-04 19:55:38 -07:00
Olaoluwa Osuntokun
7eca7b02a6
Merge pull request #3390 from joostjager/invoice-circuits
channeldb+cnct+invoices: track invoice htlcs
2019-09-04 19:51:37 -07:00
Conner Fromknecht
947cc50c13
routing/route/route: prevent modification of hop.TLVRecords
Currently the underlying array backing the hop's TLVRecords is modified
when combining custom records with the primitive forwarding info. This
commit uses a fresh slice to prevent modifications from mutating the
hop itself.
2019-09-04 14:14:34 -07:00
Wilmer Paulino
38c64b2030
Merge pull request #3433 from halseth/atpl-nodescore-tracelogs
[autopilot] Add trace logging during node scoring
2019-09-04 13:04:10 -07:00
Wilmer Paulino
d1a4fe7e2e
Merge pull request #2088 from wpaulino/lower-mempool-spend-check-timeout
chainntnfs/interface_test: lower mempool spend check timeout
2019-09-04 12:08:06 -07:00
Conner Fromknecht
278e10a2fd
routing/route/route: omit next_hop_id for final hop
BOLT04 says to omit this field for final hops, but must be present on
all other hops.
2019-09-04 12:05:10 -07:00
Conner Fromknecht
1b2c9a02b5
record+tlv/onion_types: move type constants to route/hop 2019-09-04 12:05:10 -07:00
Conner Fromknecht
dc0f429271
htlcswitch+routing: use TLV hop constructors 2019-09-04 12:05:09 -07:00
Conner Fromknecht
495f80e0bc
record/hop: add primitive hop TLV record constructors 2019-09-04 12:05:09 -07:00
Joost Jager
45cd76e9eb
lnrpc+invoicesrpc: report invoice htlcs 2019-09-04 19:20:33 +02:00
Joost Jager
d6d9ec6aa5
invoices: replay awareness
Previously the invoice registry wasn't aware of replayed htlcs. This was
dealt with by keeping the invoice accept/settle logic idempotent, so
that a replay wouldn't have an effect.

This mechanism has two limitations:

1. No accurate tracking of the total amount paid to an invoice. The total
amount couldn't just be increased with every htlc received, because it
could be a replay which would lead to counting the htlc amount multiple
times. Therefore the total amount was set to the amount of the first
htlc that was received, even though there may have been multiple htlcs
paying to the invoice.

2. Impossible to check htlc expiry consistently for hodl invoices. When
an htlc is new, its expiry needs to be checked against the invoice cltv
delta. But for a replay, that check must be skipped. The htlc was
accepted in time, the invoice was moved to the accepted state and a
replay some blocks later shouldn't lead to that htlc being cancelled.
Because the invoice registry couldn't recognize replays, it stopped
checking htlc expiry heights when the invoice reached the accepted
state. This prevents hold htlcs from being cancelled after a restart.
But unfortunately this also caused additional htlcs to be accepted on an
already accepted invoice without their expiry being checked.

In this commit, the invoice registry starts to persistently track htlcs
so that replays can be recognized. For replays, an htlc resolution
action is returned early. This fixes both limitations mentioned above.
2019-09-04 19:20:31 +02:00
Joost Jager
53eea09b63
channeldb: add now function
Needed for time control in unit tests.
2019-09-04 19:20:29 +02:00
Joost Jager
c8fa51f865
invoices: refactor invoice update callback
This commit refactors the invoice registry accept/settle logic so that
it doesn't rely anymore on a set of error values to indirectly
communicate from the update callback to the main function what action is
required on the htlc.
2019-09-04 19:20:27 +02:00
Joost Jager
144856757d
channeldb+invoices: move invoice cancel logic into registry
This commit is a continuation of the centralization of invoice state
transition logic in the invoice registry.
2019-09-04 19:20:25 +02:00
Joost Jager
416bc8c68c
channeldb+invoices: move hold invoice settle logic into registry
This commit is a continuation of the centralization of invoice state
transition logic in the invoice registry.
2019-09-04 19:20:23 +02:00
Joost Jager
ad3522f1a6
channeldb+invoices: move invoice accept or settle logic into registry
As the logic around invoice mutations gets more complex, the friction
caused by having this logic split between invoice registry and channeldb
becomes more apparent. This commit brings a clearer separation of
concerns by centralizing the accept/settle logic in the invoice
registry.

The original AcceptOrSettle method is renamed to UpdateInvoice because
the update to perform is controlled by the callback.
2019-09-04 19:20:21 +02:00
Joost Jager
c1345a4117
multi: use separate cltv expiry field from invoice
Now that the Invoice struct contains the decoded final cltv delta value,
the decoding of payment requests can be removed from the invoice
registry.
2019-09-04 19:20:19 +02:00
Joost Jager
4105142c96
channeldb+invoices: add invoice htlcs
This commit adds a set of htlcs to the Invoice struct and
serializes/deserializes this set to/from disk. It is a preparation for
accurate invoice accounting across restarts of lnd.

A migration is added for the invoice htlcs.

In addition to these changes, separate final cltv delta and expiry
invoice fields are created and populated. Previously it was required
to decode this from the stored payment request. The reason to create
a combined commit is to prevent multiple migrations.
2019-09-04 19:20:17 +02:00
Joost Jager
061b34b924
channeldb: add int64 to codec 2019-09-04 19:20:15 +02:00