serialize static method
String
serialize(
- List<
int> keyBytes, - String pathOrBip32Path,
- Bip32ChainCode chainCodeOrBip32ChainCode,
- String keyNetVerStr,
Serialize an extended key along with path, chain code, and network version.
This method takes the extended key's byte representation keyBytes
, the key's
derivation path or Bip32 path pathOrBip32Path
, the chain code or Bip32 chain code,
and the network version string keyNetVerStr
. It serializes these components and
returns the serialized key as a Bech32-encoded string.
Implementation
static String serialize(
List<int> keyBytes,
String pathOrBip32Path,
Bip32ChainCode chainCodeOrBip32ChainCode,
String keyNetVerStr,
) {
final Bip32Path path = Bip32PathParser.parse(pathOrBip32Path);
final Bip32ChainCode chainCode = chainCodeOrBip32ChainCode;
// Serialize key
final serKey = List<int>.from([
...Bip32Depth(path.length()).toBytes(Endian.little),
..._serializePath(path),
...chainCode.toBytes(),
...keyBytes,
]);
return Bech32Encoder.encode(keyNetVerStr, serKey);
}