Commit Graph

9250 Commits

Author SHA1 Message Date
41c207e247 lnwallet/test: describe existing bug after restart with dangling remote updates 2020-01-06 15:30:23 +01:00
b3bd470962 lnwallet: restore missing field in local log update
When restoring an htlc fulfill update from disk, the payment hash wasn't
restored previously.
2020-01-06 15:13:21 +01:00
4f98642b5e signrpc: derive custom shared key
With this commit we add the ability to create a shared DH key by using
a custom node private key instead of the node's identity private key.
If no key locator is specified the node's identity private key will be
used as a fallback.
2020-01-06 14:53:32 +01:00
9c3218c51e lnwallet/channel: reuse derived SingleTweak on local force close
When creating the keyring, the tweak is already calculated in the remote
commitment case. We add the calculation also for our own commitment, so
we can use it in all cases without deriving the tweak.
2020-01-06 12:08:29 +01:00
3711597fef input: remove duplicate commit weight constant 2020-01-06 12:08:25 +01:00
a56ed72bd7 lnwallet: use channel type to derive remote script
Based on the current channel type, we derive the script used for the
to_remote output. Currently only the unencumbered p2wkh type is used,
but that will change with upcoming channel types.
2020-01-06 12:08:19 +01:00
9b5809a884 input: update SignDescriptor doc to note only segwit is supported
Also update the WitnessScript doc to note it should be set also for
p2wkh.
2020-01-06 12:08:14 +01:00
f92c7a3af0 lnwallet: nil single tweak when creating keyring
To make the channel state machine less concerned about the type of
commitment, we nil the local tweak when creating the keyring, depending
on the commitment type.
2020-01-06 12:08:09 +01:00
5e3718a1b5 lnwallet: use channel type to derive keys
We abstract away how keys are generated for the different channel types
types (currently tweak(less)).

Intention is that more of the logic that is unique for each commitment
type lives in commitment.go, making the channel state machine oblivious
to the keys and outputs being created on the commitment tx for a given
channel state.
2020-01-06 12:08:05 +01:00
4fde31229c lnwallet: rename DelayKey->ToLocalKey, NoDelayKey->ToRemoteKey
Since both parties are going to have their ouputs delayed, we move way
from the DelayKey naming, and instead use ToLocalKey and ToRemoteKey.
2020-01-06 12:08:01 +01:00
7b9c54996b lnwallet/commitment: clarify keyring key ownership 2020-01-06 12:07:56 +01:00
76ce51301e lnwallet: return instead evaluated commitment instead of mutating
createCommitmentTx would earlier mutate the passed commitment struct
after evaluating the htlc view and calculating the final balances, which
was confusing since the balances are supposed to only be *after*
subtracting fees.

Instead we take the needed parameters as arguments, and return the final
balances, tx and fee to populate the commitment struct in a proper way.
2020-01-06 12:07:49 +01:00
613d771daf lnwallet: create CommitmentBuilder
We define a new struct CommitmentBuilder that will be used to craft the
final commitment transaction based on the current active channel type.
2020-01-06 11:42:03 +01:00
13a108e578 lnwallet: make fundingTxIn not depend on LightningWallet 2020-01-06 11:42:03 +01:00
83e0d47ba3 lnwallet: move methods to commitment.go
PURE CODE MOVE:
Moving createCommitmentTx, CreateCommitTx, createStateHintObfuscator,
CommitmentKeyRing, DeriveCommitmentKeys, addHTLC, genHtlcScripts

We move the methods and structs to a new file commitment.go in
preparation for defining all the logic that is dependent on the channel
type in this new file.
2020-01-06 11:42:03 +01:00
fff9dbe6f3 lnwallet: pass chan cfgs to CreateCommitTx
Instead of passing delays and dustlimits separately, we pass the correct
channel config to CreateCommitTx from the POV of the local party that
owns the commit tx.

To make it more clear which commitment we are actually creating, we
rename variables to denote local and remote, to prepare for the case
when both outputs might be delayed.
2020-01-06 11:42:03 +01:00
1a4f81ed90 lnwallet: remove duplicate chanCfg fields, use channelState 2020-01-06 11:42:02 +01:00
e2b050aca3 lnwallet: make addHtlc non-LightningChannel method
It has no dependency on LightningChannel
2020-01-06 11:42:02 +01:00
f0019006a7 lnwallet: remove unused initiator param to CreateCooperativeCloseTx 2020-01-06 11:42:02 +01:00
2c46640dd0 channeldb+lnwallet: note that balance is after subtracting commit fee
It was incorrectly stated that the commitment balance was before
subctracting the commit fee, which led to some confusion.
2020-01-06 11:42:02 +01:00
1f457ac1a8 docker: enable docker-compose up command for btc and ltc compose files 2020-01-03 12:25:48 -06:00
eb96470c7f build: add version checks to release script
Enhances the release script to check that the specified tag
is also the tag that is currently checked out. In addition to that, the
script also ensures that the tag and the version specified in version.go
match.
2020-01-03 14:05:56 +01:00
ae1f7348f0 lntest: fix macaroon paths
This change makes sure that all macaroons are stored in the same
folder. This makes it possible to use the lntest package in external
projects that use loop's lndclient library which currently assumes
that the admin macaroon and subserver macaroons are in the same sub
folder of lnd's data directory.
2020-01-03 09:19:18 +01:00
ce711a1de7 lntest: specify lnd binary
Integration tests in external projects might not have the same folder
structure as lnd does. Therefore we want to allow the path to the
lnd itest binary to be configurable.
2020-01-03 09:17:23 +01:00
b762d441cf lntest: expose configuration of harness node
When using the lntest package for itests in external projects, it
is necessary to access a harness node's configuration, for example
to get its data directory on disk. This commit exports that
configuration.
2020-01-03 09:13:29 +01:00
22e1f006b1 Merge pull request #3870 from Septem151/rpc-autopilot-fix
Fix typo in "query" rpc for autopilot.
2020-01-02 16:03:05 -08:00
5ade9abe29 Merge pull request #3777 from guggero/shared-key
signrpc: add DeriveSharedKey
2020-01-02 16:02:47 -08:00
4e0ada9ea3 routing: clean up locking on topology change 2020-01-02 18:03:48 +01:00
b6ea7d5f6c config: Make bools in sample-lnd.conf consistent 2019-12-29 14:12:06 +01:00
f289a39c1a Merge pull request #3795 from joostjager/keysend
lncli+invoices: experimental key send mode
2019-12-24 17:38:46 -06:00
4273bc0ba2 lntest/itest: add key send test 2019-12-23 21:51:27 +01:00
bb1e2afc9f lntest/itest: move single hop invoice test to separate file 2019-12-23 21:51:25 +01:00
b1206f67c2 lncli: send key
Extend lncli with a flag that indicates the intention to send
a spontaneous payment. lncli will generate a preimage/hash combination
and send the preimage as a custom record to the recipient.
2019-12-23 21:51:23 +01:00
c08865f4ae lnrpc/invoicesrpc: add is_key_send flag to rpc invoice 2019-12-23 21:51:21 +01:00
1d5844c196 invoices: jit insert key send invoices
This commit adds handling code for the key send custom record. If this
record is present and its hash matches the payment hash, invoice
registry will insert a new invoice into the database "just in time". The
subsequent settle flow is unchanged. The newly inserted invoice is
picked up and settled. Notifications will be broadcast as usual.
2019-12-23 21:51:19 +01:00
202b7c26a7 invoices: move lock acquisition down
Move in separate commit to make next commit more readable.
2019-12-23 21:51:17 +01:00
6063dc31fc lnrpc/invoicesrpc: support empty payment request fields
Prepares for spontaneous key send payments that do not have a payment
request.
2019-12-23 21:51:15 +01:00
15eedd2b1a lncli: remove debug send
Debug send has been removed some time ago. This is a left over.
2019-12-23 21:51:13 +01:00
af1b8a549d channeldb: update payment request comment
This field isn't optional. It was introduced in
5ed31b1030 which was part of release
0.4.0. This release contained breaking database changes, so it is safe
to assume that from there on the field is always populated.

If there would still be empty payment request fields in the wild, users
would also experience issues with ListInvoices. ListInvoices decodes the
payment request.
2019-12-23 21:51:11 +01:00
c89f0dc7c1 invoices/test: lower test delay
Previously 5 seconds was used, which made the otherwise fast registry
tests relatively slow.
2019-12-23 21:51:10 +01:00
7eacc40419 Merge pull request #3722 from Roasbeef/external-funding-rpc
lnrpc+lnwallet+funding: implement new RPCs to enable external channel funding
2019-12-23 14:41:46 -06:00
e0d9bbfbc4 Merge pull request #3873 from matheusdtech/reenable-tests
Re-enable TestLightningWallet tests
2019-12-23 13:23:29 -06:00
5dffa7da1c lnwallet: Re-enable tests
Tests were erroneously disabled in commit b1940d67.
2019-12-23 10:32:03 -03:00
02d616d9b7 lnwallet: Fix external funding test 2019-12-23 10:31:03 -03:00
74d48510c8 Fix typo in "query" rpc for autopilot. 2019-12-22 20:19:36 -06:00
3de3ec8008 lntest/itest: add new test for external chan point funding 2019-12-20 19:09:56 -08:00
be4db0ebca lntest: add optional FundingShim field to OpenChannelParams 2019-12-20 19:09:48 -08:00
bc176b5aa3 rpc+lnwallet: implement new FundingStateStep RPC method
In this commit, we implement the currently defined transition methods
for the new `FundingStateStep` method. At this point, we're now able to
serve the "responder" of the externally initiated channel funding flow
by being able to register and cancel a funding flow according to its
expected pending channel ID.
2019-12-20 19:09:44 -08:00
91bd56dbd1 funding+rpc: expand specified chan point shim into a canned assembler
In this commit, we update the `OpenChannel` method to observe the new
`funding_shim` field in the main open channel request. If this is
specified, and is a channel point shim, then we'll create a custom
`chanfunding.Assembler` for the wallet to use in place of the regular
funding workflow.

With this commit, the "initiator" of an external funding flow can now
delegate the remainder of the channel funding workflow to lnd.
2019-12-20 19:09:41 -08:00
3eed38d602 lnrpc: add ability to provide chan point shims for funding, new funding modifiers
In this commit, we start to expose some of the new external funding
functionality over the RPC interface.

First, we add a new `funding_shim` field to the regular `OpenChannel`
method. This can be used by a caller to express that certain parameters
of the funding flow have already been negotiated outside the protocol,
and should be used instead. For example, a shim can be provided to use a
particular key for the commitment key (ideally cold) rather than use one
this is generated by the wallet as normal, or signal that signing will
be carried out in an interactive manner (PSBT based).

Next, we add a brand new method: `FundingStateStep`. FundingStateStep is
an advanced funding related call that allows the caller to either
execute some preparatory steps for a funding workflow, or manually
progress a funding workflow. The primary way a funding flow is
identified is via its pending channel ID. As an example, this method can
be used to specify that we're expecting a funding flow for a particular
pending channel ID, for which we need to use specific parameters.
Alternatively, this can be used to interactively drive PSBT signing for
funding for partially complete funding transactions.

The new transition methods (funding state machine modifiers) in this
commit allow a party to register a funding intent that should be used
for a specified incoming pending channel ID. The "responder" to the
external channel flow should use this to prep lnd to be able to handle
the channel flow properly.
2019-12-20 19:09:38 -08:00