Commit Graph

329 Commits

Author SHA1 Message Date
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
SomberNight
933d8861ce mnemonic.make_seed: de-duplicate num_bits default magic number 2020-12-08 10:00:34 +01:00
SomberNight
f0cca25303 wallet: fix dscancel for "not all inputs ismine" case
fixes #6693
2020-11-25 09:00:44 +01:00
SomberNight
1c07777e13 follow-up prev
ah, forgot to commit this file
2020-11-05 03:10:06 +01:00
SomberNight
ea22d0073e config: distinguish knowing mempool is empty vs not having mempool_fees
config.mempool_fees is now [] if server claims mempool is ~empty,
and None if no valid histogram has been received from server.
(previously it used to be [] in both cases)
2020-10-27 18:55:39 +01:00
SomberNight
eefb68c82b transaction: change Transaction.is_segwit_input(txin) to txin.is_segwit() 2020-10-24 08:03:13 +02:00
ThomasV
59f7d4b02d fix #6676 and remove dead code 2020-10-23 11:31:04 +02:00
ThomasV
5d90790726 wallet.py: always instantiate lnbackups 2020-10-22 18:35:49 +02:00
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
bitromortac
6045de759b lightning: enable by default but without gossip
Enables lightning by creating a node private key and storing it in
the wallet. The gossiper is not launched at start up, only if there
are existing channels.
2020-10-22 18:05:51 +02:00
SomberNight
f125a06453 wallet: simplify get_wallet_delta 2020-10-18 20:37:29 +02:00
SomberNight
e71fa4924f wallet: rm wallet.txin_value 2020-10-18 20:37:21 +02:00
SomberNight
bde415cae7 wallet: don't try to get_input_tx from network when offline
related: https://github.com/spesmilo/electrum/issues/6648#issuecomment-708499893

Trying to fetch the prev tx from the network is a blocking operation with
a 10 sec timeout - we should not hang for 10 seconds if there is no network connection.
2020-10-14 19:30:10 +02:00
ghost43
83143f421a Merge pull request #6641 from SomberNight/202010_dscancel
wallet: implement cancelling tx by double-spending to self ("dscancel")
2020-10-13 17:42:10 +00:00
SomberNight
4b6c86ecbe wallet: make labels private, and access to need lock
e.g. labels plugin iterated over wallet.labels on asyncio thread while user could trigger an edit from Qt thread
2020-10-13 18:57:55 +02:00
SomberNight
3a4f07c345 wallet: implement cancelling tx by double-spending to self ("dscancel") 2020-10-09 17:36:37 +02:00
SomberNight
ca5b93f07d wallet: cpfp to send to a change address instead of receive address 2020-10-09 17:34:20 +02:00
SomberNight
ad03c1e3cb wallet: (fix) bump_fee and cpfp now returns tx with all wallet-info
Previously e.g. bip32 derivation info was missing for change outputs in partial tx returned by bump_fee.
This was not exposed to users as the GUI TxDialog calls `tx.add_info_from_wallet(self.wallet)`.
2020-10-08 19:30:02 +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
6d86f4dc18 wallet set_tx_label_based_on_invoices: don't overwrite custom label
related: #6545
2020-08-31 22:00:52 +02:00
SomberNight
55eb62bb90 wallet.get_relevant_invoice_keys_for_tx: take lock in callee not caller 2020-08-31 21:58:47 +02:00
SomberNight
6b4edc650a qt history: fixes for tx context-menu "View invoice" if more than one
fixes #6516

coalesce "View invoice" options into submenu if there are multiple;
also make sure lambda uses bound argument
2020-08-31 20:55:14 +02:00