1
0
Commit Graph

16984 Commits

Author SHA1 Message Date
SomberNight
711a325085 main_window: split out "walet info" dlg into separate file
- no semantic changes, only moving code
- the change in qt/util.py is to avoid GC issues
  - due to moving code, the group was moving out of scope and getting GC-ed,
    as we only keep a reference to the vbox

(idea from 263fb2ba33 )
2023-10-31 17:41:11 +00:00
SomberNight
3060372894 qt wizard: WCHaveMasterKey: use check_multisig_constraints
These checks were missing from validation. e.g. duplicate master keys were allowed.
2023-10-31 17:43:15 +01:00
SomberNight
4b2d8f062c qt wizard: fix WCHaveMasterKey for first multisig cosigner
fixes https://github.com/spesmilo/electrum/issues/8665
2023-10-31 17:43:15 +01:00
SomberNight
7df057aaf9 qt wizard: simplify WCHaveSeed 2023-10-31 17:43:15 +01:00
robertmin2
33ac0b4591 Update .cirrus.yml 2023-10-31 16:57:52 +01:00
JeremyRand
a7f0c90c8a Add pow_hash_header abstraction (#7592)
There is no reason why the hash function for identifying a block and the
hash function used to instantiate Hashcash must be the same; it's only a
coincidence that Bitcoin happens to use the same hash for both use
cases.  Reflecting this fact by adding this abstraction makes the code
more flexible.

Co-authored-by: Jeremy Rand <jeremyrand@danwin1210.de>
2023-10-31 14:02:20 +00:00
JeremyRand
a3d7df48db Cirrus: Mark E722 linter as mandatory (#8668)
These linter warnings were all fixed in
312f2641e7, so making CI enforce them will
reduce the risk of regressions.

Co-authored-by: Jeremy Rand <jeremyrand@danwin1210.de>
2023-10-31 13:52:24 +00:00
SomberNight
564b6c29b7 wizard: fix self._logger vs self.logger
AttributeError: 'QENewWalletWizard' object has no attribute 'logger'
2023-10-30 18:16:00 +00:00
SomberNight
da8e6c2fbf wallet: check that multisig wallet does not have duplicate masterkeys
The wizard should technically disallows this at creation time,
but this second layer sanity check could not hurt.
Also, looks like the wizard check is not working properly atm
(regression from qt wizard refactor).
2023-10-30 17:22:08 +00:00
ThomasV
120faa480e If trampoline is enabled, do not add non-trampoline nodes to invoices
Rationale: The sender should not assume that they share the same list of
hardcoded trampolines as the receiver.
2023-10-29 16:21:25 +01:00
Sander van Grieken
4d60432064 qml: add share option for address in InvoiceDialog 2023-10-29 12:33:25 +01:00
ThomasV
1170927e6b Change the constructor of LNWorker, passing node_keypair instead of xprv.
There is no need for payment_secret_key and backup_key in this class
2023-10-27 18:28:36 +02:00
SomberNight
6506abf583 lnworker: use PaymentFeeBudget
- introduce PaymentFeeBudget, which contains limits for fee budget and cltv budget
  - when splitting a payment,
    - the fee budget is linearly distributed between the parts
      - this resolves a FIXME in lnrouter ("FIXME in case of MPP")
    - the cltv budget is simply copied
  - we could also add other kinds of budgets later, e.g. for the num in-flight htlcs
- resolves TODO in lnworker ("todo: compare to the fee of the actual route we found")
2023-10-27 16:01:23 +00:00
SomberNight
53a8453e3b trampoline: fix off-by-one confusion of fees
The convention is that edges (start_node -> edge_node) store
the policy/fees for the *start_node*.
This is what the non-trampoline edges were already using (for a long time),
but the trampoline ones were off-by-one (policy was for end_node),
which was then worked around in multiple places, to correct for...

i.e. I think because of all the workarounds, there was no actual bug,
but it was just very confusing.

Also note that the prior usage of trampoline edges would not work if
we (sender) were not directly connected to a TF (trampoline-forwarder)
but had extra edges in the route to even get to the first TF.
Having the policy corresponding to the start_node of the edge would work
even in that case.
2023-10-27 14:24:19 +00:00
SomberNight
097a10f84d qt: window.how_lightning_invoice: routing_e should be read-only 2023-10-27 14:24:16 +00:00
SomberNight
39ef1cd4b9 mpp_split: make SplitConfig a subclass of dict, not just a type-hint 2023-10-27 14:24:12 +00:00
ThomasV
4a6c55ef7b test_lnpeer: add more tests, combining forwarding and hold invoices 2023-10-27 16:09:56 +02:00
SomberNight
0b25e593d5 lnworker.get_channel_by_short_id: give priority to real SCIDs
always check real SCIDs first, before checking aliases
2023-10-26 14:32:36 +00:00
ThomasV
fac5153329 Merge pull request #8659 from accumulator/issue_8658
request: amount_msat is set to None in Request when creating request …
2023-10-25 17:55:39 +02:00
SomberNight
abe700167f qt send tab: HelpLabel for "pay to" field: update text
- maybe make it more readable
- mention new syntax for raw scripts
  - see 3ff588049e
2023-10-24 16:47:05 +00:00
SomberNight
bb76b836a3 addr_sync.receive_tx_callback: rm redundant tx_hash arg 2023-10-24 16:07:30 +00:00
ThomasV
fce83c708c fail_swap: do not remove swap if it has been funded 2023-10-24 17:25:53 +02:00
SomberNight
66e2c779ea Merge remote-tracking branch 'remotes/sombernight/202310_merge_duplicate_outputs'
see https://github.com/spesmilo/electrum/pull/8474
2023-10-24 14:51:51 +00:00
SomberNight
227e257444 (follow-up) wallet: add option to merge duplicate tx outputs 2023-10-24 14:41:39 +00:00
Sander van Grieken
420e584f4e request: amount_msat is set to None in Request when creating request and amount is 0 or undefined. 2023-10-24 13:48:00 +02:00
ThomasV
36814d731a follow-up 45b248fdef 2023-10-24 13:15:03 +02:00
ThomasV
e341a6794b lnworker: fix get_scid_alias for forwarding
Note: this issue is currently not detected in python unittests,
it shows up only in regtest, and is not currently tested.
One would need to use a proper LNWallet instance in unit tests.
2023-10-24 13:05:35 +02:00
ThomasV
45b248fdef regtest: use static fees instead of hardcoded value
this allows to bump fees using "setfeerate"
2023-10-24 12:24:26 +02:00
sha-265
ae8a546bb9 Merge multiple outputs to same address 2023-10-23 16:12:30 +00:00
Sander van Grieken
eb676b3dc1 qml: don't show error when textfield is empty, don't log error when optional propert is undefined 2023-10-23 15:30:56 +02:00
ThomasV
b0dbdfd5e4 test_lnpeer: split some tests, remove redundant test 2023-10-23 13:02:02 +02:00
ThomasV
6dfbdec73e follow-up prev commit 2023-10-20 13:52:55 +02:00
ThomasV
b26f954c2d lnworker.pay_to_node: skip error handling if sender_idx is None 2023-10-20 13:42:12 +02:00
ThomasV
f8781364d2 test_lnpeer:
- Refactor _run_mpp so that it takes only one set of arguments.
   Success and failure conditions are now tested by calling
   _run_mpp multiple times.

 - In test_payment_multipart with_timeout, check that the received
   failure message actually is MPP_TIMEOUT, and not a generic
   failure. Since the onion is obfuscated by the forwarding node,
   this tests that obfuscate_onion_packet and decode_onion_packet
   work as expected.
2023-10-20 11:36:50 +02:00
ThomasV
b776d79f7f lnpeer: move access to payment_secret inside try..except block, as it might raise 2023-10-20 10:12:14 +02:00
SomberNight
687171c36a exchange_rate: cleaner log line for "failed fx history"
related a38e723b40
2023-10-19 17:15:41 +00:00
SomberNight
22a8348303 renames: use consistent naming of cltv delta vs cltv abs
to avoid confusing relative vs absolute cltvs
(see b0401a6386)
2023-10-19 16:40:05 +00:00
ThomasV
b645da6514 test_lnpeer: separate graph creation from run_trampoline 2023-10-19 18:32:04 +02:00
SomberNight
f78340efbc lnworker: (trivial) fix type hint
follow-up 4c42840c1c
2023-10-19 15:26:20 +00:00
SomberNight
783dc0cdd5 lnpeer.maybe_fulfill_htlc: also check cltv and amt against inner onion
- is_trampoline was True iff we are the final recipient of a trampoline payment
  - in that case, we were only comparing htlc.cltv_expiry against the outer onion cltv
  - we should and do now also compare against the inner onion cltv
- the checks are changed from "!=" to "<", to adapt to bolts PR 1032
  - see b38156b951
  - note that the leniency is needed for the cltv off-by-one
    added in eca10eb04d to work
2023-10-19 15:23:21 +00:00
ThomasV
7ea2e68507 follow-up 4c42840c1c 2023-10-19 16:05:54 +02:00
ThomasV
4c42840c1c lnpeer: obfuscate error pakets of forwarded htlcs, that we
propageate back to the sender.

lnworker: in htlc_fulfilled and htlc_failed, return early if the
htlc was forwarded, so that we do not trigger invoice callbacks
2023-10-19 15:59:26 +02:00
ThomasV
250884489e Revert "lnonion: fix decode_onion_error"
This reverts commit 08132d6b7d.
2023-10-19 13:12:15 +02:00
ThomasV
08132d6b7d lnonion: fix decode_onion_error
error_packet was side-effected by the loop. as a result, decoding
worked only for routes of length 1
2023-10-19 12:58:14 +02:00
SomberNight
eca10eb04d lnpeer.maybe_forward_trampoline: fix cltv calculation
follow-up b0401a6386
2023-10-18 19:22:52 +00:00
SomberNight
a059a9a256 lnpeer.pay: also log hops_data for trampoline_onion
We were already logging the outer-layer hops_data,
now we also log the inner trampoline-onion hops_data.

Example:
```
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | lnpeer.pay len(route)=1
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] |   0: edge=9926297x9781928x61754 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 601299}, 'payment_data': {'payment_secret': b'\xd2\x9cl\xdfV\xd4\xea_\x06{\xed\xc9\xc7\xa6\xf5\xc0\n\x1a\x95\xad\xad\xd2F\xb8;&\x9f\xa1\xe1\xd1\x07H', 'total_msat': 100000000, 'amount_msat': 100000000}}. hmac=None>
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | adding trampoline onion to final payload
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | lnpeer.pay len(t_route)=3
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] |   0: t_node=02389c93b85ef8f7264c6fa3d3b239341c2631c2cab97e815b33453bd8d0254e77 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600723}, 'outgoing_node_id': {'outgoing_node_id': b'\x03\x06\xd9,\x9c\xabRe\x83Mr\x0b\x14(\xf5\x81\xf9\xfb\x9b\xfeV\xc1q\x85&L\xda\xffs\xe5y(\x81'}}. hmac=b'\xe7\x04\xe2>\x9a\xd9\xf0\x92<\xf8Q\xe4\xf4\xd8\x8cr{\x1e\xb1\xee\xb0\xd4R\xba\xe5\xfd\x83\xfc\xd7\xa7\x1dt'>
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] |   1: t_node=0306d92c9cab5265834d720b1428f581f9fb9bfe56c17185264cdaff73e5792881 hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600147}, 'outgoing_node_id': {'outgoing_node_id': b'\x03\x85v\xac:\xf8AUW\xcf\x1d\x12e\xcc\xff\xb1\xea\xd6\x01\xd5\x17HX?\x12\x83\x9cD\xbe\xebC\x82o'}}. hmac=b's-\xe1\xdb\xbc\xa5\x88\x90\xc0\xafu\xab\xba\xb6k\x81\xeae)#\x85\x12fm\xe6\xc3\xbd\xf6\x86eR\xd2'>
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] |   2: t_node=038576ac3af8415557cf1d1265ccffb1ead601d51748583f12839c44beeb43826f hop_data=<OnionHopsDataSingle. payload={'amt_to_forward': {'amt_to_forward': 100000000}, 'outgoing_cltv_value': {'outgoing_cltv_value': 600147}, 'payment_data': {'payment_secret': b'B-P\x01\xc3\x1e#\x19\xf9!\xbb\xd8\xd1pu\xc7J\x11A\xa8J\xfe\xb8\x8a\xb8\xc4Oi\x0f\xe8\xac\xab', 'total_msat': 100000000}}. hmac=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'>
  1.12 | I | P/lnpeer.Peer.[MockLNWallet, alice->bob] | starting payment. len(route)=1.
```
2023-10-18 18:07:21 +00:00
ThomasV
2664ee7f63 pay_to_node: raise failure_msg if we received a trampoline error from the next onion.
that way, the error is sent back to the payer
2023-10-18 19:32:13 +02:00
SomberNight
04d8eec3be tests: change fake block height in test_lnpeer. 0 might hide bugs. 2023-10-18 17:09:53 +00:00
SomberNight
b0401a6386 lnpeer.maybe_forward_trampoline: fix abs-cltv vs cltv-delta confusion
lnworker.pay_to_node(min_cltv_expiry=) expects a relative cltv, and
we were passing an absolute one.
It is not so clear what precisely should be passed here, and that is
because pay_to_node's API was not written with forwarding in mind.
The value chosen here is just some guess that typically should work.
2023-10-17 18:22:36 +00:00
SomberNight
0273659e6e trustedcoin: fix keystore name (2)
follow-up 56e80c20d7
2023-10-17 14:33:05 +00:00