ZCashAccount.fromSeed constructor

ZCashAccount.fromSeed({
  1. required List<int> seedBytes,
  2. required ZCashAccountConfig config,
  3. required ZCryptoContext context,
  4. Bip32KeyIndex? accountIndex,
})

Implementation

factory ZCashAccount.fromSeed({
  required List<int> seedBytes,
  required ZCashAccountConfig config,
  required ZCryptoContext context,
  Bip32KeyIndex? accountIndex,
}) {
  List<Bip32KeyIndex> accountIndexes = [];
  if (accountIndex != null) {
    accountIndexes.add(accountIndex);
  } else {
    accountIndexes = Bip32PathParser.parse(config.coinConfig.defPath).elems;
  }
  final zip32Path =
      Bip32Path(
        elems: [
          Bip32KeyIndex.hardenIndex(32),
          Bip32KeyIndex.hardenIndex(config.coinConfig.coinIdx),
          ...accountIndexes,
        ],
      ).toPath();
  Bip32Slip10Secp256k1? transparent;
  if (config.transparentAllowed) {
    final tPath = Bip32Path(
      elems: [
        Bip44Const.purpose,
        Bip32KeyIndex.hardenIndex(config.coinConfig.coinIdx),
        ...accountIndexes,
      ],
    );
    transparent = Bip32Slip10Secp256k1.fromSeed(seedBytes);
    transparent = transparent.derivePath(tPath.toPath());
  }
  Zip32Sapling? sapling;
  if (config.saplingAllowed) {
    sapling = Zip32Sapling.fromSeed(seedBytes).derivePath(zip32Path, context);
  }
  Zip32Orchard? orchard;
  if (config.orchardAllowed) {
    orchard = Zip32Orchard.fromSeed(seedBytes).derivePath(zip32Path, context);
  }
  return ZCashAccount._(
    sapling: sapling,
    orchard: orchard,
    transparent: transparent,
    context: context,
    config: config,
  );
}