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#find_address can not find hd accounts after deserialization #9

Open
ujifgc opened this issue Sep 1, 2020 · 0 comments
Open

Comments

@ujifgc
Copy link
Contributor

ujifgc commented Sep 1, 2020

Have code:

function get_result(hash) {
  if (hash.error) {
    throw error;
  }else{
    return hash.data;
  }
}
var mnemonic_phrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon';
var wallet = get_result(Module.UnoSemuxWallet.new_wallet());
try {
  var hd_group_id = get_result(wallet.add_hd_group(mnemonic_phrase, ''));
  var account = get_result(wallet.generate_next_hd_address(hd_group_id));
  var address = get_result(account.address());
  console.log(`phrase "${mnemonic_phrase}" has primary address "${address}"`);

  var found_account = get_result(wallet.find_address(address));
  var found_address = get_result(found_account.address());
  console.log(`found account ${found_account} with address ${found_address} by address ${address} in original wallet`);

  var serial = get_result(wallet.serialize('password'));
  var restored_wallet = get_result(Module.UnoSemuxWallet.new_wallet());
  restored_wallet.deserialize(serial, 'password');
  var found_restored_account = get_result(restored_wallet.find_address(address));
  var found_restored_address = get_result(found_restored_account.address());
  console.log(`found account ${found_restored_account} with address ${found_restored_address} by address ${address} in restored wallet`);
}
catch(exception) {
  console.log(`failed with exception "${exception}"`);
}

When run it outputs:

phrase "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon" has primary address "d430fd0ddbdab8a767d02c7202dfccd037f97bbb"
VM3505:18 found account [object Object] with address d430fd0ddbdab8a767d02c7202dfccd037f97bbb by address d430fd0ddbdab8a767d02c7202dfccd037f97bbb in original wallet
VM3505:28 failed with exception ">_< Ouch! [GpException]: 'Addres 'd430fd0ddbdab8a767d02c7202dfccd037f97bbb' not found'
Function: 'FindAddr'
    File: 'UnoSemuxWallet'
    Line: 68
"
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

No branches or pull requests

1 participant