encode method
Encodes a List
This method takes a List
Returns an Electrum V1 mnemonic representing the encoded data.
entropyBytes
: The List
Implementation
@override
Mnemonic encode(List<int> entropyBytes) {
// Check entropy length
int entropyByteLen = entropyBytes.length;
if (!ElectrumV1EntropyGenerator.isValidEntropyByteLength(entropyByteLen)) {
throw ArgumentException(
'Entropy byte length ($entropyByteLen) is not valid');
}
// Build mnemonic
List<String> mnemonic = [];
for (int i = 0; i < entropyBytes.length ~/ 4; i++) {
mnemonic.addAll(MnemonicUtils.bytesChunkToWords(
entropyBytes.sublist(i * 4, (i * 4) + 4), wordsList,
endian: Endian.big));
}
return ElectrumV1Mnemonic.fromList(mnemonic);
}