Commit Graph

8736 Commits

Author SHA1 Message Date
Johan T. Halseth
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
Johan T. Halseth
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
Johan T. Halseth
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
Johan T. Halseth
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
Johan T. Halseth
7b9c54996b
lnwallet/commitment: clarify keyring key ownership 2020-01-06 12:07:56 +01:00
Johan T. Halseth
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
Johan T. Halseth
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
Johan T. Halseth
13a108e578
lnwallet: make fundingTxIn not depend on LightningWallet 2020-01-06 11:42:03 +01:00
Johan T. Halseth
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
Johan T. Halseth
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
Johan T. Halseth
1a4f81ed90
lnwallet: remove duplicate chanCfg fields, use channelState 2020-01-06 11:42:02 +01:00
Johan T. Halseth
e2b050aca3
lnwallet: make addHtlc non-LightningChannel method
It has no dependency on LightningChannel
2020-01-06 11:42:02 +01:00
Johan T. Halseth
f0019006a7
lnwallet: remove unused initiator param to CreateCooperativeCloseTx 2020-01-06 11:42:02 +01:00
Johan T. Halseth
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
Olaoluwa Osuntokun
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
Olaoluwa Osuntokun
5ade9abe29
Merge pull request #3777 from guggero/shared-key
signrpc: add DeriveSharedKey
2020-01-02 16:02:47 -08:00
Olaoluwa Osuntokun
f289a39c1a
Merge pull request #3795 from joostjager/keysend
lncli+invoices: experimental key send mode
2019-12-24 17:38:46 -06:00
Joost Jager
4273bc0ba2
lntest/itest: add key send test 2019-12-23 21:51:27 +01:00
Joost Jager
bb1e2afc9f
lntest/itest: move single hop invoice test to separate file 2019-12-23 21:51:25 +01:00
Joost Jager
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
Joost Jager
c08865f4ae
lnrpc/invoicesrpc: add is_key_send flag to rpc invoice 2019-12-23 21:51:21 +01:00
Joost Jager
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
Joost Jager
202b7c26a7
invoices: move lock acquisition down
Move in separate commit to make next commit more readable.
2019-12-23 21:51:17 +01:00
Joost Jager
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
Joost Jager
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
Joost Jager
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
Joost Jager
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
Olaoluwa Osuntokun
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
Olaoluwa Osuntokun
e0d9bbfbc4
Merge pull request #3873 from matheusdtech/reenable-tests
Re-enable TestLightningWallet tests
2019-12-23 13:23:29 -06:00
Matheus Degiovani
5dffa7da1c lnwallet: Re-enable tests
Tests were erroneously disabled in commit b1940d67.
2019-12-23 10:32:03 -03:00
Matheus Degiovani
02d616d9b7 lnwallet: Fix external funding test 2019-12-23 10:31:03 -03:00
Carson Mullins
74d48510c8
Fix typo in "query" rpc for autopilot. 2019-12-22 20:19:36 -06:00
Olaoluwa Osuntokun
3de3ec8008
lntest/itest: add new test for external chan point funding 2019-12-20 19:09:56 -08:00
Olaoluwa Osuntokun
be4db0ebca
lntest: add optional FundingShim field to OpenChannelParams 2019-12-20 19:09:48 -08:00
Olaoluwa Osuntokun
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
Olaoluwa Osuntokun
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
Olaoluwa Osuntokun
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
Conner Fromknecht
72a49d486a
Merge pull request #3647 from cfromknecht/hex-jsonpb
build+lncli: default to hex encoding for byte slices
2019-12-20 18:23:52 -08:00
Olaoluwa Osuntokun
c9f39638b0
Merge pull request #3857 from kiwiidb/master
fix: incomplete comment about minFinalCLTVExpiry
2019-12-20 17:05:28 -08:00
Wilmer Paulino
9216ef2cd7
Merge pull request #3855 from cfromknecht/sorted-policies
routing/pathfind_test: construct sorted edge policies
2019-12-20 10:27:28 -08:00
kiwiidb
af1ff291a7 Merge branch 'master' of github.com:lightningnetwork/lnd 2019-12-20 15:00:20 +01:00
Joost Jager
6e0cfe579b
Merge pull request #3841 from joostjager/check-max-onion-size
routing: check max routing info size
2019-12-20 14:42:47 +01:00
Joost Jager
e3b9ed5cd8
Merge pull request #3863 from joostjager/fix-result-interpretation
routing: fix gap in result interpretation
2019-12-20 14:42:19 +01:00
Joost Jager
8d0205e9e4
Merge pull request #3831 from carlaKC/invoices-surfaceupdateresult
Add MPPTimeout ResolutionResult and expose to caller
2019-12-20 14:41:37 +01:00
carla
25a8773736
routing: interpret mpp timeout failues
This commit adds success mission control
results for all hops along the route in
a mpp timeout and takes no action for
the final hop along the route. This is a
temporary measure to prevent the default
logic from penalizing the final node while
we decide how to penalize mpp timeouts.
2019-12-20 13:02:30 +02:00
carla
b6f546503a
routerrpc: add MppTimeout code to failures 2019-12-20 13:02:19 +02:00
carla
e0c86f1e71
htlcswitch+invoices: fail mpp timeouts with FailMPPTimeout
This commit adds a getResolutionFailure function
which returns an appropriate wire failure based
on the outcome of a htlc resolution. It also updates
 the MissionControlStore test to ensure that lnd
can handle failures which occur due to mpp timeout.
2019-12-20 13:02:02 +02:00
carla
1d3bb5aed6
lnwire: add FailMPPTimeout message 2019-12-20 13:01:41 +02:00
carla
d2e395d5f2
multi: replace errInvoiceNotFound with resolution result
This commit moves handling of invoice not found
errors into NotifyExitHopHtlc and exposes a
resolution result to the calling functions. The
intention of this change is to make calling
functions as naive of the invoice registry's
mechanics as possible.

When NotifyExitHopHtlc is called and an invoice
is not found, calling functions can take action
based on the HtlcResolution's InvoiceNotFound
outcome rather than having to add a special error
check on every call to handle the error.
2019-12-20 13:01:15 +02:00
carla
7b5dda0417
invoices: add resolution result to htlcResolution
This commit adds the resolution result obtained
while updating an invoice in the registry to
htlcResolution. The field can be used by calling
functions to determine the outcome of the
update and act appropriately.
2019-12-20 13:00:53 +02:00