Commit graph

98 commits

Author SHA1 Message Date
bitromortac
4efcb53d24 network: load gossip db early
The gossip db is loaded early when the network is started to save
time when the gui is locked and a wallet not yet loaded. Side effects
of the LNWallet to start peering when a channel db is loaded is
circumvented.
2020-10-22 18:05:51 +02:00
SomberNight
83e61d6743
cli: allow specifying --wallet at any arg position, as before
Before commit 46ffab0b55 all of these used to work:
./run_electrum -o signmessage tb1qeh090ruc3cs5hry90tev4fsvrnegulw8xssdzx "asdasd" -w ~/.electrum/testnet/wallets/test_segwit_2 --testnet
./run_electrum -o signmessage -w ~/.electrum/testnet/wallets/test_segwit_2 tb1qeh090ruc3cs5hry90tev4fsvrnegulw8xssdzx "asdasd" --testnet
./run_electrum -w ~/.electrum/testnet/wallets/test_segwit_2 -o signmessage tb1qeh090ruc3cs5hry90tev4fsvrnegulw8xssdzx "asdasd" --testnet
Since then, the last one no longer works.

Related: 9d2ede8796
2020-10-05 18:02:37 +02:00
SomberNight
a81b0ecc59
daemon/rpc: include "jsonrpc" key in rpc responses
fixes #6612
2020-09-23 21:39:31 +02:00
MrNaif2018
6bd1a04aee
Pass wallet to invoice_status/request_status (#6595)
* Pass wallet to invoice_status/request_status

* Check for same wallet in qt gui

Co-authored-by: ghost43 <somber.night@protonmail.com>
2020-09-18 17:28:51 +00:00
SomberNight
a32cb7784f
myAiohttpClient: add id counter, and rename to JsonRPCClient 2020-06-09 17:50:06 +02:00
SomberNight
50f705ee46
fix json-rpc interface (when not using CLI) 2020-06-09 17:45:04 +02:00
ThomasV
30f5be26ac Remove dependencies: jsonrpcserver, jsonrpcclient 2020-06-09 11:26:39 +02:00
ThomasV
cfdfbd2bfe follow-up 6058829870 2020-06-02 16:32:07 +02:00
ThomasV
6058829870 Use attr.s classes for invoices and requests:
- storage upgrade
 - fixes #6192
 - add can_pay_invoice, can_receive_invoice to lnworker
2020-06-01 21:02:45 +02:00
SomberNight
9baaf1afda
commands: make 'wallet'-mangling in decorator less obscure, and fixes
- some commands expect a 'wallet_path' arg, while others expect 'wallet'
- 'wallet_path' in the end is supposed to be a str,
  'wallet' in the end is supposed to be an Optional[Abstract_Wallet]
- initially, in the decorator, 'wallet' can be a str, in which case
  the decorator replaces it with an Abstract_Wallet (from the daemon)
- Previously the decorator sometimes converted 'wallet_path' to 'wallet'.
  This was because when called from the CLI it was always given 'wallet_path' (and never 'wallet),
  while when called from JSON-RPC it was given either 'wallet' or 'wallet_path' (depending on command).
  Now, the CLI also behaves as JSON-RPC, and hence 'wallet_path' and 'wallet' are fully separate.
- A bug is fixed where, when a command that only optionally takes a 'wallet' (such as gettransaction),
  was called from the JSON-RPC with the arg present, it raised; and when called from CLI with the arg present
  the arg was not actually passed to the command.
- A bug is fixed where if one command calls another command (that both take a 'wallet'),
  it would raise (due to assuming 'wallet' is str and needs to be converted to Abstract_Wallet).
  This fixes #6154.

-----

$ ./run_electrum --testnet daemon -d
$ ./run_electrum --testnet load_wallet -w ~/.electrum/testnet/wallets/default_wallet

$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"gettransaction","params":{"txid":"9f43ff71ea2594873e4e7d15e61254a3661ff2df1af76325c854d9aa199550ce"}}' http://user:pass@127.0.0.1:7777
{"jsonrpc": "2.0", "result": "0200000001caaac6b5eb916e3067d0224f942fb331ce1dcfb4031cfb479e7941dcf95e409801000000fdfe0000483045022100e2a508bb78c2172eb03f081a342454ba1d24669e959700973b1a742a4fedd0c302203174e06feda265031cf9aa0364d4a4eafb71b0c0a62e76be7795cfbb307b677a01483045022100d0e14564838fac754395158741d64c73da2b86e7900dfdc6a63c7492b232ba130220778e7e7c21d94ebcd340057302aeff7e9a797a3aa3e0ac4884e9ff27339ea6e9014c69522102091f0b4d8ab30016a5d1c088249e02883fad8160f06fa53588ad8598650a3e6221035f2f8263bb3608d6cc4ee03bd4cb8d65c4d70af71049f05fbfee4978832a1fd22103fe42dab58718ea0413f7c8de693cdeee22ce19b1dc34c0bbdd7a48245465c5a253aefdffffff01cb9f0700000000001976a914c13fd6294d1be7b9410a5538f4b4ef10fc594ee788ac802c1800", "id": "curltext"}

$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"gettransaction","params":{"txid":"9f43ff71ea2594873e4e7d15e61254a3661ff2df1af76325c854d9aa199550ce", "wallet":"~/.electrum/testnet/wallets/default_wallet"}}' http://user:pass@127.0.0.1:7777
{"jsonrpc": "2.0", "error": {"code": -32000, "message": "'str' object has no attribute 'db'"}, "id": "curltext"}
2020-05-14 16:33:02 +02:00
ThomasV
d3fb68575d daemon.py: Add authentication to Watchtower.
Define abstract class AuthenticatedServer
2020-05-12 10:12:30 +02:00
ThomasV
e2c2c89988 follow-up prev 2020-05-10 22:11:09 +02:00
ThomasV
13317c2f51 fix callback name: request_status 2020-05-10 21:14:31 +02:00
ThomasV
87facaa781 payserver: do not allow create_invoice by default 2020-05-10 17:07:19 +02:00
ThomasV
11aaa0b66f Simplify services (watchtower, payserver):
- Do not expose services settings in GUI
 - Use a single netaddress configuration variable.
2020-05-10 14:52:50 +02:00
ThomasV
085b6ca2ab jsonrpc: pass timeout to aiohttp session 2020-05-02 17:25:30 +02:00
SomberNight
0ee73378c9
daemon: rm "daemon.wallet" reference
related: #4905 -- when closing a wallet, it can get gc-ed now

TODO: PayServer needs to choose wallet somehow
2020-05-01 06:56:21 +02:00
SomberNight
2b1a150c52
multi-wallet: properly stop lnworker/lnwatcher 2020-05-01 04:50:08 +02:00
SomberNight
47ab8f8dc5
daemon.on_stop: adapt to python 3.8
(py3.8 has breaking changes re asyncio.CancelledError and asyncio.TimeoutError)

follow-up 308517d473
2020-04-15 19:34:52 +02:00
SomberNight
cf1f2ba4dc
network: replace "server" strings with ServerAddr objects 2020-04-15 17:23:47 +02:00
ThomasV
9224404108 Move callback manager out of Network class 2020-04-14 18:29:51 +02:00
SomberNight
b21bcf5977
taskgroups: don't log CancelledError 2020-02-27 20:22:49 +01:00
SomberNight
3d42fca86e
daemon.run_gui: make sure to exit process on exception
previously, if GUI-related imports raised, the GUI would not start
but the process would not exit (e.g. asyncio event loop would go on)

Traceback (most recent call last):
  File "...\electrum\electrum\daemon.py", line 517, in run_gui
    gui = __import__('electrum.gui.' + gui_name, fromlist=['electrum'])
  File "...\electrum\electrum\gui\qt\__init__.py", line 39, in <module>
    from PyQt5.QtGui import QGuiApplication
ImportError: DLL load failed while importing QtGui: The specified module could not be found.
2020-02-19 15:45:36 +01:00
ThomasV
300888f21c fix path for payserver static files 2020-02-19 11:47:43 +01:00
SomberNight
004acb906d
ecc: abstract away some usage of python-ecdsa: randrange 2020-02-11 16:41:45 +01:00
ThomasV
e1ce3aace7 Separate db from storage
- storage is content-agnostic
 - db and storage are passed to wallet contructor
2020-02-10 17:45:23 +01:00
SomberNight
a6dd17bfef
fix daemon (don't close instantly)
follow-up 37747d7469
2020-01-11 00:04:00 +01:00
SomberNight
37747d7469
split network main_taskgroup: create daemon.taskgroup
network.main_taskgroup restarts every time the proxy settings are changed,
many long-running tasks (some introduced with lightning) are not prepared for and do not want this.
2020-01-09 19:23:21 +01:00
SomberNight
a5a7c205e3
trivial: add a few log lines for startup 2019-12-10 23:31:58 +01:00
SomberNight
9d0ae2f95b
adapt to aiohttp 4.0
related: #5753
2019-12-10 22:55:11 +01:00
SomberNight
420b1a6636
cli: load_wallet now auto-upgrades the WalletStorage when needed
previously it would bail out and just return False
2019-11-22 15:54:34 +01:00
Daniel Kraft
423c4b0695
Return 401 from RPC server for missing auth.
When no (supported) authentication is passed to the JSON-RPC server,
return a 401 HTTP error code instead of 403.  This indicates to the
client that authentication is required, and also requests that to be
sent using the "basic" method.  The previously-returned code 403 is now
only returned if authentication is passed but not valid.

There are some JSON-RPC clients out there that only send authentication
after a 401 code requested it.  Those fail to connect to the Electrum
RPC interface even if the correct password is configured.  Those same
clients can e.g. connect to Bitcoin Core successfully, which already
implements logic matching this change.

See also https://stackoverflow.com/questions/3297048/403-forbidden-vs-401-unauthorized-http-responses.
2019-11-21 15:16:37 +01: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
a35421ab71 qt settings: create services tab for both watchtower and payserver 2019-09-22 17:12:48 +02:00
ThomasV
1ecbafb920 add SSL context to watchtower server 2019-09-13 12:26:27 +02:00
ThomasV
a43be6657d follow-up on SingleConfig 2019-09-10 17:14:25 +02:00
SomberNight
1a08063928
config: remove 'open_last_wallet' side-effecting
related: #5629
2019-09-10 17:10:52 +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
d5d9f5b46c fix #5618 2019-09-08 12:06:21 +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
ThomasV
5faa0ade3d ignore exceptions in payserver 2019-09-06 08:06:26 +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
28da62f51b add PayServer settings to settings_dialog 2019-09-05 14:43:27 +02:00
ThomasV
9d595f1fe1 fix websocket messages 2019-09-05 11:45:28 +02:00
ThomasV
466c2bd293 for now, use PR_PAID for onchain unconfirmed 2019-09-05 11:33:09 +02:00
ThomasV
128285a050 http server: add ssl and bip70 signed requests 2019-09-05 10:57:50 +02:00