-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: scheduled transactions prototype #242
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really nice.
It would be better to not have a global setting with "keep funds in wallet", but instead make this a button for each of the three addresses. This way I can set one or two outgoing addresses, and toggle the selfspend for the third.
how much time do we have until the other PR and our part will be delivered? I would try to flesh something out that is more or less final and includes all our last insights from the call. |
Tested and works as expected in general. Really great job 💪 Since it is hidden with a feature flag, it is safe to be merged These are some key takeaway while testing the PR: Summary
Problems/Observations
Suggestions
Nits
Max brought up a good suggestion too – I think it is best to keep track of these improvements in distinct issues. What do you think @MaxHillebrand ?
@editwentyone I think it is safe to say that with the main functionality now merged and released in JM v0.9.6, Jam is completely independent regarding release date. However, this PR – with or without visual improvements – already brings massive benefits to Jam. What do you think about adding UI improvements step by step in conjunction with feedback from users? This approach does have it's downsides too, but I guess it is quite difficult to come up with a "more or less final" version. If there is no "hard no" from you, I'd be in favor of merging this as is (maybe some tiny adaptions, e.g. show errors, prevent quick restarts, etc.). Keep in mind that it is still hidden behind a feature flag. |
Thanks for the detailed review @theborakompanioni. My suggestion for going forward with this:
This allows us to get something out of the door quickly which we can then iterate on. I think the project is still in a state where we can comfortably release early and often and make sure we get maximum feedback and learn as much as possible while doing so. Thoughts? cc @dergigi |
Good point! The only tricky thing is that we have to explain to the user that he can't control the amount that goes to each destination address. Eventually we'll have to explain that anyway, though. I'll track this as improvement but not add it right away in this PR. I think that it'll be easier to think about wording and how exactly the behavior should be if we do it in a separate PR after we have one more iteration of the UI. Hope that works for you. 🤞 |
Let's iterate! Final versions never really stay final from my experience. 😉 Once we have a next iteration we can start working on it right away. There backend functionality was released yesterday so it's not a blocker for us anymore. |
src/components/Jam.jsx
Outdated
const newAddresses = getNewAddresses(3, INTERNAL_DEST_ACCOUNT) | ||
await setFieldValue('dest1', newAddresses[0], true) | ||
await setFieldValue('dest2', newAddresses[1], true) | ||
await setFieldValue('dest3', newAddresses[2], true) | ||
} else { | ||
await setFieldValue('dest1', '', false) | ||
await setFieldValue('dest2', '', false) | ||
await setFieldValue('dest3', '', false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the await
s are not necessary.. setFieldValue
returns plain void
. See formik#setfieldvalue.
BUT: If they are removed, the form does not work correctly anymore.. do you know what's wrong with that?
(To reproduce the error, enter an invalid address in the input field and tick "Keep funds in Jam")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good catch. I guess the issue is that without the await
, the validate function gets triggered once for each setFieldValue
call resulting it only seeing the field that was changed by the call that triggered the validation:
With the await
, the validation function magically sees the values changed by the other setFieldValue
calls:
So I guess it's just pure luck that it works. However, not sure if we should be relying on such undocumented behavior, though. I'll have a look to see if I can find a workaround. There's an endless thread on the Formik repo about something similar with no good conclusion unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uff.. sorry for getting you into that. Should we add a small warning as comment?
Otherwise I already know that I will try to remove them.. because I forget that they serve a purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we leave them then definitely with a comment. But I feel bad for using it in such an undocumented way. I'll look into it a bit more and if I can't find something I'll add a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok changed it so that the form is explicitly verified again when all 3 addresses are filled out. Might be not ideal but at least works based on documented APIs only. Let me know what you think!
So just for reference, I managed to create a schedule that looks like this, when starting the scheduler without spendable utxos (either no utxos or all are frozen):
First row is the "account".. After this, the wallet cannot be opened anymore - Jam will display "No wallet loaded" from now on. Same happens with the CLI: root@1e7dfe3b919b:/src/scripts# ./wallet-tool.py funded.jmdat
User data location: /root/.joinmarket/
2022-05-09 10:03:07,498 [DEBUG] rpc: getblockchaininfo []
2022-05-09 10:03:07,500 [DEBUG] rpc: listwallets []
2022-05-09 10:03:07,500 [DEBUG] rpc: getwalletinfo []
2022-05-09 10:03:07,513 [DEBUG] rpc: getnewaddress []
Enter passphrase to decrypt wallet:
Traceback (most recent call last):
File "/src/scripts/./wallet-tool.py", line 6, in <module>
jmprint(wallet_tool_main("wallets"), "success")
File "/src/jmclient/jmclient/wallet_utils.py", line 1570, in wallet_tool_main
wallet = open_test_wallet_maybe(
File "/src/jmclient/jmclient/wallet_utils.py", line 1444, in open_test_wallet_maybe
return open_wallet(path, mixdepth=max_mixdepth, **kwargs)
File "/src/jmclient/jmclient/wallet_utils.py", line 1490, in open_wallet
wallet = wallet_cls(storage, **kwargs)
File "/src/jmclient/jmclient/wallet.py", line 1730, in __init__
super().__init__(storage, **kwargs)
File "/src/jmclient/jmclient/wallet.py", line 1135, in __init__
super().__init__(storage, **kwargs)
File "/src/jmclient/jmclient/wallet.py", line 1441, in __init__
super().__init__(storage, **kwargs)
File "/src/jmclient/jmclient/wallet.py", line 1998, in __init__
self._populate_script_map()
File "/src/jmclient/jmclient/wallet.py", line 2423, in _populate_script_map
super()._populate_script_map()
File "/src/jmclient/jmclient/wallet.py", line 2048, in _populate_script_map
path = self.get_path(md, address_type, i)
File "/src/jmclient/jmclient/wallet.py", line 2466, in get_path
return super().get_path(mixdepth, address_type, index)
File "/src/jmclient/jmclient/wallet.py", line 2124, in get_path
return tuple(chain(self._get_bip32_export_path(mixdepth, address_type),
File "/src/jmclient/jmclient/wallet.py", line 2242, in _get_bip32_export_path
path = (self._get_bip32_mixdepth_path_level(mixdepth), address_type)
File "/src/jmclient/jmclient/wallet.py", line 2311, in _get_bip32_mixdepth_path_level
assert 0 <= mixdepth < 2**31
AssertionError Guess that this must be reported to the server repo as well. Can you verify @dnlggr ? |
+1 to @dnlggr's suggestion. Let's do any nits and smaller improvements incrementally after this PR. |
b4bc365
to
a892e03
Compare
Good find. I think 0afd258 should fixed this. On my machine, the backend response is instant so I can't really test if it works without artificially slowing things down. Can you do a quick check on your end and see if the issue is resolved? |
I think we should be good to merge now (I hope I didn't miss anything). Everything that hasn't been addressed in this PR, I'll address via separate follow up PRs. I'll create issues for that and link them here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 🪨 🪨 🪨
This is a bare minimum MVP-style integration of scheduled transactions.
Before we merge this, we'll have to switch the backend repo back to the upstream
joinmarket-clientserver
repo. We'll be able to do that once the API support for scheduled transactions is released which is scheduled (😅) to be included the next Joinmarket release. Until then I'll keep this PR on draft. It is ready for review though.Give it a spin and let me know how it goes. UI is obviously something that'll change quite a lot in upcoming versions. It's probably okay for a very first version though. Just to get the foot in the door so to speak and have something to iterate on.
Let me know what you think! I'll work on progress reporting in the mean time.
Also let me hear suggestions for the copy. I put something off the top of my head -- haven't really thought about it too deeply.
📸
Relevant backend changes: