Commit Graph

2699 Commits

Author SHA1 Message Date
00ca97c789 lnwallet: in TestForceClose properly assign Bob's balance 2017-07-31 20:44:22 -07:00
1b61341410 lnwallet: when creating channels in tests, properly account for commitment fee 2017-07-31 20:43:38 -07:00
db793991ac lnwallet: don't add trimmed HTLC value to initiator commitment fees
This commit fixes a lingering bug in the way the internal channel state
machine handled fee calculation. Previously, we would count the dust
HTLC’s that were trimmed towards the fee that the initiator paid. This
is invalid as otherwise, the initiator would always benefit from dust
HTLC’s. Instead, we now simply “donate” the dust HTLC’s to the miner in
the commitment transaction. This change puts us in compliance with
BOLT-0003.
2017-07-31 20:41:23 -07:00
5ece7fec2d lnwallet: add a String() method to updateType 2017-07-31 20:37:51 -07:00
628c5cd63a features: add a new feature bit for recent changes 2017-07-30 20:27:56 -07:00
0f2fcf68b2 test: update testChannelFundingPersistence to use --defaultchanconfs 2017-07-30 20:26:38 -07:00
fa3fd9a19a test: update integration tests framework API usage to recent change
OpenPendingChannel and OpenChannel no longer take a number of
confirmations as a parameter.
2017-07-30 20:24:54 -07:00
d4a5eaa6ad lnwallet: modify CommitSpendNoDelay to directly craft witness
This commit modifies the CommitSpendNoDelay script witness generation
function. We must modify this function as all non-delayed outputs now
also require a key derivation. The current default
signer.ComputeInputScript implementation is unable to directly look up
the public key required as it attempt to target the pub key using the
pkScript.
2017-07-30 20:23:31 -07:00
e840f43db4 build: update glide to track latest lightning-onion commit 2017-07-30 20:22:21 -07:00
828c650bbc config: add new command line param --defaultchanconfs
This commit adds a new command line option that allows clients to
specify a default value to use when responding to a new channel funding
request. In a future change, a pure mapping will be added, with the
command line option having higher precedence.
2017-07-30 20:21:51 -07:00
747e0f57d1 multi: fix linter errors 2017-07-30 18:22:45 -07:00
563fac84cc breacharbiter: sweep commitment output in case of unilateral close
This commit adds a new responsibility to the breach arbiter: the
service is now responsible for sweeping the commitment outputs to-self,
in the case of a unilateral commitment broadcast by the remote party.
In this new commitment design, this output won’t be immediately
recognized by the wallet due to using a tweaked public key. As a
result, we need to sweep this output into the wallet manually.
2017-07-30 17:52:32 -07:00
8eadd09403 htlcswitch: add additional logging statement when forwarding HTLC's 2017-07-30 17:52:25 -07:00
07b0604458 lnwallet: add TweakPubKeyWithTweak helper function
This commit adds a new helper function which is identical to
TweakPubkey, but lets the caller specify their own hash tweak.
2017-07-30 17:52:22 -07:00
899fa1ea3e lnwallet: properly populate the signDesc within UnilateralCloseSummary
This commit modifies the closeObserver code to populate the signDesc in
the case we have a non-trimmed balance. Additionally, we now also add a
*wire.OutPoint field to the struct in order to allow receivers of the
message to construct a witness that can spend the newly created output
to their wallet.
2017-07-30 17:52:18 -07:00
8a23de5303 lnwallet: consult current state instead of revocation log during unilateral closure 2017-07-30 17:52:14 -07:00
db10772bd0 lnd: add initial skeleton functions for RequiredRemoteDelay+ NumRequiredConfs 2017-07-30 17:52:11 -07:00
a73589f3e9 lnd: properly initialize LightningWallet with new config 2017-07-30 17:52:07 -07:00
522712b9a6 breacharbiter: update wallet/signer API usage to due recent changes 2017-07-30 17:52:04 -07:00
458138f6fa utxonursery: update serialization, API usage for recent SignDescriptor changes 2017-07-30 17:52:00 -07:00
07212588fc funding: update funding workflow to adhere to BOLT-0002
This commit updates the main single-funder funding workflow within the
fundingManager (initiated via the rpcserver or by a message from a
connected peer) to fully adhere to the funding protocol outlined in
BOLT-0002.

The major changes are as follows:
  * All messages modified to use the new funding messages in BOLT-0002.
  * The initiator of a funding workflow no longer decides how many
confirmations must elapse before the channel can be considered open.
  * Rather than each side specifying their desired CSV delay, both
sides now specify the CSV delay for the _other_ party.
2017-07-30 17:51:57 -07:00
216cc3f919 test: update open channel methods in the testing framework 2017-07-30 17:51:54 -07:00
5ed9375e94 rpcserver: update RPC function impls to account for new API changes 2017-07-30 17:51:51 -07:00
0dfe73386b Cmd/lncli: remove num_confs as a param to the openchannel command 2017-07-30 17:51:48 -07:00
43b40c2ba2 lnrpc: remove num_confs as a parameter within OpenChannelRequest
This commit removes the num_confs parameter within the
OpenChannelRequest struct as it’s no longer applicable with the new
funding workflow. In the new funding workflow, it’s the responder that
decides how many confirmations are required.
2017-07-30 17:51:44 -07:00
34bb0ec36f server: within peerTerminationWatcher exit early if daemon is exiting 2017-07-30 17:51:41 -07:00
cd7b3290a8 peer: modify channel closing negotiation to create new delivery scripts
This commit modifies the channel close negotiation workflow to instead
take not of the fat that with the new funding workflow, the delivery
scripts are no longer pre-committed to at the start of the funding
workflow. Instead, both sides present their delivery addresses at the
start of the shutdown process, then use those to create the final
cooperative closure transaction.

To accommodate for this new change, we now have an intermediate staging
area where we store the delivery scripts for both sides.
2017-07-30 17:51:37 -07:00
01fe9adff0 peer: update logWireMessage to account for new lnwire messages 2017-07-30 17:51:34 -07:00
976dcb7b97 htlcswitch: update TestChannelLinkSingleHopMessageOrdering to ignore rev window 2017-07-30 17:51:31 -07:00
1d771eeb1b htlcswitch: ensure payments in TestChannelLinkBidirectionalOneHopPayments aren't dust
This commit modifies the TestChannelLinkBidirectionalOneHopPayments
test to ensure that each payment sent is safely above the dust
threshold. Note that the dust threshold itself is now higher due to the
existence of the HTLC covenant transactions which the HTLC values
themselves must cover.

This change ensure that this test operates under “normal” operation
conditions in order to catch any bugs introduced during a major change.
2017-07-30 17:51:27 -07:00
f8e536dff5 htlcswitch: update messageToString helper test func to new msgs 2017-07-30 17:51:23 -07:00
402112e6ee htlcswitch: update tests utilities to be aware of new commitment design 2017-07-30 17:51:20 -07:00
2d1a598b66 htlcswitch: modify channelLink to use new create+verify commitment API 2017-07-30 17:51:16 -07:00
f7c4237686 htlcswitch: remove initial revocation window extension in channelLink
We can safely remove the initial revocation window extension as this
has gone away with the new state machine. We instead now just fill the
window once the channel has been opened, and then maintain a fixed
window size of 2 from there on.
2017-07-30 17:51:13 -07:00
6ad9d218b0 lnwallet: update all channel unittests due to new commitment design 2017-07-30 17:51:09 -07:00
8121bc77ce lnwallet: add delivery scripts as a param to CreateCloseProposal+ CompleteCooperativeClose
This commit modifies the methods that transition the state of the
channel into an active closing state. With the new commitment design,
the delivery scripts are no longer pre-committed to the initial funding
messages. Instead, the scripts are sent at the instant that either side
decides to shutdown within the Shutdown message.
2017-07-30 17:51:05 -07:00
40e9120c04 lnwallet: populate HTLC resolutions after observing a unilateral channel close 2017-07-30 17:51:02 -07:00
01aa4eb2ae lnwallet: populate HTLC resolutions within the ForceCloseSummary 2017-07-30 17:50:59 -07:00
83e0116d7e lnwallet: extend the UnilateralCloseSummary to include HTLC resolutions
This commit adds a new companion struct: OutgoingHtlcResolution to the
commitment state machine. The purpose of this struct is the provide the
caller with the information necessary to sweep all outgoing HTLC’s in
the case of a broadcast up-to-date commitment transaction.

The HTLC resolutions allow a caller to sweep an outgoing HTLC into
their wallet after the absolute timeout of the HTLc has passed. This is
a two step process, with the first portion consisting of broadcasting
the HTLC timeout transaction itself, and the second portion consisting
of claiming the HTLC itself after a CSV delay.
2017-07-30 17:50:55 -07:00
a4c07d061e lnwallet: the BreachRetribution struct is now aware of HTLC outputs
This commit adds awareness of active HTLC outputs to the
BreachRetribution struct. Previously, in the case of a breach, the
struct was only populated with enough information to sweep the two
commitment outputs. With this commit, the struct now has enough
information to sweep _all_ outputs within the commitment transaction.
2017-07-30 17:50:51 -07:00
5a78f80ffe lnwallet: update restoreStateLogs to be aware of new commitment scheme 2017-07-30 17:50:47 -07:00
b9da43a2b8 lnwallet: update fetchCommitmentView due to new commitment design
This commit updates the central fetchCommitmentView method to manage
and derive the necessary easy required to create new commitments due to
the new state machine design within the specification. Each state now
requires us to derive a number of keys for each commitment state:
localDelay, remoteDelay, localKey, remoteKey, the commitment point, and
finally the revocation key itself.
2017-07-30 17:50:43 -07:00
3a052d2874 lnwallet: when creating new states, dispatch HTLC signing to sigPool 2017-07-30 17:50:40 -07:00
f569b80a80 lnwallet: when verifying new states, dispatch HTLC sig validation to sigPool 2017-07-30 17:50:37 -07:00
cd8672f824 lnwallet: update CreateCommitTx due to new key derivation 2017-07-30 17:50:34 -07:00
e314b83559 lnwallet: update HTLC script generation to account for new covenant HTLC's
This commit updates the set of functions tasked with generating HTLC’s
scripts for new commitments to now adhere to the new commitment
transaction design. With this change, the process of claiming an HTLC
now requires a second-level HTLC transaction, which solves a prior
issues due to the tight coupling of the timeout and delay clauses when
claiming an HTLC.
2017-07-30 17:50:31 -07:00
8b9a58cb15 lnwallet: add a sigPool instances to the state machine struct 2017-07-30 17:50:27 -07:00
4c9bd9dc54 lnwallet: when handling possible channel breach, only log if contract breach 2017-07-30 17:50:24 -07:00
e56258917e lnwallet: introduce populateHtlcIndexes for tracking HTLC indexes in commitments
This commit adds a new method to the commitment struct:
populateHtlcIndexes.  populateHtlcIndexes modifies the set of HTLC's
locked-into the target view to have full indexing information
populated. This information is required as we need to keep track of the
indexes of each HTLC in order to properly write the current state to
disk, and also to locate the PaymentDescriptor corresponding to HTLC
outputs in the commitment transaction.

We also modify toChannelDelta to take not of these new changes, and
access the appropriate index directly.
2017-07-30 17:50:21 -07:00
549688d793 lnwallet: remove isDustLocal and isDustRemote, replace w/ htlcIsDust
This commit modifies the way we account for dust HTLC’s within the
commitment state machine when creating and validating new states.
Previously, an HTLC was dust if the amount of the HTLC was below the
dustLimit of the commitment chain. Now, with the HTLC covenant
transaction, the value of the HTLC also needs to cover the required fee
of the HTLC covenant transaction at the specified fee rate of the
commitment chain.

As a result, we now determine if an HTLC is dust or not, only at the
commitment site, using the new htlcIsDust function.
2017-07-30 17:50:16 -07:00