encode static method
String
encode(
- List<
int> privKey, { - List<
int> netVer = const [], - PubKeyModes pubKeyMode = PubKeyModes.compressed,
Encodes a private key into a WIF string.
The privKey
is the private key to be encoded, and netVer
is an optional
list of network version bytes. By default, it's an empty list.
The pubKeyMode
determines the mode of the associated public key, where
WifPubKeyModes.compressed
represents the compressed mode.
Returns the WIF-encoded private key as a string.
Implementation
static String encode(List<int> privKey,
{List<int> netVer = const [],
PubKeyModes pubKeyMode = PubKeyModes.compressed}) {
final prv = Secp256k1PrivateKeyEcdsa.fromBytes(privKey);
List<int> privKeyBytes = prv.raw;
if (pubKeyMode == PubKeyModes.compressed) {
privKeyBytes =
List<int>.from([...privKeyBytes, WifConst.comprPubKeySuffix]);
}
privKeyBytes = List<int>.from([...netVer, ...privKeyBytes]);
return Base58Encoder.checkEncode(privKeyBytes);
}