computeStateHash static method

String computeStateHash(
  1. int accountType,
  2. String account,
  3. String previous,
  4. String representative,
  5. BigInt balance,
  6. String link,
)

Implementation

static String computeStateHash(int accountType, String account,
    String previous, String representative, BigInt balance, String link) {
  assert(accountType == NanoAccountType.BANANO ||
      accountType == NanoAccountType.NANO);
  Uint8List statePreamble = NanoHelpers.hexToBytes(
      "0000000000000000000000000000000000000000000000000000000000000006");
  Uint8List accountBytes =
      NanoHelpers.hexToBytes(NanoAccounts.extractPublicKey(account));
  Uint8List previousBytes = NanoHelpers.hexToBytes(previous.padLeft(64, "0"));
  Uint8List representativeBytes =
      NanoHelpers.hexToBytes(NanoAccounts.extractPublicKey(representative));
  Uint8List balanceBytes = NanoHelpers.bigIntToBytes(balance);
  Uint8List linkBytes = NanoAccounts.isValid(accountType, link)
      ? NanoHelpers.hexToBytes(NanoAccounts.extractPublicKey(link))
      : NanoHelpers.hexToBytes(link);
  return NanoHelpers.byteToHex(Blake2b.digest256([
    statePreamble,
    accountBytes,
    previousBytes,
    representativeBytes,
    balanceBytes,
    linkBytes
  ])).toUpperCase();
}