-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
5770509
to
2b7a9f6
Compare
2b7a9f6
to
58c2786
Compare
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.
Had a quick look and added some comments. Will need to have a nother look though :)
crates/daemon/src/wallet.rs
Outdated
) -> Result<(xtra::Address<Self>, watch::Receiver<Option<WalletInfo>>)> { | ||
// generate empty export seed | ||
let mut export_seed = [0u8; 256]; | ||
thread_rng().fill(&mut export_seed); |
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.
Given this test will run now regularly we should check if this seed indeed does not hold any Bitcoin 🤑
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.
@bonomat what do you have in mind exactly?
crates/daemon/src/wallet.rs
Outdated
}) | ||
} | ||
} | ||
|
||
impl Actor<ElectrumBlockchain, Tree> { | ||
pub async fn spawn_test( |
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'm not sure this is a good idea: this will run an online test against testnet using public infrastructure.
Besides that it can have random side effects if the server is down, it might slow down our test executions.
Do you think we can use our test wallet for this?
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.
well.. we could do that, but I have the feeling we would very quickly end up with testing only test code. however, I can give it a try.
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.
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!
I am mostly unsure about:
- Importing leading to overwriting the current wallet seed.
- The way we determine the environment.
crates/daemon/src/wallet.rs
Outdated
use tokio_extras::Tasks; | ||
|
||
impl Actor<(), bdk::database::MemoryDatabase> { | ||
pub fn new_offline( | ||
const IMPORT_SEED: [u8; 256] = [ |
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.
🙃 Since it's only used in one test I would just inline it.
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.
❓ Why can't it be a random seed with the right length?
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.
@luckysori I am asserting on the address. To ensure that from the same import seed we will always derive the same address. Before, it was also used to check the balance (it owns 0.001 btc)
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.
Do we need to assert on the address? Maybe it's enough to just check that it changes as that implies that a new wallet has been loaded.
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.
what benefits would we get by that - i feel like the test would be less effective without that assertion.
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 suppose it is valuable to check that importing a wallet is deterministic.
I would then suggest to move the expected seed into the specific test (I believe it is only used once). It's a bit noisy otherwise.
@@ -512,6 +591,7 @@ mod tests { | |||
time_to_lock, | |||
}, | |||
blockchain_client: (), | |||
db: None, |
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.
❓ Why is this field an Option
? I would expect to always be able to provide the database.
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.
@luckysori well, I don't like it either, but I didn't find a better way of doing it with the existing tests. Since the tests mainly use a MemoryDatabase, I do not have a Db available there. Do you have a suggestion?
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.
Hmm, I didn't come up with anything after some limited experimenting. I might come back to this later myself.
01f62ef
to
51eb1c8
Compare
I've committed a change 84a510c which will automatically copy the existing seed file into a backup file with the timestamp in its name. e.g.
Alternatively to the environment variable, I could make use of the app seed argument, meaning if the seed is provided from extern we are not managing it in terms of importing or exporting. This will then be reflect with a simple boolean. e.g. something like that.
I will wait for your feedback before implementing that path though, as I am not sure if this is a much better approach than the current one. |
I think it is better to rely on the presence of the app seed argument, because that is the reason why importing (and perhaps even exporting?) a seed shouldn't be allowed. On the other hand, the What I also care about is disabling the route based on this information, rather than exposing an event via SSE that the client has to interpret. It removes an event that doesn't really belong there imo and it also means that the API is unavailable even if you don't go through the UI. |
That's actually a very good point. I will adapt that - however i still need to transfer the information about the disabled import / export feature. I will implement it using the app seed argument. Thanks for the feedback! |
@luckysori have a look at a98bdb5. I've introduced a managed_wallet flag and added it to the WalletInfo event. Additionally the export / import routes will only be added in case the wallet is managed. I like it much better now, wdyt? |
Nice work! I like it much better too. It makes sense for it to go with the |
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.
Thanks for addressing my comments!
Thanks for taking the time and give me comments 🙂 👍 |
4f8555e
to
4ee33ac
Compare
4ee33ac
to
583a3df
Compare
bors r+ |
Build succeeded: |
resolves #2989
see also #3048