Bip32Base<BIP extends Bip32Base<BIP> >.fromExtendedKey constructor
Bip32Base<BIP extends Bip32Base<BIP> >.fromExtendedKey (
- String exKeyStr, [
- Bip32KeyNetVersions? keyNetVer
Creates a BIP-32 key from an extended key string.
The exKeyStr parameter represents the extended key string, and the
optional keyNetVer specifies the key network version.
Implementation
Bip32Base.fromExtendedKey(String exKeyStr, [Bip32KeyNetVersions? keyNetVer]) {
keyNetVer ??= defaultKeyNetVersion;
final deserKey = Bip32KeyDeserializer.deserializeKey(
exKeyStr,
keyNetVer: keyNetVer,
);
final keyBytes = deserKey.keyBytes;
final Bip32KeyData keyData = deserKey.keyData;
final isPublic = deserKey.isPublic;
if (keyData.depth.depth == 0) {
if (!keyData.fingerPrint.isMasterKey()) {
throw Bip32KeyError('Invalid extended master fingerPrint.');
}
if (keyData.index.index != 0) {
throw Bip32KeyError('Invalid extended master child index.');
}
}
_privKey = _initializePrivateKey(
isPublic ? null : keyBytes,
isPublic ? keyBytes : null,
keyData,
keyNetVer,
curveType,
);
_pubKey = _initializePublicKey(
isPublic ? null : keyBytes,
isPublic ? keyBytes : null,
keyData,
keyNetVer,
curveType,
);
}