Commit Graph

172 Commits

Author SHA1 Message Date
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
ThomasV 717d112b26 Move create_transaction logic from commands to wallet 2020-05-21 12:08:46 +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 8fb79196ba add_lightning_request command: return request object 2020-05-11 17:52:04 +02:00
ThomasV b891d3dc85 new command: get_ssl_domain 2020-05-09 10:33:18 +02:00
ThomasV 7b44e27087 lnpay: return payment log, increase timeout 2020-05-05 18:32:43 +02:00
ThomasV a5a5048d53 lnpay: save invoice 2020-05-02 17:26:02 +02:00
Luke Childs ca1046bce2 Add --serverfingerprint option (#6094)
* Add --fingerprint option

* Simplify conditional checks

* Improve warning wording

* Throw error instead of logging and returning

* --fingerprint => --serverfingerprint

* Only run fingerprint checks against main server

* Throw error if --serverfingerprint is set for a non SSL main server

* Fix linting errors

* Don't check certificate fingerprint in a seperate connection

* Disallow CA signed certs when a fingerprint is provided

* Show clear error and then exit for Qt GUI users

* Remove leading newlines from error dialog

* Always check is_main_server() when getting fingerprint

* Document how to generate SSL cert fingerprint
2020-04-24 14:11:40 +00:00
SomberNight e2ae44beb9 commands: "notify" cmd: stop watching addr if called with empty URL
closes #5881
2020-04-24 15:34:55 +02:00
ThomasV 0b6ae1dbff fix #6101 2020-04-20 18:55:07 +02:00
ThomasV 4d01a550c4 fix #6103: local config contains remote reserve 2020-04-20 18:48:41 +02:00
SomberNight b2cfaddff2 network.NetworkParameters: merge host+port+protocol into "server" field 2020-04-16 21:19:45 +02:00
ThomasV ef5ad5f22f extend 'add_peer', 'list_peers' commands to gossip 2020-04-16 12:39:12 +02:00
ThomasV 27949cb0e5 add list_peer command. (fix #6057) 2020-04-12 12:48:44 +02:00
ThomasV 312ef15cd6 fix #6056 2020-04-11 12:02:38 +02:00
ThomasV 7a11c05916 fix #6075 2020-04-11 10:56:43 +02:00
ThomasV 8f41aeb783 Replace wallet backup with channel backups
- channels can be backed up individually
 - backups are added to lnwatcher
 - AbstractChannel ancestor class
2020-04-10 14:45:23 +02:00
ghost43 b31efdc3e7 Merge pull request #6076 from JeremyRand/initial-download-exception
Use specific Exception when chain isn't synced
2020-04-08 08:34:40 +00:00
JeremyRand 40389a21b6 Use specific Exception when chain isn't synced
Makes it easier for calling code to know what error happened.
2020-04-08 03:09:08 +00:00
SomberNight 900a7631cf commands: add new cmd "getprivatekeyforpath" to export a WIF for a path
related: #6061
2020-03-31 05:50:18 +02:00
JeremyRand 72de433f5c Commands: clarify description of getservers
The previous description made it sound like it returned the list of
currently connected servers; this clarifies that it's only a list of
candidate servers to connect to (no guarantee that they are all currently
connected).
2020-03-30 22:50:25 +00:00
SomberNight 777e350fae lnchannel: partly fix available_to_spend
we were looking at inconsistent ctns
and we were looking at the wrong subject's ctx

all the FIXMEs and TODOs here will still warrant some attention.

(note that test_DesyncHTLCs was passing incorrectly:
the "assertRaises" was catching a different exception)
2020-03-26 09:04:55 +01:00
interrupt00 df700ca96a Document how to disable proxy 2020-03-17 23:23:17 +01:00
ThomasV d5469b7eb5 fix #6037 2020-03-16 14:31:22 +01:00
ThomasV 8480989fb7 follow-up 17a893441a: satoshis 2020-03-06 10:07:36 +01:00
ThomasV 34e236c9b6 CLI: show channel reserves and unsettled balances. fixes #5817 2020-03-06 09:57:37 +01:00
SomberNight 2aebcc5e26 commands: gate get_channel_ctx behind --iknowwhatimdoing 2020-03-05 17:27:43 +01:00
ThomasV 89fa9b5090 Merge pull request #5898 from leo-lb/plausible-deniability-config
Add command line option to forget config on exit.
2020-03-03 11:50:04 +01:00
SomberNight 660d7d137c commands: add changegaplimit and getminacceptablegap cmds
There are some legitimate use-cases for changing the gap limit,
so just as it has already been possible to do in the GUI (using the console only! don't expose this to mere mortals.),
now CLI/RPC users have this exposed too.

The "changegaplimit" command will always raise unless invoked with the --iknowwhatimdoing option.

closes #5882

e.g.:
$ curl --data-binary '{"id":"curltext","jsonrpc":"2.0","method":"changegaplimit","params":{"new_limit": 30, "iknowwhatimdoing": true, "wallet":"~/.electrum/testnet/wallets/test_segwit_2"}}' http://user:password@127.0.0.1:7777
$ ./run_electrum --testnet changegaplimit 30 --iknowwhatimdoing -w ~/.electrum/testnet/wallets/test_segwit_2
2020-03-02 19:07:59 +01:00
ThomasV 077f778632 Replace lightning_settle_delay with enable_htlc_settle (asyncio.Event) 2020-02-28 10:15:28 +01:00
ThomasV 8730fa3f75 return preimage in lnpay. fixes #5794 2020-02-23 12:40:40 +01:00
ThomasV 67d0e780b3 remove double definition of lightning_history. fixes #5984 2020-02-23 11:59:34 +01:00
ThomasV 9451ca9568 move list_channels to commands.py 2020-02-20 10:30:30 +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 3835157f41 cli: history commands: only json-encode once
closes #5868
closes #5931
2020-02-04 17:56:52 +01:00
ThomasV 4ec86d36a8 faster and improved regtests
- print the test name before each test
 - start only needed agents (alice, bob, carol)
 - set settle_delay using setconfig instead of restarting daemon
 - test the watchtower ctn in test_watchtower
2020-02-02 15:07:28 +01:00
Leo Le Bouter f81db9cd1d Add command line option to forget config on exit.
By default, Electrum saves the last opened wallet's path as well as
recently opened wallets.

This can be damaging to plausible deniability.

Now it's possible to run Electrum with `--forgetconfig` to not
write to the config at all, which includes the wallet paths.
2020-01-21 13:32:02 +01:00
SomberNight ad5c6284c4 commands/jsonrpc: fix specifying "wallet" to commands that need it 2019-12-21 07:00:30 +01:00
SomberNight 9b28f6df7b wallet: encrypt storage by default
notably, now also in kivy
2019-12-19 14:22:47 +01:00
SomberNight 557987d4eb add/fix some open_channel related type hints 2019-11-23 20:28:46 +01:00
ThomasV fd8236538a Open lightning channels with partially signed tx.
Fixes #5379.
2019-11-23 19:49:12 +01:00
ThomasV 06589df812 simplify add_transaction 2019-11-23 12:46:43 +01:00
SomberNight c31fa059fe cli: clear up "rbf" arg for "payto" cmd in help text; and use eval_bool
related: #5791

(previously rbf was a str, and it was casted to a bool directly, i.e. only
the empty string "" evaluated as False)
2019-11-22 16:09:42 +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
SomberNight 3d88d6870c cli: fix load_wallet for storage-encrypted wallets 2019-11-22 15:48:22 +01:00
ghost43 f2ca651dc4 Merge pull request #5775 from JeremyRand/resolver-wallet
Fix missing wallet argument to _resolver
2019-11-18 02:11:06 +00:00
JeremyRand 643bc9d802 Fix missing wallet argument to _resolver 2019-11-18 01:31:33 +00:00
ThomasV 78813dcb7d Pass make_tx function to ConfirmTxDialog
- allow 'spend max' when opening a channel (fixes #5698)
 - display amount minus fee when 'max' buttons are pressed
 - estimate fee of channel funding using a template with dummy address
2019-11-14 10:20:19 +01:00
SomberNight 85a4811742 transaction.tx_from_any: recognise even more types, and add tests 2019-11-08 15:01:18 +01:00
SomberNight bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00