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

feat: Legacy XprvDouble Support #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

parodyBit
Copy link
Collaborator

Copy link
Member

@Tommytrg Tommytrg left a comment

Choose a reason for hiding this comment

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

Could you run dart format .?

@Tommytrg
Copy link
Member

Could we rename the method fromEncryptedXprv with fromEncryptedXprvSingle and then create a method fromEncryptedXprv that receives an XPRV and a password and calls fromEncryptedXprv orfromEncryptedXprvSingle according to the length of the XPRV?

const ENCRYPTED_XPRV_DOUBLE_LENGTH = 478;
const ENCRYPTED_XPRV_SINGLE_LENGTH = 293;

static List<Xprv> fromEncryptedXprv(String xprv, String password) {
  try {
    int xprvLength = xprvString.length;
    if (xprvLength == ENCRYPTED_XPRV_SINGLE_LENGTH)  {
      return Xprv.fromEncryptedXprvSingle(xprv, password); 
    }

    if (xprvLength == ENCRYPTED_XPRV_DUBLE_LENGTH)  {
       return Xprv.fromEncryptedXprvDouble(xprv, password); 
    }      

    if (xprvLength != ENCRYPTED_XPRV_DUBLE_LENGTH && xprvLength != ENCRYPTED_XPRV_SINGLE_LENGTH)  {
      throw proper_error_because_xprv_is_invalid();
    }
  } catch (e) {
     rethrow;
  }
}

Tommytrg added a commit to Tommytrg/my-wit-wallet that referenced this pull request Aug 17, 2023
We are moving the business logic related to the XPRV length to the witnet.dart
library (https://github.com/witnet/witnet.dart). So, in this PR, we only remove
the XPRV length validation while importing a wallet. The logic to handle a
double XPRV is implemented here: witnet/witnet.dart#31
Tommytrg added a commit to Tommytrg/my-wit-wallet that referenced this pull request Aug 17, 2023
We are moving the business logic related to the XPRV length to the witnet.dart
library (https://github.com/witnet/witnet.dart). So, in this PR, we only remove
the XPRV length validation while importing a wallet. The logic to handle a
double XPRV is implemented here: witnet/witnet.dart#31
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.

None yet

2 participants