Skip to content
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

Wallet Decrypt - Mnemonic #180

Merged
merged 15 commits into from
Sep 15, 2017
Merged

Wallet Decrypt - Mnemonic #180

merged 15 commits into from
Sep 15, 2017

Conversation

skubakdj
Copy link
Contributor

@skubakdj skubakdj commented Sep 8, 2017

What This Does

Broadly speaking, two things are accomplished:

What Still Needs to Happen

A few things to get done before this is merged:

  • Need to write unit tests for decryptMnemonicToPrivKey
  • Need to do more manual testing
  • Need to test against Trezor to make sure I didn't break anything (may need some help for this one)

return dPath.split("'/").length === 4;
//TODO: use a regex to detect proper paths
const len = dPath.split("'/").length;
return len === 3 || len === 4;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, BIP44 is way more readable than BIP32. Would have saved me a lot of headaches: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

Would you mind changing the comment to reflect that BIP 44 is really where we're determining that 4 is the amount, but that ledger is the exception for 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, will do 👍

})
);

try {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try/catch introduced because derived addresses wouldn't populate on network/api failure

@dternyak dternyak added the wip label Sep 8, 2017
: 'is-invalid'}`}
value={phrase}
onChange={this.onMnemonicChange}
placeholder={translateRaw('x_Mnemonic')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can save the translateRaw import by passing true as the argument for the textOnly parameter:

translate('x_Mnemonic', true)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes me question if translateRaw should even be exported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda like it as a separate function, makes the flow typing a little easier (Not two return types) and is very easy to understand over mystery args.

Copy link
Contributor

@wbobeirne wbobeirne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I'm out of town sans Trezor, but I'll run this ASAP on Tuesday to make sure it still works.

: 'is-invalid'}`}
value={phrase}
onChange={this.onMnemonicChange}
placeholder={translateRaw('x_Mnemonic')}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda like it as a separate function, makes the flow typing a little easier (Not two return types) and is very easy to understand over mystery args.

this.setState({ phrase: e.target.value });
};

onChooseAddress = (e: SyntheticInputEvent) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor, but this feels like a misnomer. This isn't when you choose the address, this is more like opening the modal, or validating the phrase / pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, I'll switch it to onDWModalOpen, unless you can suggest something else.

{
"label": "Expanse",
"value": "m/44'/40'/0'/0"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing multiple now, might be worth making this a JS file so that we can assign these repeated ones to variables and reuse them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted dpaths.json to dpaths.js.

return dPath.split("'/").length === 4;
//TODO: use a regex to detect proper paths
const len = dPath.split("'/").length;
return len === 3 || len === 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow, BIP44 is way more readable than BIP32. Would have saved me a lot of headaches: https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki

Would you mind changing the comment to reflect that BIP 44 is really where we're determining that 4 is the amount, but that ledger is the exception for 3?

@@ -40,13 +40,15 @@ type Props = {
dPaths: { label: string, value: string }[],
publicKey: string,
chainCode: string,
seed: string,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a required prop, but the DecryptWallet/Trezor.jsx wasn't altered to send it (And probably shouldn't, I think this should be optional.) Any idea why flow didn't catch that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I'll make it optional. Not sure why flow didn't catch that, it definitely should have...

}
} catch (err) {
console.log(err);
//TODO: maybe communicate API call error to user?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, I think you can just get away with a yield put(showNotification(...

}
} catch (err) {
console.log(err);
//TODO: maybe communicate API call error to user?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, showNotification

@wbobeirne
Copy link
Contributor

Tested the branch on my Trezor, everything seems to work fine. Still not sure how it's not complaining more about the lack of seed arg, but looks like no regressions here.

@dternyak
Copy link
Contributor

dternyak commented Sep 12, 2017

@wbobeirne Interesting. I'm currently unable to send via Trezor on the latest develop. You're able to send via Trezor on this branch? Notice: The signed tx generates, but when attempting to broadcast it the node always responds with

Error: Insufficient funds. The account you tried to send transaction from does not have enough funds. Required XXX000000000000 and got: 0.

There is likely something wrong with the generation of the signedTx.

I have more info listed here: MyEtherWallet/MyEtherWallet#182 (comment)

@dternyak
Copy link
Contributor

dternyak commented Sep 12, 2017

I'm going to attempt to send via Trezor on this branch -- will update with my results.

I get a similar failure when testing on this branch.

@wbobeirne Can you confirm whether or not you attempted to actually broadcast the signedTx, and not just generate it?

@wbobeirne
Copy link
Contributor

Sorry, allow me to reiterate, I only tested unlocking. This branch is a bit behind develop, and I didn't test sending until it was up to date.

@@ -165,7 +171,7 @@ export class WalletDecrypt extends Component {

onUnlock = (payload: any) => {
this.props.dispatch(
WALLETS[this.state.selectedWalletKey].unlock(this.state.value || payload)
WALLETS[this.state.selectedWalletKey].unlock(payload || this.state.value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Payload is a SyntheticEvent in some cases. We'll either need to check if payload isn't one, or change how onUnlock is called so that it's never sent an event.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, in that case we just need to bring develop back into this bad boy.

@skubakdj skubakdj force-pushed the wallet-decrypt-mnemonic branch from 79241a1 to d518ba6 Compare September 14, 2017 17:35
@skubakdj skubakdj added status: ready for review Open PR's that are ready for technical review. Replaced with "changes needed" or "ready to merge". and removed wip labels Sep 14, 2017
@skubakdj
Copy link
Contributor Author

@dternyak, @wbobeirne I think I've addressed all the comments with these latest commits. Also added some tests, rebased this branch with develop, and did some manual testing. Any additional feedback on the changes?

Also, still haven't been able to test using Trezor, but I can get to it tonight if need be.

@dternyak
Copy link
Contributor

dternyak commented Sep 14, 2017 via email

* Match v3 more closely.

* Require wallet index on deterministic wallets, update trezor to send index.

* remove redundent stripAndLower function and rename existing stripHex to stripHexPrefixAndLower
@dternyak dternyak merged commit c88e96d into develop Sep 15, 2017
@dternyak dternyak deleted the wallet-decrypt-mnemonic branch September 15, 2017 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready for review Open PR's that are ready for technical review. Replaced with "changes needed" or "ready to merge".
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants