Commit Graph

77 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
85b2b52a5f
lnwallet: add concrete type for coin selection fail during funding workflow 2016-09-26 12:18:03 -07:00
Olaoluwa Osuntokun
0013b804c0
lnwallet: display target+current amount when coin selection fails for funding txns 2016-09-26 11:52:56 -07:00
Olaoluwa Osuntokun
7310d0a0f7
lnwallet: remove extraneous logging messages 2016-09-21 19:48:46 -07:00
Olaoluwa Osuntokun
49ce1040d4
lnwallet: adopt simple fee structure for commitment transactions
This commit modifies the prior funding workflow to account for fees
when creating the funding output. As a stop gap, the current fee for
the commitment transaction is now hard-coded at 5k satoshis. Once the
fee models are in place this should instead be some high multiple of
the current “average” fee rate within the network, continuing, the
proper fee should be adjusted from the commitment transaction has
outputs are added/removed.
2016-09-12 19:08:01 -07:00
Olaoluwa Osuntokun
d0353b2864
lnwallet: add ability to trigger a force closure within channel state machine
This commit introduces the concept of a manually initiated “force”
closer within the channel state machine. A force closure is a closure
initiated by a  local subsystem which broadcasts the current commitment
state directly on-chain rather than attempting to cooperatively
negotiate a closure with the remote party.

A force closure returns a ForceCloseSummary which includes all the
details required for claiming all rightfully owned outputs within the
broadcast commitment transaction.

Additionally two new publicly exported channels are introduced, one
which is closed due a locally initiated force closure, and the other
which is closed once we detect that the remote party has executed a
unilateral closure by broadcasting their version of the commitment
transaction.
2016-09-12 19:07:35 -07:00
Olaoluwa Osuntokun
671098325d
lnwallet: refactor all wallet/channel interaction to use the WalletController.
This commit performs a major refactor of the current wallet,
reservation, and channel code in order to call into a WalletController
implementation rather than directly into btcwallet.

The current set of wallets tests have been modified in order to test
against *all* registered WalletController implementations rather than
only btcwallet. As a result, all future WalletControllers primary need
to ensure that their implementation passes the current set of tests
(which will be expanded into the future), providing an easy path of
integration assurance.

Rather than directly holding the private keys throughout funding and
channel creation, the burden of securing keys has been shifted to the
specified WalletController and Signer interfaces. All signing is done
via the Signer interface rather than directly, increasing flexibility
dramatically.

During channel funding, rather than creating a txscript.Engine to
verify commitment signatures, regular ECDSA sig verification is now
used instead. This is faster and more efficient.

Finally certain fields/methods within ChannelReservation and
LightningChannel have been exposed publicly in order to restrict the
amount of modifications the prior tests needed to undergo in order to
support testing directly agains the WalletController interface.
2016-09-08 12:25:54 -07:00
Olaoluwa Osuntokun
99fdb3a3a9
lnwallet: modify elkrem root derivation, derive from root HD seed
This commit modifies the elkrem root derivation for each newly created
channel. First a master elkrem root is derived from the rood HD seed
generated from private wallet data. Next, a HKDF is used with the
secret being the master elkrem root.
2016-09-08 12:25:49 -07:00
Olaoluwa Osuntokun
773c831561
lnwallet: replace naive coin selection a size+fee aware version 2016-09-08 12:25:36 -07:00
Olaoluwa Osuntokun
8bbd010f74
lnwallet: use the ChainNotifier interface throughout instead of BtcdNotifier
This commit refactors the code within lnwallet interacting with the
ChainNotifier to accept, and call against the implementation rather
than a single concrete implementation.

LightningWallet no longer creates it’s own BtcdNotifier implementation
doing construction, now instead accepting a pre-started `ChainNotifier`
interface.  All imports have been updated to reflect the new naming
scheme.
2016-09-01 19:13:19 -07:00
Olaoluwa Osuntokun
8a56fbf196
lnwallet: switch name of package logger to avoid module collision 2016-07-27 11:29:07 -07:00
Olaoluwa Osuntokun
a14246c5bb
lnwallet: use two-value read from conf channel to detect closure 2016-07-14 16:17:10 -07:00
Olaoluwa Osuntokun
8775107454
lnwallet: keep commitments cold at all times, store sig instead
This commit changes prior behavior which stored a “hot” commitment
transaction, meaning one which all the sigScript fully assembled and
able to be broadcast.

Instead, we now store the current signature for our commitment
transaction as a separate field within the database and within memory.
As a result, this eliminates a class of bugs which would erroneously
broadcast a fully loaded commitment transaction, either leading to a
loss of funds, or suspending availability to funds for a period of
time.
2016-07-05 16:55:47 -07:00
Olaoluwa Osuntokun
2c187209eb
lnwallet: update internal wallet reservations to use revoke keys
This update the wallet to implement the new single funder workflow
which uses revocation keys rather than revocation hashes for the
commitment transactions.
2016-06-30 12:13:50 -07:00
Olaoluwa Osuntokun
31e5466692
lnd: introduce the fundingManager
This commit introduces the fundingManger which is used as a bridge
between the wallet’s internal ‘ChannelReservation’ workflow, and the
wire protocol’s funding messages.

 The funding manger is responsible for progressing the workflow, and
communicating any errors generated during the workflow back to the
source peer.
2016-06-21 13:13:49 -07:00
Olaoluwa Osuntokun
3a14fe8ba5
lnwallet: add support for single funder workflow
This commit modifies the existing workflow to add additional paths to
be used when on the responding side of a single funder workflow.

Additionally, several bugs encountered within the existing dual funder
workflow logic have been fixed, and modified to account for the wallet
being on the igniting side of a single funder workflow.
2016-06-21 13:13:41 -07:00
Olaoluwa Osuntokun
4a6a2d6cd4
lnwallet: correct inputs scripts for nested P2SH spend
The previous logic incorrectly assumed the returned address was already
a p2wkh address. Instead, a p2sh address was returned. So we now
correctly craft both the sigScript and witness stack for a nested p2sh
spend.
2016-06-21 13:13:33 -07:00
Olaoluwa Osuntokun
d52955b146
lnwallet: extract coin selection to distinct method
This is required since for single funder channels, we don’t contribute
any funds so we don’t need to select any change or coins for input into
the funding transaction.
2016-06-21 13:13:29 -07:00
Olaoluwa Osuntokun
fcff17c336
multi: change all imports to roasbeef's forks
This commit will allow the general public to build lnd without jumping
through hoops setting up their local git branches nicely with all of
our forks.
2016-05-15 17:22:37 +03:00
Olaoluwa Osuntokun
c6eedafb9a
lnwallet: update reservation workflow to be segwitty
Only nested p2sh or pure witness outputs are used when selecting coins
for inputs to a funding transaction.

The funding transaction output now uses p2wsh rather than regular p2sh.

All tests have been updated accordingly.
2016-05-03 20:06:58 -07:00
Olaoluwa Osuntokun
4b4c0f73b0
lnwallet: add ListUnspentWitness for funding tx coin selection 2016-05-03 20:06:49 -07:00
Olaoluwa Osuntokun
163eb8dcb8
lnwallet: remove FundingType enum
Removing as segwit is now the path forward.
2016-05-03 20:06:30 -07:00
Tadge Dryja
71231c477c make imports lowercase 2016-04-30 20:24:57 -07:00
Olaoluwa Osuntokun
1a96e4f7a6 lnwallet: default to p2wkh address for generated change+delivery addresses 2016-04-24 20:27:56 -07:00
Olaoluwa Osuntokun
0e607c1939 lnwallet: during shutdown properly wait for all goroutines to exit 2016-04-24 12:39:43 -07:00
Olaoluwa Osuntokun
1e35018e89 lnwallet: fix compile errors against btcd's segwit branch 2016-04-12 21:37:08 -07:00
Olaoluwa Osuntokun
7420503c7a lnwallet: publicly export WaddrmgrEncryptorDecryptor 2016-03-24 14:32:44 -07:00
Olaoluwa Osuntokun
082a8a34e3 lnwallet: update tests and workflow to new OpenChannel struct 2016-03-24 00:01:35 -07:00
Olaoluwa Osuntokun
fe6d71e95e lnwallet: accept channeldb as a param in constructor
lnwallet is no longer responsible for creating/opening channeldb. The
call is now expected to do so.
2016-03-22 18:48:18 -07:00
Olaoluwa Osuntokun
1944003fde lnwallet: update to use new btcdnotify.NewBtcdNotifier API 2016-02-26 17:38:31 -08:00
Olaoluwa Osuntokun
25c1b7a491 lnwallet: update chainNotifier assignment to new BtcdNotifier constructor 2016-02-26 17:38:31 -08:00
Tadge Dryja
0d3639435f can sync with segnet in hard mode
lots of changes but they seem to work
2016-02-15 22:13:17 -08:00
Olaoluwa Osuntokun
fa05ee9a22 lnwallet: move pubKey comparison for funding output spend into spendMultiSig func
* This change makes the spendMultiSig function testable independent of
the reservation workflow.
2016-02-05 12:33:22 -08:00
Olaoluwa Osuntokun
b3cdc6167f lnwallet: switch over to using btcwallet's new Loader type
Allows us to remove a lot of duplicated code pertaining to wallet
setup. We also gain hooks into the wallet to trigger callbacks once the
wallet is created/opened.
2016-02-03 12:01:45 -08:00
Olaoluwa Osuntokun
92c14c99c3 lnwallet: update tests to utilize the in-progress btcsuite/btcd/rpctest package
Instead of creating “fake” utxos for bob, and alice. We now employ a
dedicated mining node to hand out utxos, and generate blocks with hand
picked transactions.
2016-02-03 12:01:44 -08:00
Olaoluwa Osuntokun
7bebefbd8f lnwallet: fix script bug, ensure sigScript is set before verification 2016-02-03 12:01:44 -08:00
Olaoluwa Osuntokun
74ee5334f4 lnwallet: allow configurable net param for wallet create/open 2016-02-03 12:01:44 -08:00
Olaoluwa Osuntokun
98bbd314a7 lnwallet: add active Bitcoin network to config 2016-02-03 12:01:44 -08:00
Olaoluwa Osuntokun
80ce49a883 lnwallet: update btcwallet and chain.Client to new upstream API's
A major change for btcwallet adding a new RPC wallet, refactoring parts
of the wallet, and introducing new functionality has been introduced.
This commit updates lnwallet to the API changes. A future commit will
change lnwallet to use some of the new functionality such as the
notification server, etc.
2016-02-03 12:01:44 -08:00
Olaoluwa Osuntokun
034cbef66d lnwallet: avoid goroutines waiting for channel open indefinitely blocking
Select over the quit channel in order to shutdown goroutines waiting
for funding txn confirmations. Without this we may leak goroutines
which are blocked forever if the process isn’t exiting when the walet
is signaled to shutdown.
2016-02-03 12:01:44 -08:00
Olaoluwa Osuntokun
20d471a766 lnwalelt: add note for balance update ntfs 2016-02-03 12:01:44 -08:00
Tadge Dryja
2815afebb7 update imports to github 2016-01-16 10:45:54 -08:00
Olaoluwa Osuntokun
07b0d5ca3e lnwallet: once the reservation workflow is complete, wait then open the payment channel
* Hooks into the ChainNotifier infrastructure to receive a notification
once the funding transaction gets enough notifications.
* Still need to set up the notification grouting within a
LightningChannel to watch for uncooperative closures, and broadcasts
and revoked channel states.
2016-01-14 23:58:04 -08:00
Olaoluwa Osuntokun
6e0cfaf7ec lnwallet: re-introduce rpc calls during channel reservation workflow
* In preparation for regression testing once nodetest is finished.
* These sections we’re previously uncommented to allow for testing the
wallet without a full-node hooked up.
2016-01-14 23:58:04 -08:00
Olaoluwa Osuntokun
cf65aaa2c9 lnwallet: have wallet return db so it can be closed during shutdown
* Also remove some extra print statements from debugging
* Separate out logic to create wallet from creating an ID
2016-01-14 23:57:54 -08:00
Tadge Dryja
19233dc42d wallet creation works, takes 11 seconds 2016-01-14 23:56:09 -08:00
Olaoluwa Osuntokun
1772108544 lnwallet: start of HTLC update logic
* moved sorting of transaction outside of createCommitTx also us to add
HTLC’s before sorting
* On the fence about the proxy object design, will re-visit once we
start to implement the p2p code.
2016-01-14 23:56:09 -08:00
Olaoluwa Osuntokun
c41f7d1a7d lnwallet: update to 20 byte revocation hashes 2016-01-14 23:56:08 -08:00
Tadge Dryja
cb32ab1fb9 identify where it freezes. in btcwallet/walletdb/interface.go:271 2016-01-14 23:56:08 -08:00
Tadge Dryja
8504362c5e trying to store id pkh. Doesn't work; wallet creation never completes 2016-01-14 23:56:08 -08:00
Tadge Dryja
e70c6aa367 trying to store private identity key. Doesn't work. 2016-01-14 23:56:08 -08:00