Commit Graph

681 Commits

Author SHA1 Message Date
f321x
0f442f4c85 plugin: nwc: improve filtering of expired requests
improve the filtering of incoming requests by checking if they have
explicitly set an expiration tag. If so, they will only be ignored if
this timestamp is exceeded. Otherwise requests older than 30 secons will
get ignored and an error will get sent to the client so the client is
aware it's request arrived too late.
This is done to prevent handling requests the user may already expects
to have failed.
2025-06-10 19:29:19 +02:00
ThomasV
2024fa4507 Merge pull request #9902 from SomberNight/202506_base64_trailing_garbage
base64.b64decode: always set validate=True
2025-06-04 14:59:20 +02:00
SomberNight
3e4601c61d base64.b64decode: always set validate=True
Notably verifymessage and decrypt(message) were silently ignoring trailing garbage
or inserted non-base64 characters present in signatures/ciphertext.
(both the CLI commands and in the GUI)
I think it is much cleaner and preferable to treat such signatures/ciphertext as invalid.

In fact I find it surprising that base64.b64decode(validate=False) is the default.
Perhaps we should create a helper function for it that set validate=True and use that.
2025-06-03 18:58:05 +00:00
f321x
3daed92be2 nwc: don't announce spending methods if limit is 0
don't return the spending methods pay_invoice and multi_pay_invoice in
the get_info request and the info event so connections can be used for
services that enforce receive only connections.
2025-06-03 14:13:32 +02:00
ThomasV
f0930ffc1d Merge pull request #9839 from SomberNight/202505_transaction_verify_sig_2
transaction: add method verify_sig_for_txin
2025-05-30 14:32:27 +02:00
ThomasV
853b793bef rm verbosity_shortcuts option (unused, redundant) 2025-05-29 16:20:41 +02:00
ThomasV
05733088a3 psbt_nostr: minor fix 2025-05-20 13:52:30 +02:00
Sander van Grieken
000b1bb3b5 swaps: update instructions in manifest, add Max Forward and Max Reverse amounts in qml provider picker 2025-05-19 14:55:34 +02:00
SomberNight
0508625afc transaction: add method verify_sig_for_txin
This new `Transaction.verify_sig_for_txin` function is an instance method of `Transaction` instead of `PartialTransaction`.
It takes a complete txin, a pubkey and a signature, and verifies the signature.

- `get_preimage_script` is renamed to `get_scriptcode_for_sighash` and now effectively has two implementations:
  - the old impl became `PartialTxInput.get_scriptcode_for_sighash`
    - this assumes we are the ones constructing a spending txin and can have knowledge beyond what will be revealed onchain
  - the new impl is in the base class, `TxInput.get_scriptcode_for_sighash`
    - this assumes the txin is already "complete", and mimics a consensus-verifier by extracting the required fields
      from the already complete witness/scriptSig and the scriptpubkey of the funding utxo
- `serialize_preimage` now does not require a PartialTransaction, it also works on the base class Transaction

-----

I intend to use this for debugging only atm: I noticed TxBatcher sometimes creates invalid signatures by seeing
that bitcoind rejects txs with `mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)`.
However the txs in question have multiple txins, with some txins containing multiple signatures, and bitcoind does not tell us
which txin/signature is invalid. Knowing which signature is invalid would be a start, but I can now add some temp debug logging
to `serialize_preimage` to compare the message being signed with the message being verified.

As can be seen from the tests, the signature and the pubkey needs to be manually extracted from the txin to be verified:
we still don't have a script interpreter so we don't have logic to "verify a txin". However this new code adds logic
to verify a signature for a txin/pubkey combo (which is a small part of an interpreter/verifier).
2025-05-18 15:20:19 +00:00
Sander van Grieken
77407fa206 qml: offer same choices as desktop; Open, Discard, Save to wallet 2025-05-16 10:41:41 +02:00
ThomasV
33ea89c94b Merge pull request #9793 from accumulator/psbt_nostr_send_description
PSBT nostr, send invoice/tx description along with PSBT
2025-05-15 09:44:55 +02:00
SomberNight
6c11c75d58 follow-up prev 2025-05-14 13:29:30 +00:00
SomberNight
44f3444795 lnworker: make "preimages" dict private
I want to hook into lnworker.save_preimage (not done yet).
Other modules should not put preimages into the dict directly.
2025-05-14 13:23:02 +00:00
ThomasV
37352ea5a9 Merge pull request #9823 from f321x/psbt_nostr_verify_authors
fix: verify author pubkey of psbt nostr events
2025-05-14 13:12:25 +02:00
Sander van Grieken
a9213c4d66 psbt_nostr: send label along with PSBT 2025-05-14 12:49:33 +02:00
Sander van Grieken
f535817006 psbt_nostr: qml: don't let iterator overwrite param 2025-05-14 12:48:47 +02:00
f321x
759022d3ff fix: verify author pubkey of psbt nostr events
Checks if the pubkey of the author sending the psbt cosigning
request is in our list of cosigner pubkeys to prevent accepting
"fake" requests from other pubkeys.
2025-05-14 11:28:11 +02:00
ThomasV
0d1b6aa432 nwc plugin: improve dialog layout 2025-05-07 12:10:20 +02:00
ThomasV
cec2089917 revealer plugin: do not add icon to status bar
timelock_recovery: move help button to the top
2025-05-07 09:33:08 +02:00
ThomasV
b86be552e7 hardware wallets: show address on device also from tx dialog 2025-05-06 18:22:07 +00:00
SomberNight
ba3783f998 refactor qt.util.ChoiceWidget: introduce ChoiceItem 2025-05-06 18:12:37 +00:00
f321x
e80551192b plugins: structure plugin storage in wallet
store all plugin data by plugin name in a root dictionary `plugin_data`
inside the wallet db so that plugin data can get deleted again.
Prunes the data of plugins from the wallet db on wallet stop if the
plugin is not installed anymore.
2025-05-06 13:16:49 +02:00
ThomasV
59a283a0cc Merge pull request #9778 from accumulator/qt_richlabel
plugins: coldcard: use RichLabel, org imports
2025-05-04 11:20:37 +02:00
f321x
31a9934e59 plugin: add help text to revealer plugin
there is no available documentation on what this plugin does or how it
works, also the concept isn't well known. By adding some information in
the form of a help box the user can understand the concept of what this
plugin does and how it is used.
2025-05-02 14:02:25 +02:00
Sander van Grieken
7146e320f0 plugins: coldcard: use RichLabel, org imports
qt/util.py: introduce RichLabel, allows link select and open
2025-05-01 12:06:16 +02:00
accumulator
3e80d47529 Merge pull request #9755 from f321x/psbt_nostr_proxy
plugin: psbt_nostr: use proxy in psbt cosigning plugin
2025-04-28 22:01:04 +02:00
accumulator
19a159b368 Merge pull request #9756 from f321x/use_relays_directly
plugin: psbt_nostr: read psbt cosigning relays directly from config
2025-04-28 22:00:05 +02:00
Sander van Grieken
c89e8f6f03 qt,qml: move TaskThread to common_qt 2025-04-23 15:24:02 +02:00
f321x
e3a3b65c03 use network proxy in psbt cosigning plugin 2025-04-23 13:54:35 +02:00
f321x
6f5cc7b273 read psbt cosigning relays directly from config 2025-04-23 11:36:38 +02:00
Oren
2fb0dd066f Timelock Recovery Extension (#9589)
* Timelock Recovery Extension

* Timelock Recovery Extension tests

* Use fee_policy instead of fee_est

Following 3f327eea07

* making tx with base_tx

Following ab14c3e138

* move plugin metadata from __init__.py to manifest.json

* removing json large indentation

* timelock recovery icon

* timelock recovery plugin: fix typos

* timelock recovery plugin: use menu instead of status bar.

The status bar should be used for displaying status. For example,
hardware wallet plugins use it because their connection status is
changing and needs to be displayed.

* timelock recovery plugin: ask for password only once

* timelock recovery plugin: ask whether to create cancellation tx in the initial window

* remove unnecessary code.

(calling run_hook from a plugin does not make sense)

* show alert and cancellation address at the end.

skip unnecessary dialog

* timelock recovery plugin: do not show transactions one by one.

Set the fee policy in the first dialog, and use the same fee
policy for all tx. We could add 3 sliders to this dialog, if
different fees are needed, but I think this really isn't
really necessary.

* simplify default_wallet for tests

All the lightning-related stuff is irrelevant for
this plugin.

Also use a different destination address
for the test recovery-plan (an address
that does not belong to the same wallet).

* Fee selection should be above fee calculation

also show fee calculation result with "fee: " label.

* hide Sign and Broadcast buttons during view

* recalculate cancellation transaction

The checkbox could be clicked after the fee rate
has been set. Calling update_transactions() may seem
inefficient, but it's the simplest way to avoid such edge-cases.

Also set the context's cancellation transaction to None when the
checkbox is unset.

* use context.cancellation_tx instead of checkbox value

context.cancellation_tx will be None iff the checkbox was unset

* hide cancellation address if not used

* init monospace font correctly

* timelock recovery plugin: add input info at signing time.

Fixes trezor exception: 'Missing previous tx'

* timelock recovery: remove unused parameters

* avoid saving the tx in a separate var

fixing the assertions

* avoid caching recovery & cancellation inputs

* timelock recovery: separate help window from agreement.

move agreement at the end of the flow, rephrase it

* do not cache alert_tx_outputs

* do not crash when not enough funds

not enough funds can happen
when multiple addresses are specified
in payto_e, with an amount larger
than the wallet has - so we set
the payto_e color to red.

It can also happen when the user
selects a really high fee, but this
is not common in a "recovery"
wallet with significant funds.

* If files not saved - ask before closing

* move the checkbox above the save buttons

people read the text from top to
bottom and may not understand
why the buttons are disabled

---------

Co-authored-by: f321x <f321x@tutamail.com>
Co-authored-by: ThomasV <thomasv@electrum.org>
2025-04-22 10:02:01 +02:00
ThomasV
3eac741947 Merge pull request #9739 from accumulator/psbt_nostr_fixes
plugins: psbt_nostr: start processing PSBTs after wallet is_up_to_date
2025-04-17 08:34:42 +02:00
ThomasV
c0ddce4586 plugins: rename plugin nostr cosigner, minor tweaks 2025-04-16 10:08:55 +02:00
Sander van Grieken
4e9ec5d2ea plugins: psbt_nostr: exclude 2FA wallets 2025-04-16 10:05:54 +02:00
Sander van Grieken
182accb9fb plugins: psbt_nostr: move can_send_psbt logic from GUI to backend, fix qml wallet switch bug 2025-04-16 09:47:41 +02:00
Sander van Grieken
eb52090fee plugins: psbt_nostr: start processing PSBTs after wallet is_up_to_date
also don't break the receive loop when an invalid tx is received.
2025-04-16 09:13:36 +02:00
ThomasV
9d42505eec psbt_nostr: add plugin icon to txdialog button 2025-04-15 18:23:58 +02:00
ThomasV
dff1d5b0c1 Merge pull request #9694 from accumulator/qml_psbt_over_nostr
psbt_nostr: split generic and UI parts, implement for qml
2025-04-15 18:12:17 +02:00
Sander van Grieken
3b97ab7407 plugins: psbt_nostr: qt: offer 3 choices for each PSBT; 'Open, Discard, Save to wallet' 2025-04-15 17:38:11 +02:00
ThomasV
34a8ec64f8 move audio_modem icons to plugin dir, so that the plugin is self-contained.
This requires changing the API of OverlayControlMixin.addButton
2025-04-15 15:34:01 +02:00
Sander van Grieken
60bd6327ce plugins: psbt_nostr: let GUI handle a received PSBTs one by one by pausing receiving additional PSBTs until PSBT dialog is closed.
Accepting a PSBT opens the Tx dialog and pauses receiving additional PSBTs until the Tx dialog is closed.
Rejecting a PSBT will start a cooldown and accept all pending PSBTs into the history for later inspection.
2025-04-15 14:06:57 +02:00
Sander van Grieken
3ff84f08a6 plugins: psbt_nostr: implement for qml 2025-04-15 14:06:29 +02:00
Sander van Grieken
13a4076f22 plugins: psbt_nostr: split generic and UI parts 2025-04-15 14:00:36 +02:00
ThomasV
1162f45bd5 plugins: minor tweaks
- add icon to PluginDialog
 - add icon to psbt_nosr
 - rename 'PSBT Nostr' as 'Nostr Multisig'
2025-04-15 12:23:03 +02:00
ThomasV
a92e65c561 plugins: add plugin icon to menu in init_menubar 2025-04-15 10:33:14 +02:00
ThomasV
dcf632ed1e add icons for nwc and labels plugins 2025-04-15 10:23:05 +02:00
ThomasV
0831fc3b80 plugins: move wallet-related settings to the wallet menu
Plugins should use the init_menubar hook.
References are kept to the various menu objects.
2025-04-15 10:01:00 +02:00
ThomasV
8c028f7528 Add/remove plugins from GUI
- both internal and external plugins require GUI install
   (except internal HW plugins, which are 'auto-loaded' and hidden)
 - remove init_qt hook
 - in Qt, reload wallet windows if plugin enabled/disabled
 - add 'uninstall' button to PluginDialog
 - add 'add plugins' button to wizard hw screen
 - add icons to the plugin list
2025-04-15 08:35:10 +02:00
ThomasV
c93b13f6d9 Make it possible to create zip plugins from internal plugins
specifically:
 - add 'name' field to manifest.json
 - make 'version' optional in contrib/make_plugin
 - fix import in jade plugin
2025-04-14 11:54:04 +02:00
ThomasV
eff8b65355 Plugins: pass wallet to settings_dialog
Also, remove settings_widget method.
The widget should always be a button.

nwc: is_initialized -> initialized
2025-04-12 11:09:15 +02:00