toBase58 method

String toBase58()

Private Key To Base58

Implementation

String toBase58() {
  final version =
      (!isNeutered()) ? network.bip32.private : network.bip32.public;
  Uint8List buffer = Uint8List(78);
  ByteData bytes = buffer.buffer.asByteData();
  bytes.setUint32(0, version);
  bytes.setUint8(4, depth);
  bytes.setUint32(5, parentFingerprint);
  bytes.setUint32(9, index);
  buffer.setRange(13, 45, chainCode);
  if (!isNeutered()) {
    bytes.setUint8(45, 0);
    buffer.setRange(46, 78, privateKey!);
  } else {
    buffer.setRange(45, 78, publicKey);
  }
  return bs58check.encode(buffer);
}