Commit Graph

121 Commits

Author SHA1 Message Date
ThomasV a13cea6f8a add remove_lightning command 2019-10-14 11:18:57 +02:00
ThomasV 90ce9f195b Allow user to enable lightning in the GUI. Make it a per-wallet setting. 2019-10-13 20:34:38 +02:00
SomberNight 04edad9984 config: no longer singleton. it is passed to Wallet.__init__
The few other cases that used SimpleConfig.get_instance() now
either get passed a config instance, or they try to get a reference
to something else that has a reference to a config.
(see lnsweep, qt/qrcodewidget, qt/qrtextedit)
2019-09-22 20:46:01 +02:00
ThomasV f08e5541ae Refactor invoices in lnworker.
- use InvoiceInfo (NamedTuple) for normal operations,
   because lndecode operations can be very slow.
 - all invoices/requests are stored in wallet
 - invoice expiration detection is performed in wallet
 - CLI commands: list_invoices, add_request, add_lightning_request
 - revert 0062c6d695 because it forbids self-payments
2019-09-22 16:06:53 +02:00
JeremyRand 7b91cd9cf4 Add from_coins arg to payto/paytomany
Fixes https://github.com/spesmilo/electrum/issues/5430
2019-09-21 20:07:16 +00:00
SomberNight a1d7d39f68 commands: add type hints for "wallet" param, and fix code rot found via 2019-09-21 02:14:22 +02:00
ThomasV aaed594772 Simplify invoices and requests.
- We need only two types: PR_TYPE_ONCHAIN and PR_TYPE_LN
 - BIP70 is no longer a type, but an optional field in the dict
 - Invoices in the wallet are indexed by a hash of their serialized list of outputs.
 - Requests are still indexed by address, because we never generate Paytomany requests.
 - Add 'clear_invoices' command to CLI
 - Add 'save invoice' button to Qt
2019-09-12 20:11:20 +02:00
SomberNight 1b332748c3 qt console: fix commands that do not expect a 'wallet' arg 2019-09-12 19:22:55 +02:00
ThomasV 65b88dca86 return fees in history, show them in kivy GUI 2019-09-11 17:49:40 +02:00
ThomasV cefa4762ba do not create multiple instances of SimpleConfig (fix #5629). Add config field to wallet 2019-09-10 08:57:40 +02:00
SomberNight ef5a5151e3 daemon: make 'wallets' dict private
especially as keys (paths) need to be standardized, this should not be exposed
2019-09-09 22:15:11 +02:00
ThomasV 103a37b0ca add wallet_path to kwargs in run_cmdline 2019-09-09 09:58:16 +02:00
ThomasV 46ffab0b55 remove --wallet option for daemon. fixes #3752 2019-09-09 06:28:54 +02:00
ThomasV 5e92f637a6 fix CLI exception handling 2019-09-06 12:38:13 +02:00
ThomasV 35b0b3a43c Fix CLI. Some commands require wallet_path. Return error on exception. 2019-09-06 11:06:08 +02:00
SomberNight 712c3f1248 commands: try to fix tests 2019-09-05 23:22:11 +02:00
SomberNight 58681e4d07 follow-up prev (commands) 2019-09-05 18:30:04 +02:00
ThomasV 9ec9e1760a CLI: always use the daemon's cmd_runner, and pass the 'wallet'
parameter explicitly to each command that requires it.
Previous code was relying on side effects to set the wallet.
This should fix #5614
2019-09-05 17:57:51 +02:00
ThomasV 128285a050 http server: add ssl and bip70 signed requests 2019-09-05 10:57:50 +02:00
SomberNight 9d65120e59 commands: fix "close_wallet" 2019-09-04 20:16:47 +02:00
SomberNight 1bd9b3a66a commands: fix "restore" cmd
Previously commands did not run on the asyncio thread but now they do.
"restore" was polling like "while 1: time.sleep()", blocking the event loop.

Now "restore" does not sync the wallet; which is actually cleaner
as previously this wallet would never get unloaded from the daemon (syncing forever).

This is also symmetric with the "create" cmd which also does not try to sync with the network.

However now it became difficult to write a script that restores a wallet and wants to wait
until it gets synced. Workaround for now is to poll with "list_wallets" whether it's synced.

We could create a new command that blocks until the loaded wallet gets synced.
2019-09-04 20:15:54 +02:00
ThomasV 747ab7a0a2 Integrate http_server (previously in electrum-merchant)
Use submodule to fetch HTML and CSS files
2019-09-04 12:20:05 +02:00
ThomasV 7f870f5e09 replace daemon 'start' subdommand with -d 2019-09-02 19:04:08 +02:00
SomberNight eb5033dfc6 commands: add feerate param to payto/paytomany 2019-09-01 17:52:02 +02:00
ThomasV e79253b5e0 Syntax change: Require --offline to run commands without a daemon.
That makes the syntax less ambiguous. It also makes it possible to
implement a CLI that does not import all the electrum modules.
2019-08-31 09:24:00 +02:00
ThomasV 8010123c08 Display and refresh the status of incoming payment requests:
- All requests have an expiration date
 - Paid requests are automatically removed from the list
 - Unpaid, unconfirmed and expired requests are displayed
 - Fix a bug in get_payment_status, conf was off by one
2019-08-22 06:00:45 +02:00
ThomasV 246cda2928 fix Flake8 tests 2019-08-20 09:03:12 +02:00
ThomasV 9cfeadea70 Turn daemon subcommands into RPCs 2019-08-20 09:03:12 +02:00
ThomasV 54257cbcca Rewrite JsonRPC requests using asyncio.
- commands are async
 - the asyncio loop is started and stopped from the main script
 - the daemon's main loop runs in the main thread
 - use jsonrpcserver and jsonrpcclient instead of jsonrpclib
2019-08-20 09:03:12 +02:00
SomberNight 6b1810f8dc commands.py: fix type of "timeout" arg
was str by default
2019-08-20 09:03:12 +02:00
ThomasV e5286f7598 minor fix: always initialize Commands.lnworker 2019-08-20 09:03:12 +02:00
ThomasV 28b1569f28 (trivial) fix getbalance 2019-08-20 09:03:12 +02:00
ThomasV 9f8e2c689e test funding_txn_minimum_depth, show it in GUI 2019-08-20 09:03:12 +02:00
SomberNight 4ccfa39fdd cli: fix add_peer cmd 2019-08-20 09:03:12 +02:00
ThomasV af7d7e883c Rework wallet history methods:
- wallet.get_full_history returns onchain and lightning
 - capital gains are returned by get_detailed_history
 - display lightning history in kivy
 - command line: separate lightning and onchain history
2019-08-20 09:03:12 +02:00
ThomasV 0913194a53 qt: add clear button to receive tab, show invoice right after it is added 2019-08-20 09:03:11 +02:00
ThomasV b8d908d63e lnworker improvements:
- enable option data_loss_protect
 - separate add_peer from open_channel
 - display exceptions raised in open_channel
2019-08-20 09:03:11 +02:00
ThomasV dbe8b75659 move lnpay attempts logic to lnworker.pay 2019-08-20 09:03:11 +02:00
ThomasV 7be4cdaf18 redeem htlcs:
- fix bug in lnsweep: lnwatcher transactions were indexed by prev_txid
 - add test for breach remedy with unsettled htlcs
 - add timeout option to lnpay, and replace DO_NOT_SETTLE with SETTLE_DELAY
   so that we can read intermediate commitment tx in regtest
2019-08-20 09:03:11 +02:00
ThomasV 6d9ef29690 redo LNWorker pay:
- wait until htlc has been fulfilled
 - raise if htlc is not fulfilled
 - return boolean success
 - try multiple paths in GUI
2019-08-20 09:03:11 +02:00
ThomasV b1f8c42424 post-rebase fix 2019-08-20 09:03:11 +02:00
ThomasV 842fff832f enable lightning through command line option 2019-08-20 09:03:11 +02:00
ThomasV e7218d798d add get_channel_ctx to CLI, for testing breaches 2019-08-20 09:03:11 +02:00
ThomasV 3dce65dc73 Rename lnchan, lnchannel_verifier, lnbase
Auto-completions are a pain if files share a long prefix
2019-08-20 09:03:11 +02:00
ThomasV d383573bc3 CLI: use funding_point in channel_open and channel_close. add host:port to nodeid 2019-08-20 09:03:11 +02:00
ThomasV f04e10f61a save channel timestamps, and show lightning payments in history tab 2019-08-20 09:03:11 +02:00
ThomasV b7d93e2e11 gui: display lightning balance in status bar 2019-08-20 09:03:11 +02:00
ThomasV 2af178a586 Store boolean is_received in lightning invoices. Sort lightning history with timestamp. Minor fixes 2019-08-20 09:03:11 +02:00
ThomasV 281d51c002 follow-up prev commit 2019-08-20 09:03:11 +02:00
ThomasV 0e8dba897e lightning:
* store invoices for both directions
* do not store lightning_payments_inflight, lightning_payments_completed in lnworker
* payment history is returned by get_payments method of LNChannel
* command line: lightning history, lightning_invoices
* re-enable push_msat
2019-08-20 09:03:11 +02:00