decodeRaw function

WIF decodeRaw(
  1. Uint8List buffer, [
  2. int? version
])

Implementation

WIF decodeRaw(Uint8List buffer, [int? version]) {
  if (version != null && buffer[0] != version) {
    throw ArgumentError('Invalid network version');
  }
  if (buffer.length == 33) {
    return WIF(
        version: buffer[0],
        privateKey: buffer.sublist(1, 33),
        compressed: false);
  }
  if (buffer.length != 34) {
    throw ArgumentError('Invalid WIF length');
  }
  if (buffer[33] != 0x01) {
    throw ArgumentError('Invalid compression flag');
  }
  return WIF(
      version: buffer[0], privateKey: buffer.sublist(1, 33), compressed: true);
}