UnifiedSpendingKey.fromSeed constructor
UnifiedSpendingKey.fromSeed({
- required List<
int> seedBytes, - required ZCashNetwork network,
- required ZCryptoContext context,
- Bip32KeyIndex? accountIndex,
Implementation
factory UnifiedSpendingKey.fromSeed({
required List<int> seedBytes,
required ZCashNetwork network,
required ZCryptoContext context,
Bip32KeyIndex? accountIndex,
}) {
final config = ZcashConf().fromNetwork(network);
List<Bip32KeyIndex> accountIndexes = [];
if (accountIndex != null) {
accountIndexes.add(accountIndex);
} else {
accountIndexes = Bip32PathParser.parse(config.defPath).elems;
}
final zip32Path =
Bip32Path(
elems: [
Bip32KeyIndex.hardenIndex(32),
Bip32KeyIndex.hardenIndex(config.coinIdx),
...accountIndexes,
],
).toPath();
final tPath = Bip32Path(
elems: [
Bip44Const.purpose,
Bip32KeyIndex.hardenIndex(config.coinIdx),
...accountIndexes,
],
);
Bip32Slip10Secp256k1 transparent = Bip32Slip10Secp256k1.fromSeed(seedBytes);
transparent = transparent.derivePath(tPath.toPath());
Zip32Sapling sapling = Zip32Sapling.fromSeed(
seedBytes,
).derivePath(zip32Path, context);
Zip32Orchard orchard = Zip32Orchard.fromSeed(
seedBytes,
).derivePath(zip32Path, context);
return UnifiedSpendingKey._(
sapling: sapling,
orchard: orchard,
transparent: transparent,
context: context,
config: config,
);
}