-
Notifications
You must be signed in to change notification settings - Fork 4
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: added getAddressAtIndex method and API #425
Conversation
Codecov Report
@@ Coverage Diff @@
## master #425 +/- ##
==========================================
+ Coverage 95.56% 95.60% +0.03%
==========================================
Files 40 40
Lines 2436 2458 +22
Branches 274 278 +4
==========================================
+ Hits 2328 2350 +22
Misses 108 108
|
@@ -0,0 +1,24 @@ | |||
{ |
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 this file accepts comments, I think we should explain what this is.
Maybe also mention in the README (or some other doc that we would link in the README) that we have these configs and how to use them.
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.
Done in 5c9ab39
src/db/index.ts
Outdated
@@ -7,7 +7,7 @@ | |||
import { strict as assert } from 'assert'; | |||
import { ServerlessMysql } from 'serverless-mysql'; | |||
import { get } from 'lodash'; | |||
import { OkPacket } from 'mysql'; | |||
import { OkPacket } from 'mysql2'; |
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 this change was needed?
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 uncertain if this change should be made here. I feel that having it in its own PR would make it easy for future developers to understand that:
- No other changes on the application were necessary (in case of a one-line PR), or
- What changes had to be made with this lib update
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.
We have both mysql
and mysql2
on the project, mysql2
is used by sequelize during migrations
Both OkPacket
are exactly the same on both libraries, I changed this because I needed a type from mysql2
but ended up not using it and forgot to rollback to mysql
instead of mysql2
Changed mysql2
to mysql
in 79b8d38
const addresses = await mysql.query<AddressInfo[]>( | ||
` | ||
SELECT \`address\`, \`index\`, \`transactions\` | ||
FROM \`address\` pd |
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.
For an address to be available in this table, we need to have had a transaction involving the address, right?
I'm asking this because, if this is true, then this new API you're building won't be able to actually derive a new address at an index, right?
I don't know how this API will be used to evaluate whether this is a limitation or not
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.
You're partially correct
We also make sure that the wallet always have at least MAX_GAP
addresses starting from the last used index
So you're correct that this API won't be able to actually derive a new address at an index, but that's the expected behavior since this is exactly what the old facade does, so this is definetly a limitation but is not a problem for our use case
I added a notice in the API docs in 724fde2
src/db/index.ts
Outdated
@@ -7,7 +7,7 @@ | |||
import { strict as assert } from 'assert'; | |||
import { ServerlessMysql } from 'serverless-mysql'; | |||
import { get } from 'lodash'; | |||
import { OkPacket } from 'mysql'; | |||
import { OkPacket } from 'mysql2'; |
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 uncertain if this change should be made here. I feel that having it in its own PR would make it easy for future developers to understand that:
- No other changes on the application were necessary (in case of a one-line PR), or
- What changes had to be made with this lib update
69a6e83
to
a3a71a4
Compare
Motivation
Currently the
getAddressAtIndex
method in the wallet service facade is broken since it expectsthis.seed
to have the seed loaded and we don't keep it in memory, so it derives an address from an empty Mnemonic:https://github.com/HathorNetwork/hathor-wallet-lib/blob/652b94e72021dd11cd0372d3a5b750d9d83f0e29/src/wallet/wallet.ts#L991
We could ask for the user's PIN and use his seed to derive the address at an index, but that would also force us to also ask the PIN on the fullnode facade, which is something we don't want to do.
Acceptance Criteria
flake.nix
,flake.lock
anddirenv
files to setup a working nodejs14 environment using nix flakesSecurity Checklist