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

Added Ledger to Account Create, Import, Migration of Existing #5701

Draft
wants to merge 34 commits into
base: staging
Choose a base branch
from

Conversation

j-s-n
Copy link
Contributor

@j-s-n j-s-n commented Dec 21, 2024

Summary

Added ledger flag to newly created accounts (create, import, multisig, DKG) and migrated db.

Testing Plan

Ledger imports were not workingon my laptop so will need to confirm those next.

  1. Create wallet
    1. false hard coded
    2. tested
  2. Import wallet
    1. ledger
      1. false hard coded
      2. tested
    2. ledger flag
      1. true hard coded
      2. tested
    3. import file
      1. wallet
        1. ledger value decoded
        2. tested
      2. ledger
        1. ledger value decoded
        2. tested
      3. long prompt
        1. ledger value decoded
  3. Multisig
    1. particpants wallets
      1. false hard coded
      2. tested
  4. DKG
    1. wallet
      1. false hard coded
      2. tested
    2. ledger
      1. true hard coded
      2. tested
  5. Edge Cases
    1. Migration
      1. old wallets add false ledger flag
    2. Old wallet imports
      1. decoding added conditional false ledger property if it doesnt exist

Documentation

N/A


## Breaking Change
Don't think so. Ledger flag is only being added to new and existing entries in db.

@j-s-n j-s-n force-pushed the wallet-ledger-flag branch from e497266 to e21967d Compare January 17, 2025 03:00
@@ -529,6 +529,7 @@ export class DkgCreateCommand extends IronfishCommand {
name: accountName,
createdAt: null,
spendingKey: null,
ledger: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be ledger: true -- this is in the performRound3WithLedger method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks. i corrected this.

} from './033-add-ledger-to-accounts/old/accountValue'
import { GetStores } from './033-add-ledger-to-accounts/stores'

export class Migration033 extends Migration {
Copy link
Contributor

Choose a reason for hiding this comment

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

This might need to be Migration034 if it goes in after #5630

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved all of the related files to migration 34, but will discuss if the migration logic will be implemented.

accountForward(oldValue: OldDecryptedAccountValue): NewDecryptedAccountValue {
const newValue = {
...oldValue,
ledger: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the ledger flag will already be false in every account I don't think we need a migration for accounts.

If we want to update the database version we could have a placeholder migration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will discuss if the migration logic will be implemented or if we can do a placeholder migration

@@ -68,6 +68,7 @@ routes.register<typeof ImportParticipantRequestSchema, ImportParticipantResponse
{
name: request.data.name,
secret: request.data.secret ? Buffer.from(request.data.secret, 'hex') : undefined,
ledger: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want this to be true unless we can pass in ledger with the request.

On the other hand, I'm not sure we will want to import participant identities moving forward.

@@ -19,6 +19,7 @@ export interface MultisigIdentityValue {
* while allowing distinction between undefined and actual secrets during deserialization.
*/
secret?: Buffer
ledger: boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this field isn't optional we need a migration to update existing stored identities.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we may actually want to avoid adding ledger to this datastore. I think we should avoid importing just the identity from a ledger device without also importing a full account, and the goal of #5692 is to not have multisig identities stored for imported accounts

@@ -320,6 +320,7 @@ export namespace multisig {
incomingViewKey: string
outgoingViewKey: string
proofAuthorizingKey: string
ledger: boolean
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 an unused change and will be deleted the next time this file is re-generated. This is auto-generated by NAPI-RS so you cannot modify it manually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

think this was added in a previous commit and was causing the lining error comparing rust changes. i removed and it solved the problem.

@@ -45,7 +45,7 @@ import { MultisigIdentityValue, MultisigIdentityValueEncoder } from './multisigI
import { ParticipantIdentity, ParticipantIdentityEncoding } from './participantIdentity'
import { TransactionValue, TransactionValueEncoding } from './transactionValue'

const VERSION_DATABASE_ACCOUNTS = 32
const VERSION_DATABASE_ACCOUNTS = 33
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need to be bumped and the migration needs to be renamed because this PR just merged in migration 33.

#5630

Copy link
Contributor Author

Choose a reason for hiding this comment

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

corrected all references to 34 after 33 was merged

@@ -30,6 +30,7 @@ describe('AccountValueEncoding', () => {
},
scanningEnabled: true,
proofAuthorizingKey: key.proofAuthorizingKey,
ledger: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should flip this to true in one of these tests to check the serialization is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test passed with ledger as true

@j-s-n j-s-n force-pushed the wallet-ledger-flag branch from 6740a3c to 38bf2f8 Compare January 22, 2025 00:22
j-s-n and others added 24 commits January 21, 2025 16:28
…ger to wallet/createAccount. added a ledger flag to buffer for accountvalue
… addition wouldn't cause bech32 to exceed max limit
… in testing environment. tested import manually.
@j-s-n j-s-n force-pushed the wallet-ledger-flag branch from 38bf2f8 to 9234876 Compare January 22, 2025 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants