createWallet method

  1. @override
Future<void> createWallet()
override

지갑 생성 이미 지갑이 있을경우 기존 지갑 로드

Implementation

@override
createWallet() async {
  final coin = TWCoinType.TWCoinTypeSmartChain;
  StoredKey storedKey = StoredKey();
  final directory = await getApplicationDocumentsDirectory();

  if (StoredKey.load("${directory.path}/wallet") != null) {
    print(123);
    myWallet = storedKey.wallet(walletPassword)!;
    return;
  }

  HDWallet wallet = HDWallet();
  StoredKey.importHDWallet(
      wallet.mnemonic(), "BL_WALLET", walletPassword, coin);
  storedKey.store("${directory.path}/wallet");

  // final address = wallet.getAddressForCoin(coin);
  // final derivationPath = "m/44'/60'/0'/0/0";
  // final pubKey = wallet.getExtendedPublicKey(
  //     TWPurpose.TWPurposeBIP44, coin, TWHDVersion.TWHDVersionXPUB);
  //
  // storedKey.addAccount(address, coin, derivationPath, pubKey);
  myWallet = wallet;
}