Commit Graph

350 Commits

Author SHA1 Message Date
SomberNight 92226b077a qt tx dialog: handle fiat fee for zero-fee tx
fix #7166
2021-04-01 17:02:34 +02:00
ThomasV bf6ecb6418 make init_lightning callable at runtime, without reloading the wallet 2021-03-31 10:57:36 +02:00
SomberNight 537ec92460 wallet: change init_lightning to sometimes create deterministic LN keys 2021-03-30 21:53:18 +02:00
SomberNight 35bc461fe1 keystore: encapsulate "can_have_deterministic_lightning_xprv" logic 2021-03-30 21:31:37 +02:00
ThomasV bbdfde5b41 fix capital gains 2021-03-30 17:32:43 +02:00
ThomasV 3fc85725aa Merge pull request #7135 from SomberNight/202103_get_utxos_at_height
wallet: implement get_utxos at specific block height
2021-03-29 11:03:11 +02:00
ThomasV e93becf33a wallet.add_transaction: prevent channel backup from being added twice 2021-03-27 14:29:10 +01:00
ThomasV f14b7d5a12 check_password_for_directory: safeguards 2021-03-25 16:12:24 +01:00
SomberNight c2c3ece455 wallet: implement get_utxos at specific block height
This allows looking up what UTXOs the wallet had at a specific time in the past.
2021-03-24 19:37:37 +01:00
ThomasV cd6a468fb9 Android: unify password as soon as we know it is possible 2021-03-23 17:49:27 +01:00
ThomasV 2fee920f43 On Android, if channels are not recoverable, display channel backup when a new channel is created.
Remove the 'android_backups' setting, which was unpractical.
2021-03-19 13:17:58 +01:00
ThomasV 64a931f21e Deterministic NodeID:
- use_recoverable_channel is a user setting, available
   only in standard wallets with a 'segwit' seed_type
 - if enabled, 'lightning_xprv' is derived from seed
 - otherwise, wallets use the existing 'lightning_privkey2'

Recoverable channels:
 - channel recovery data is added funding tx using an OP_RETURN
 - recovery data = 4 magic bytes + node id[0:16]
 - recovery data is chacha20 encrypted using funding_address as nonce.
   (this will allow to fund multiple channels in the same tx)

GUI:
  - whether channels are recoverable is shown in wallet info dialog.
  - if the wallet can have recoverable channels but has an old node_id,
    users are told to close their channels and restore from seed
    to have that feature.
2021-03-19 10:17:02 +01:00
ThomasV 3ed2173a04 remove newlines in get_tx_fee_warning, it does not render well on kivy 2021-03-15 09:26:16 +01:00
ThomasV 2ad49bbc5b Kivy: Show fee dialog before opening a new channel.
Remove fee and rbf from settings, as they are now always proposed
2021-03-13 09:34:19 +01:00
ThomasV 018f09f2af use mktx_for_open_channel in commands module. fix indentation 2021-03-12 19:05:25 +01:00
SomberNight 897f90d6e8 wallet: factor out "what key to use for invoice"
fix: qt request list was not using the correct key
2021-03-12 17:29:54 +01:00
ThomasV 90b228de83 fix wallet get_full_history: add onchain tx for channels not opened by us 2021-03-12 12:15:39 +01:00
SomberNight de6f5a8e03 {daemon,wallet}|.stop: small clean-up 2021-03-10 18:07:15 +01:00
SomberNight 8de52bf523 wallet: (trivial) use kwargs for get_tx_item_fiat 2021-03-09 18:22:30 +01:00
SomberNight 3c019c2f9c daemon/wallet/network: make stop() methods async 2021-03-09 17:52:36 +01:00
ThomasV 652d10aa5f Remove LNBackups object: no longer needed since LNWorker is instantiated by default. 2021-03-09 11:52:04 +01:00
SomberNight e25602ab3b wallet: don't put partial tx as UTXO into psbt
if there is a chain of unsigned txs, we cannot populate NON_WITNESS_UTXO

closes #7080
closes #7009
closes #6482
2021-03-04 13:20:49 +01:00
SomberNight f9f49daad7 tx dialog: uniform high fee warnings between GUIs 2021-02-26 19:02:24 +01:00
SomberNight 058d9ab6bb wallet.bump_fee: add new strategy: decrease payment amounts
- Rename bump_fee "methods" to "strategies".
- Refactor strategies so that bump_fee can use any subset of them in any permutation.
- Adds a new strategy which decreases the payment outputs (instead of change).
2021-02-25 15:32:07 +01:00
SomberNight d800f88bfc (trivial) wallet: fix over-indentation 2021-02-24 19:01:02 +01:00
Marius Baisan 55fdddb0b8 Add back the 'to_height' and 'from_height' to onchain_history command
Exclude unconfirmed transactions from --to_height and include them into --from_height.
The reason being that an unconfirmed transaction will end up eventually into the last
block which most of the time will be higher than --from_height
2021-02-19 13:12:09 +01:00
SomberNight 1dea8393d7 wallet: follow-up b080df9cff 2021-02-16 22:28:11 +01:00
SomberNight 01ed5e7345 wallet.bump_fee: (fix) method2 was bumping too much if output was rm-ed
regression from bafe8a2fff
2021-02-15 10:20:34 +01:00
SomberNight b080df9cff wallet.bump_fee: (fix) make sure input signatures are removed
bump_fee was returning an invalid tx if its input was a
PartialTransaction that had signatures. It was relying on
line 1441 to remove signatures.

Relatedly, the WalletDB used to store such PartialTransactions as
PartialTransaction objects, but only until the program was restarted.
This is because serialising and de-serialising such a tx results in a
Transaction object.

So, combining these two, to reproduce a bug:
- create a tx, sign it, save as local
- bump fee, sign it, save as local
- bump fee --> tx already signed!? --> has old sigs, so it is invalid
2021-02-15 10:20:30 +01:00
SomberNight 914eb9989d wallet: minor clean-up of tx.set_rbf() calls
Better to always call it, to make sure inputs have identical sequence numbers.
2021-02-12 04:59:40 +01:00
SomberNight ca86e35724 wallet.bump_fee: (fix) make sure all inputs have same sequence number
Previously, if bump_fee decided to add new inputs to the tx, they would
have a different sequence number than the existing inputs. This was
unintentional.
2021-02-12 04:59:34 +01:00
SomberNight 27cd078001 wallet: auto-freeze small unconfirmed UTXOs
see #6960
2021-01-29 12:37:15 +01:00
SomberNight bc6f2926f4 commands: add 'freeze_utxo' cmd; to expose this to CLI/RPC 2021-01-22 21:56:11 +01:00
SomberNight da777caa0b wallet: use lock when modifying frozen_{addresses,coins} 2021-01-22 21:56:08 +01:00
ThomasV 6522a1e1a3 fix #6341 2021-01-17 21:11:17 +01:00
ThomasV f130cb53ce bump_dee and dscancel: call tx.estimated_size() after add_input_info().
This is a workaround, see the FIXME. PartialTxInput.is_segwit() should
return the correct value, or raise if information is missing.
2021-01-17 17:26:44 +01:00
ThomasV 7619949b2f fix #6674: raise exceptions if dscancel or cpfp create dust or negative output. 2021-01-14 19:44:15 +01:00
ThomasV be438bdd60 check_password_for_directory: skip non-files 2021-01-14 14:59:14 +01:00
ThomasV 1e4fa83098 Kivy: use the same password for all wallets
When the app is started, the password is checked against all
wallets in the directory.

If the test passes:
 - subsequent wallet creations will use the same password
 - subsequent password updates will be performed on all wallets
 - wallets that are not storage encrypted will encrypted
   on the next password update (even if they are watching-only)

This behaviour is restricted on Android, with a 'single_password' config variable.
Wallet creation without password is disabled if single_password is set
2021-01-13 12:24:19 +01:00
ThomasV a2122a8c19 auto-remove paid invoices from GUI
- delay 3 seconds in GUI
 - kivy remove 'delete' buttons from send/receive screens
2021-01-12 10:59:41 +01:00
ThomasV 90abfda12b add unconfirmed state for onchain invoices and requests 2021-01-12 10:59:11 +01:00
SomberNight 21f13e21b1 wallet: fix bump_fee and dscancel for "not all inputs ismine" case
we fetch the missing prev txs over network

fixes #6551
fixes #6864
2020-12-20 15:29:41 +01:00
SomberNight bb41ef3450 wallet: (fix) bump_fee sometimes created invalid tx that spent orig out
When replacing non-segwit tx, bump_fee in some circumstances created
a tx that tried to spend from the tx-to-be-replaced. There is
explicit logic to avoid this but it only worked for segwit txs.

The change in transaction.py is a no-op, just tried to make it clearer
that the scriptSigs, witnesses are being reset by from_tx().
2020-12-18 19:35:22 +01:00
ThomasV b08f9f3581 fix #6859: height is must be passed to OnchainInvoice constructor 2020-12-18 10:49:45 +01:00
ThomasV 43614af2c4 wallet: use height to determine request status (similar to outgoing invoices) 2020-12-16 12:25:41 +01:00
ThomasV 91cdd12fa2 Merge pull request #6842 from spesmilo/save_height_in_invoices
Save height in invoices, use it to determine invoice status
2020-12-11 19:56:59 +01:00
ThomasV cdfaaa2609 Save height in invoices, use it to determine invoice status (fixes #6609) 2020-12-11 19:55:56 +01:00
SomberNight c81551299e transaction: put full derivation paths into PSBT by default
There are three export options for exporting a PSBT.
The default option previously only put derivation path suffixes for pubkeys
(paths relative to the intermediate xpub), now it puts the full path
(if is known by the keystore).

The "export for hardware device; include xpubs" option works same as before:
it puts both full paths and also global xpubs into the PSBT.
Hence the difference between the default option and the "include xpubs" option
is now only that the latter puts global xpubs into the PSBT.

This change is largely made for user-convenient in mind.
Now exporting a PSBT should be less error-prone: particularly for the
single-signer coldcard with sdcard usage, the default option will now work.

closes #5969
related #5955
2020-12-10 17:39:12 +01:00
SomberNight ac223073ba keystore: handle unusual derivation paths in PSBT
If a tx contained a derivation path for a pubkey,
with a length=2 der suffix,
with the first element of the suffix not in (0, 1),
with a fingerprint that matches either our root or intermediate fp,
then processing that tx would raise and result in a crash reporter.

Traceback (most recent call last):
  File ".../electrum/electrum/gui/qt/main_window.py", line 2718, in do_process_from_text
    self.show_transaction(tx)
  File ".../electrum/electrum/gui/qt/main_window.py", line 1041, in show_transaction
    show_transaction(tx, parent=self, desc=tx_desc)
  File ".../electrum/electrum/gui/qt/transaction_dialog.py", line 84, in show_transaction
    d = TxDialog(tx, parent=parent, desc=desc, prompt_if_unsaved=prompt_if_unsaved)
  File ".../electrum/electrum/gui/qt/transaction_dialog.py", line 680, in __init__
    self.set_tx(tx)
  File ".../electrum/electrum/gui/qt/transaction_dialog.py", line 218, in set_tx
    tx.add_info_from_wallet(self.wallet)
  File ".../electrum/electrum/transaction.py", line 1944, in add_info_from_wallet
    wallet.add_input_info(txin, only_der_suffix=only_der_suffix)
  File ".../electrum/electrum/wallet.py", line 1573, in add_input_info
    is_mine = self._learn_derivation_path_for_address_from_txinout(txin, address)
  File ".../electrum/electrum/wallet.py", line 2609, in _learn_derivation_path_for_address_from_txinout
    pubkey, der_suffix = ks.find_my_pubkey_in_txinout(txinout, only_der_suffix=True)
  File ".../electrum/electrum/keystore.py", line 155, in find_my_pubkey_in_txinout
    path = self.get_pubkey_derivation(pubkey, txinout, only_der_suffix=only_der_suffix)
  File ".../electrum/electrum/keystore.py", line 391, in get_pubkey_derivation
    if not test_der_suffix_against_pubkey(der_suffix, pubkey):
  File ".../electrum/electrum/keystore.py", line 368, in test_der_suffix_against_pubkey
    if pubkey != self.derive_pubkey(*der_suffix):
  File ".../electrum/electrum/keystore.py", line 491, in derive_pubkey
    assert for_change in (0, 1)
AssertionError
2020-12-09 09:42:51 +01:00
SomberNight f74ac1a741 cli/rpc: fix 'sweep' command
fixes #6825
2020-12-08 12:21:56 +01:00