Commit graph

244 commits

Author SHA1 Message Date
SomberNight
6040e953a3
wallet: implement reserving addresses, and use it for LN SRK to_remote
- Use change addresses (instead of receive) for the static_remotekey to_remote outputs,
  and reserve these to greatly reduce the chance of address-reuse
- Use change addresses (instead of receive) for LN channel sweep addresses.
  Note that these atm are not getting reserved.
2020-05-22 17:19:51 +02:00
SomberNight
6457bb141d
wallet: (trivial) rename check_address 2020-05-22 17:19:48 +02:00
SomberNight
f8c574b699
wallet: (fix) get_receiving_address must always return an addr
- also, disallow deleting last address from an imported wallet (fixes #3254, fixes #4833)
- also, set LNBackups.sweep_address lazily, as during fresh wallet creation
  there are no addresses in the wallet at that point yet! see trace below.

Traceback (most recent call last):
  [...]
  File "...\electrum\electrum\tests\test_commands.py", line 112, in test_export_private_key_deterministic
    wallet = restore_wallet_from_text('bitter grass shiver impose acquire brush forget axis eager alone wine silver',
  File "...\electrum\electrum\wallet.py", line 2575, in restore_wallet_from_text
    wallet = Wallet(db, storage, config=config)
  File "...\electrum\electrum\wallet.py", line 2502, in __new__
    wallet = WalletClass(db, storage, config=config)
  File "...\electrum\electrum\wallet.py", line 2346, in __init__
    Deterministic_Wallet.__init__(self, db, storage, config=config)
  File "...\electrum\electrum\wallet.py", line 2147, in __init__
    Abstract_Wallet.__init__(self, db, storage, config=config)
  File "...\electrum\electrum\wallet.py", line 261, in __init__
    self.lnbackups = LNBackups(self)
  File "...\electrum\electrum\lnworker.py", line 1401, in __init__
    self.sweep_address = wallet.get_receiving_address()
  File "...\electrum\electrum\wallet.py", line 1498, in wrapper
    addr = func(self, *args, **kwargs)
  File "...\electrum\electrum\wallet.py", line 1520, in get_receiving_address
    raise Exception("no receiving addresses in wallet?!")
Exception: no receiving addresses in wallet?!
2020-05-22 16:25:33 +02:00
SomberNight
9657e927a7
wallet: (trivial) define import/delete_address in Abstract_Wallet 2020-05-22 16:17:41 +02:00
ThomasV
717d112b26 Move create_transaction logic from commands to wallet 2020-05-21 12:08:46 +02:00
ThomasV
6aeab66463 fix #6157 2020-05-11 08:12:09 +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
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
SomberNight
2b1a150c52
multi-wallet: properly stop lnworker/lnwatcher 2020-05-01 04:50:08 +02:00
SomberNight
54fdb011f9
fixups for CallbackManager refactor
9224404108
2020-04-24 15:32:05 +02:00
SomberNight
54e1520ee4
ln: check if chain tip is stale when receiving HTLC
if so, don't release preimage / don't forward HTLC
2020-04-13 17:04:27 +02:00
ThomasV
e2544b893a rm dead code: wallet.wait_until_synchronized 2020-04-11 15:26:29 +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
SomberNight
900a7631cf
commands: add new cmd "getprivatekeyforpath" to export a WIF for a path
related: #6061
2020-03-31 05:50:18 +02:00
ThomasV
df5acd1ea5 kivy: add delete button for invoices/requests 2020-03-10 17:30:08 +01:00
ThomasV
e48c7d01cd Qt: add 'View channel' to history menu, 'View funding transaction' to channel menu 2020-03-06 08:47:31 +01:00
SomberNight
ac6a5a3c5f
wallet: min_acceptable_gap should mimic wallet.synchronize
if wallet.synchronize uses address_is_old, so should min_acceptable_gap
2020-03-02 18:53:04 +01:00
SomberNight
d4fc73e2b4
kivy tx dialog: don't show "remove tx" option so eagerly
(long standing annoyance, not related to prev commit directly)
2020-03-02 05:45:04 +01:00
SomberNight
7a574c3cbc
wallet/GUI: don't allow "removing" a LN force-close-tx from history 2020-03-02 05:11:08 +01:00
SomberNight
d8180c678b
Qt addresses list: show derivation path in tooltip (also addr dialog)
related: #5641
2020-03-01 05:45:15 +01:00
SomberNight
1ca6f6f306
Qt address list speedup: wallet.is_beyond_limit was slow 2020-02-29 07:28:13 +01:00
SomberNight
88658f9c2c
WalletDB: add type hints, and also corresponding asserts for sanity 2020-02-24 18:26:49 +01:00
ThomasV
570167a2c4 restrict lightning to p2wpkh wallets 2020-02-20 21:17:25 +01:00
ThomasV
21fffeb7ad do not store 'outputs' field in requests (it is unused) 2020-02-19 11:24:44 +01:00
SomberNight
0723355a0f
util.Satoshis: note that sometimes this actually has 'msat' precision 2020-02-17 16:52:25 +01:00
SomberNight
a6302b3a12
fix wallet history order: incl both on-chain and LN, sorted by time
GUIs now respect order of wallet.get_full_history(), which is probably the sane
thing to do, given that is the order the "balance" column is calculated in.

fixes #5958
2020-02-17 16:33:54 +01:00
ThomasV
0869e09275 Qt: fix balance column 2020-02-17 14:55:10 +01:00
ThomasV
4dc74870e1 Catch exceptions raised in LNWorker._pay_to_route
Reset payment status if an exception is caught.
Also, do not pass status to the 'invoice_status' network callback.
This fixes #5869, #5870, #5964.
2020-02-17 12:33:43 +01:00
ThomasV
e3ccfe6449 kivy: make backups optional 2020-02-15 17:26:03 +01:00
ThomasV
d9172ade71 kivy: use password + pin_code
- password is per wallet, is retained in memory
 - pin code is saved in config
2020-02-15 17:09:09 +01:00
ThomasV
d5dc8d1ab2 kivy: save pin code in memory 2020-02-15 16:28:15 +01:00
ThomasV
2dad87cbb4 Automate backups:
- backup wallet file on each channel creation
 - on android, a backup password is entered in settings
 - on desktop, the backup path is in settings
2020-02-15 16:28:15 +01:00
ThomasV
cee8607218 save_backup: use db.dump() to clone the db 2020-02-15 16:28:15 +01:00
ThomasV
87b7d2c0c0 wallet backup function for kivy/android 2020-02-15 16:28:15 +01:00
ThomasV
62eceeb573 Save and read lighting backups (Qt) 2020-02-15 16:28:15 +01:00
ThomasV
2a7b5081c9 channel states: make sure that closing_txid is saved if channel is closed 2020-02-14 13:25:04 +01:00
SomberNight
ab4e2dd9f0
wallet: fix is_mine/can_sign. don't just rely on ks, also check script
Previously a standard (single-sig) wallet would consider a multisig txin as is_mine
(if the keystore found its pubkey in the txin).

fixes #5948
2020-02-12 18:14:07 +01:00
SomberNight
0d33da2f95
wallet: (sanity) is_mine now guaranteed to handle 'None' input 2020-02-12 18:14:04 +01:00
SomberNight
0a5ad9fda4
ecc: small API clean-up 2020-02-11 16:42:02 +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
ThomasV
dbceed2647 Restructure wallet storage:
- Perform json deserializations in wallet_db
 - use StoredDict class that keeps tracks of its modifications
2020-02-04 13:35:58 +01:00
SomberNight
a041a0c075
wallet: log when saving already paid invoice
(maybe it should not be allowed?)
2020-01-21 16:50:45 +01:00
SomberNight
6d270364c6
qt paytoedit: properly handle multiple max ('!') outputs 2020-01-18 04:15:44 +01:00
SomberNight
94888739d3
try to fix "--offline" mode 2020-01-09 19:23:24 +01:00
SomberNight
9b28f6df7b
wallet: encrypt storage by default
notably, now also in kivy
2019-12-19 14:22:47 +01:00
SomberNight
79681c90e0
wallet._is_onchain_invoice_paid: support "zero amount" invoice 2019-12-17 22:12:51 +01:00
SomberNight
02baae10d7
kivy: implement opening storage-encrypted wallet files 2019-12-17 18:39:52 +01:00
SomberNight
7b49832a3f
payment requests: fix explicit "None" expiration
Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\main_window.py", line 994, in <lambda>
    self.create_invoice_button.clicked.connect(lambda: self.create_invoice(False))
  File "...\electrum\electrum\gui\qt\main_window.py", line 1123, in create_invoice
    key = self.create_bitcoin_request(amount, message, expiry)
  File "...\electrum\electrum\gui\qt\main_window.py", line 1132, in create_bitcoin_request
    addr = self.wallet.get_unused_address()
  File "...\electrum\electrum\wallet.py", line 1452, in wrapper
    addr = func(self, *args, **kwargs)
  File "...\electrum\electrum\wallet.py", line 1465, in get_unused_address
    addrs = self.get_unused_addresses()
  File "...\electrum\electrum\wallet.py", line 1459, in get_unused_addresses
    in_use_by_request = [k for k in self.receive_requests.keys() if self.get_request_status(k)[0] != PR_EXPIRED]
  File "...\electrum\electrum\wallet.py", line 1459, in <listcomp>
    in_use_by_request = [k for k in self.receive_requests.keys() if self.get_request_status(k)[0] != PR_EXPIRED]
  File "...\electrum\electrum\wallet.py", line 1535, in get_request_status
    if exp > 0 and time.time() > timestamp + exp:
TypeError: '>' not supported between instances of 'NoneType' and 'int'
2019-12-16 21:03:34 +01:00
ThomasV
2c6a1f55fb
Merge pull request #5825 from SomberNight/201912_local_tx_can_be_partial
wallet: allow saving partial tx as local (if it has a txid)
2019-12-15 16:40:46 +01:00