deriveAccountPublicKey function

Map<String, Object?> deriveAccountPublicKey({
  1. required Map<String, Object?> source,
  2. String chain = 'bitcoin',
  3. String? scriptType,
  4. int account = 0,
  5. String? format,
  6. String? path,
})

Implementation

Map<String, Object?> deriveAccountPublicKey(
    {required Map<String, Object?> source,
    String chain = 'bitcoin',
    String? scriptType,
    int account = 0,
    String? format,
    String? path}) {
  final info = _chain(chain);
  if (info.curve == 'ed25519') {
    throw const WalletHDDerivationException(
        'Solana SLIP-0010 does not define extended public keys');
  }
  final fmt = _format(info, format, scriptType);
  final resolvedPath =
      _path(path ?? _accountPath(info, account, scriptType, fmt));
  final node =
      Bip32Slip10Secp256k1.fromSeed(_sourceSeed(source), _versions(fmt))
          .derivePath(resolvedPath);
  return {
    'schemaVersion': 1,
    'chain': chain,
    'curve': info.curve,
    'path': resolvedPath,
    'format': fmt.name,
    'extendedPublicKey': node.publicKey.toExtended,
    'publicKeyHex': BytesUtils.toHexString(node.publicKey.compressed)
  };
}